On 9 January 2012 15:42, Matthew <[email protected]> wrote: > You could do the above by explicitly making a scalar symbol for each > of x[0], x[1], ... > > >>> x,y,z = symbols('x y z') > >>> X = Matrix([[x], [y], [z]]) > >>> f = 5*X[0]**2 + 5*X[1]**2 + 5*X[2]**2 > > >>> Matrix([f]).jacobian(X) > [10⋅x 10⋅y 10⋅z] > > >>> Matrix([f]).jacobian(X) * ones(3,1) # inner product with ones vector > to sum > [10⋅x + 10⋅y + 10⋅z] > > I believe there is a clean way to make a bunch of symbols x0, x1, x2, > x3, ... easily using the symbols function. I just don't know it. > It's var('x0:4') but I'm unsure whether it's a good idea to use it in a script. Anyway, there is no problem to use it interactively.
> > > On Jan 8, 6:41 pm, Alan Bromborsky <[email protected]> wrote: > > On 01/08/2012 07:06 PM, John B wrote: > > > > > > > > > > > > > > > > >> You might find section 11.1 in "Geometric Algebra for Physicists" by > > >> Doran and Lasenby relevant. Also go tohttp:// > www.montgomerycollege.edu/Departments/planet/planet/Numerical_... > > >> and download bookGA.pdf. and look at chapter 6. > > > Hello Alan: > > > Thanks, but perhaps my example did not help to explain my real > > > question. Here is a more simple statement of my question. Is there a > > > way to use sympy to differentiate, for example, the function: > > > > > f = 5*x[0]**2 + 5*x[1]**2 + ...5*x[n]**2, where x is in vector or > > > matrix form to obtain the symbolic answer df/dx = > > > > > Sum(10*x[i], (i,0,n)) > > > > > That is, is there some way to write in sympy (Sum(5*x[i]**2, (i, > > > 0,n))).diff()? > > > John > > > > Is x[j] a vector or matrix or is x = (x[0],...,x[n]) the vector for the > > vector case, then how would you write the matrix case? > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
