# [Maxima] Problem with Matrix

Wolfgang Lindner LindnerW at t-online.de
Thu Dec 18 12:46:58 CST 2008

```dear Rene,

| 2) Is genmatrix the right way to go, like in
| where n is the length of var?

your defintion is reflected in the following definition (from Barton Willis
AFAIK) which is directly usable at the maxima prompt:

hessian (e, vars) :=
block([n:length(vars)],
genmatrix (lambda([i,j], diff(e[i],vars[i],1,vars[j],1) n,
n) );

jacobian(e, vars) :=
block( [m:length(e),n:length(vars)],
genmatrix(lambda([i,j],diff(e[i],vars[j])), m, n) );

So I like to define in my courses:

jacobian ([x*y], [x,y]);
at(%, [x=1,y=1]);

hessian (x^2-x*y+2*y, [x, y] );
determinant(hessian (x^2-x*y+2*y, [x, y] ));

It is also possible to use package 'vect':

grad (x^2 + y^2 + z^2);
express (%);
ev (%, diff);

.. or something like this (depending on what the students are knowing):

Let us know what's your opinion.

sincerely
Wolfgang

-----Ursprüngliche Nachricht-----
Von: Rene Grothmann <2008 at rene-grothmann.de>
An: maxima at math.utexas.edu <maxima at math.utexas.edu>
Datum: Donnerstag, 18. Dezember 2008 15:16
Betreff: [Maxima] Problem with Matrix

I am trying to make some student functions for differentiation, such as
gradient, Jordan matrix, Hesse matrix. However, I have troubles handling
matrices.

1) Is there a way to ask the dimensions of a matrix?

2) Is genmatrix the right way to go, like in

where n is the length of var?

3) Is there any difference between a vector [x,y] and a 1x2-matrix?

Thanks for any responses.