"Barton Willis" <willisb at unk.edu> schrieb:
>>Q1: where (package?) to find the source code of 'jacobian' and 'hessian'?
> The source for jacobian and hessian is in share/linaralgebra/linalg-extra.
Dear Barton, dear Robert, dear group,
thank you for your valuable hints.
Because I do not speak lisp yet (but I tried to read the souce with interested eyes) I
translated the lisp source of jacobian and hessian to Maxima's own language.
;;; Barton's lisp code:
(defun $hessian (e vars)
(if ($listp vars) (let ((n ($length vars)))
($genmatrix `((lambda) ((mlist) i j) ($diff ,e (nth i ,vars) 1 (nth j ,vars) 1)) n n))
`(($hessian) ,e ,vars)))
My translation:
/* my attempt to translate to Maxima */
hessian1 (e, vars) :=
block([n:length(vars)],
genmatrix (lambda([i,j], diff(e[i],vars[i],1,vars[j],1), n, n) );
^^^ ^^^^
? ?
Testing it ..
(%i87) hessian1(x^2+y^2,[x,y]);
(%o87) matrix([0,0],[0,0])
.. which is wrong.
Q1: I could not find my mistake .. have I misunderstood the lisp code,
have I not yet crasp genmatrix(..) or the diff(..) construct?
I at least hope that my math brain is ok:)
Q2: Is there any advantage in coding hessian in lisp than in maxima?
HTH Wolfgang