[Maxima] function which takes functions as arguments
Stavros Macrakis
macrakis at alum.mit.edu
Thu Oct 4 09:25:19 CDT 2007
On 10/3/07, Uğur Güney <ugurguney at gmail.com> wrote:
> # I want to study coordinate transformations using Maxima. What I want is to
> have a function, find_jacobian(), which takes tree functions as arguments
> and returns a matrix.
As a general rule, Maxima is set up to work more conveniently with
*expressions* than with functions. So I would recommend that you
write, e.g.
ax : r*sin(th)*cos(ph);
that is, setting ax to an *expression* instead of defining x() as a function.
etc.
Then writing the Jacobian is trivial:
jacobian_matrix(exprs,vars) :=
genmatrix(lambda([i,j],diff(exprs[i],vars[j]),length(exprs),length(vars));
jacobian_matrix( [ax,ay,az], [r, th, ph] ) =>
matrix([cos(ph)*sin(th), cos(ph)*r*cos(th), -sin(ph)*r*sin(th)],
[sin(ph)*sin(th), sin(ph)*r*cos(th), cos(ph)*r*sin(th)],
[cos(th), -r*sin(th), 0 ])
-s
More information about the Maxima
mailing list