I replaced e[i] with e and moved one paren to it's proper location.
Now it works:
(%i3) hessian1 (e, vars) :=
block([n:length(vars)],
genmatrix (lambda([i,j], diff(e,vars[i],1,vars[j],1)), n, n))$
(%i4) hessian1(x^2+y^2,[x,y]);
(%o4) matrix([2,0],[0,2])
Barton
-----LindnerW at t-online.de (Wolfgang Lindner) wrote: -----
>To: "Barton Willis" <willisb at unk.edu>
>From: Wolfgang Lindner
>Date: 05/31/2007 03:27PM
>cc: "maxima-help" <maxima at math.utexas.edu>
>Subject: Re: [Maxima] jacobian not listed
>
>"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