function which takes functions as arguments



On Wed, 2007-10-03 at 23:13 +0300, U?ur G?ney wrote:
> # the user will define three functions
> x1(q1,q2,q3):= some function of q1,q2 and q3;
> x2(q1,q2,q3);= ...;
> # and call
> J: find_jacobian(x1,x2,x3); 
> # and have the Jacobian in J.
> # How can I do this? 

Maxima already has a jacobian() function that does what you want, even
though it has not been documented yet. Example:

(%i12) x(r,theta,phi):=r*sin(theta)*cos(phi)$
(%i13) y(r,theta,phi):=r*sin(theta)*sin(phi)$
(%i14) z(r,theta,phi):=r*cos(theta)$

(%i15)
jacobian([x(r,theta,phi),y(r,theta,phi),z(r,theta,phi)],[r,theta,phi]);

(%o15)
[ cos(phi) sin(theta)  cos(phi) r cos(theta)  - sin(phi) r sin(theta) ]
[                                                                     ]
[ sin(phi) sin(theta)  sin(phi) r cos(theta)   cos(phi) r sin(theta)  ]
[                                                                     ]
[     cos(theta)          - r sin(theta)                 0            ]

(%i16) trigsimp(determinant(%));
                                  2
(%o16)                           r  sin(theta)

Regards,
Jaime Villate