On Saturday, April 13, 2013 2:40:52 AM UTC+5:30, brombo wrote: > > Analogous to term pythonic code I would use sympythonic code and make > the following suggestions - > > Start by defining you basis vectors as noncommutative symbols - > > (e1,e2,e3) = symbols('e_1 e_2 e_3',commutative=False) > > Then if a1, a2, and a3 are commutative sympy expressions (symbols) any > vector a is - > > a = a1*e1+a2*e2+a3*e3 > > Then you automatically get vector addition, subtraction, and scalar > multiplication (if c, b1, b2, and b3 are scalars) > > b = b1*e1+b2*e2+b3*e3 > > and > > a+b = (a1+b1)*e1+(a2+b2)*e2+(a3+b3)*e3 > > a-b = (a1-b1)*e1+(a2-b2)*e2+(a3-b3)*e3 > > c*a = c*a1*e1+c*a2*e2+c*a3*e3 > > Then if you define dictionaries for the dot and cross products, dot > product > > dot_dict = > {e1**2:1,e1*e2:0,e1*e3:0,e2*e1:0,e2**2:1,e2*e3:0,e3*e1:0,e3*e2:0,e3**2:1} > > then - > > dot(a,b) = (a*b).subs(dot_dict) > > cross product > > cross_dict = > {e1**2:0,e1*e2:e3,e1*e3:-e2,e2*e1:-e3,e2**2:0,e2*e3:e1,e3*e1:e2,e3*e2:-e1,e3**2:0} > > > > cross(a,b) = (a*b).subs(cross_dict) > > Like wise for coordinate transformations - > > Let the bases be e1,e2,e3 ang g1,g2,g3 be related by g1 = f1(e1,e2,e3), > g1 = f2(e1,e2,e3), g1 = f2(e1,e2,e3) > where f1, f2, and f3 could also be functions of the coordinates then > > g_to_e_dict = {g1:f1,g2:f2,g3:f3} > > a = a1*g1+a2*g2+a3*g3 > > a_in_terms_of_e = a.subs(g_to_e_dict) > > etc. >
Thanks a lot. I'll make the changes soon. -- 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?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.