I want to calculate the inner product of Navra.

Asked 2 years ago, Updated 2 years ago, 143 views

I would like to calculate the inner product ··b using ((nabra), but how can I do it from here?I want to print 3.

import numpy as np
x = Symbol ('x')
y = Symbol('y')
z = Symbol ('z')

del_x = np.gradient(,dx)
del_y=np.gradient(,dy)
del_z=np.gradient(,dz)
nabra=np.array([del_x, del_y, del_z])
b=np.array([x,y,z])
np.inner(nabla,b)

python numpy sympy

2022-09-30 21:48

1 Answers

First, please understand the difference between SymPy and NumPy.SymPy is the library for symbolic calculations and NumPy is the library for numerical calculations.

SymPy then provides a function to represent the vector field.See this document: Scalar and Vector Field Functionality

Sample Program:

>> from sympathy.vector import CodeSys 3D, Del, diversity
>>>#Determine the coordinate system.
... C = CodeSys 3D ('C')
>>># Navra is defined as Del()
... nabla=Del()
>>>#C.i, C.j, C.k are the standard base, and C.x, C.y, C.z are the temporary arguments for the vector field.
... b=C.x*C.i+C.y*C.j+C.z*C.k
>>>#Internal product is dot
... nabla.dot(b)
Derivative(C.x, C.x) + Derivative(C.y, C.y) + Derivative(C.z, C.z)
>>># Use doit() to get differential calculations.
... nabla.dot(b).doit()
3
>>># The inner product with Navra is also defined as diversity.
... diversity(b).doit()
3


2022-09-30 21:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.