Hello everyone, 
In designing the vector module, I have defined a class called 'Del', whose 
instances will act as the Del operator <http://en.wikipedia.org/wiki/Del> 
for the coordinate system it is assigned to.
An example of code using the operator -

>>> C = CoordSysCartesian('C')
>>> i, j, k = C.base_vectors()
>>> x, y, z = C.base_scalars()
>>> delop = C.delop

*For divergence*- 

>>> v = x*y*z * (i + j + k)
>>> delop & v
x*y + y*z + z*x

*Curl *-

>>> delop ^ v  #^ stands for 'cross'
(-x*y + x*z)*i + (x*y - y*z)*j + (-x*z + y*z)*k

*Gradient* -

>>> delop(x*y*z)
y*z*i + z*x*j + x*y*k

*Directional derivative*-

>>> (i & delop)(x)
1

Now the question is, is there a need/is it possible to code Del similar to 
Derivative or Integral? Especially with respect to unevaluated expressions. 
Jason suggested I look into it, though I am not sure how it will work, or 
what a use case will be.

Any suggestions/thoughts?

On Friday, June 6, 2014 7:14:51 PM UTC+5:30, Sachin Joglekar wrote:
>
> Hello everyone,
> I have been working on a basic vector framework for sympy for some time 
> now. I am still working on the classes for coordinate systems, so currently 
> all operations occur in the _same_ frame. The PR for the code is here 
> <https://github.com/sympy/sympy/pull/7566>.
>
> To get you started, here is how you would do some basic vector 
> manipulations using the code (i, j, k are by default base vectors, and x, 
> y, z are by default base scalars. Better naming ideas?)-
>
> >>> from sympy.vector import *
> >>> u = 4*i - 5*k
> >>> from sympy.vector.vector import VectorAdd
> >>> isinstance(u, VectorAdd)
> True
> >>> v = 8*k
> >>> u += v
> >>> u ^ v
> ...output...
>
> Now I am facing a few problems..
>
> 1. How do I ensure methods like 'trigsimp' work with these classes? 
> Currently, passing a vector like *(sin(a)+cos(a))**2*i - j* to trigsimp 
> returns the correct answer mathematically, _but_ the instance is of type 
> Add (instead of the expected VectorAdd). How do I prevent this?
>
> 2. How do I get 'solve' to work with these classes? For example, consider 
> a problem solved (in the future) using the module -
>
> *Do the following vectors form a basis for R^3: {(2,-3,1), (4,1,1), 
> (0,-7,1)}?* 
>
> To check if the vectors can form a basis, we check if the 3 conventional 
> basis vectors can be expressed in terms of the given vectors. First, define 
> b1, b2 and b3 as the vectors in question
>
> >>> b1 = 2*R.i - 3*R.j + R.k
> >>> b2 = 4*R.i + R.j + R.k
> >>> b3 = - 7*R.j + R.k
>
> Define three Symbols as the coefficients of the linear multiples
>
> >>> a, b, c = symbols('a b c')
>
> Now check if R.i = x*b1 + y*b2 + z*b3n returns a valid solution. If yes, 
> do the same for R.j and R.z. If all three have some solution (not 
> necessarily same), the vectors do form a basis.
>
> >>> solve(R.i - (a*b1 + b*b2 + c*b3), a, b, c)
> >>>
>
> solve returned None. Hence, solution does not exist. Therefore, the given 
> vectors cannot define a basis for R^3.
>
> I think it would involve changing the code for 'solve' itself. Any ideas?
>
> I guess answering these questions may require a look at my code, so any 
> help is appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2fcbb902-0439-4d2b-84e6-f4da2024e449%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to