symbolic vector differentiation



Not exactly what the poster is looking for, but related: as of the upcoming
version, the itensor package will have the ability to carry out
differentiation with respect to indexed variables, including variables that
contain (coordinate) derivative indices. I also added a few demos that
demonstrate how this can be used in practice, e.g., deriving the field
equations of relativity from the Einstein-Hilbert Lagrangian via the
second-order Euler-Lagrange equation.


Viktor
 

-----Original Message-----
From: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu]
On Behalf Of Robert Dodier
Sent: Friday, April 04, 2008 2:07 AM
To: dmnewman at pobox.com
Cc: maxima at math.utexas.edu
Subject: Re: [Maxima] symbolic vector differentiation

On 4/3/08, Daniel M. Newman <dmnewman at pobox.com> wrote:

>  (%i3) T:v . transpose(v);
>  (%o3) v[3]^2+v[2]^2+v[1]^2
>
>  (%i4) diff(T,v);
>  Non-variable 2nd argument to diff:[v[1],v[2],v[3]] -- an error.  To
>  debug this try debugmode(true);

Well, here is a not-very-straightforward way to get that, and the
bad news is that I don't think anything simpler can work.

:lisp (setf (symbol-function '$olddiff) #'$diff)
diff (x, y, n):= if listp (y) then map (lambda ([v], diff (x, v, n)),
y) else olddiff (x, y, n);

With that,

T: v[3]^2+v[2]^2+v[1]^2;
diff (T, [v[1], v[2], v[3]], 1);
 => [2*v[1], 2*v[2], 2*v[3]]

To make n optional (with default n = 1) is more work, so is handling
'diff nouns (i.e. things that are displayed with Leibniz notation).

We should consider having built-in diff and 'diff handle differentiation
wrt to a list of variables. It is broadly useful and not easy.

Hope this helps

Robert Dodier
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima