>
restart;
>
read
"C:/books/ess/programs/jacobian.mpl";
>
f := [
sin(x-y), cos(x) ];
>
J :=
Jacobian( f, [x,y] );
>
stopat( Jacobian );
>
showstat( Jacobian );
Jacobian := proc(fnlist::list, varlist::list(name))
local J, i, j, m, n, tmp, inds;
1* m := nops(fnlist);
2 n := nops(varlist);
3 J := Matrix(m,n,storage = sparse);
4 for i to m do
5 inds := indets(fnlist[i]);
6 for j to n do
7 if member(varlist[j],inds) then
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
9 if not Testzero(tmp) then
10 J[i,j] := tmp
end if
end if
end do
end do;
11 J
end proc
>
J :=
Jacobian( f, [x,y] );
Jacobian:
1* m := nops(fnlist);
DBG>
next
2
Jacobian:
2 n := nops(varlist);
DBG>
next
2
Jacobian:
3 J := Matrix(m,n,storage = sparse);
DBG>
next
Matrix(2, 2, [[0,0],[0,0]], datatype = anything,
storage = sparse, order = Fortran_order, shape = [])
Jacobian:
4 for i to m do
...
end do;
DBG>
into
Matrix(2, 2, [[0,0],[0,0]], datatype = anything,
storage = sparse, order = Fortran_order, shape = [])
Jacobian:
5 inds := indets(fnlist[i]);
DBG>
next
{x, y, sin(x-y)}
Jacobian:
6 for j to n do
...
end do
DBG>
list
Jacobian := proc(fnlist::list, varlist::list(name))
local J, i, j, m, n, tmp, inds;
1* m := nops(fnlist);
2 n := nops(varlist);
3 J := Matrix(m,n,storage = sparse);
4 for i to m do
5 inds := indets(fnlist[i]);
6 ! for j to n do
7 if member(varlist[j],inds) then
...
end if
...
end do
...
end do;
...
end proc
DBG>
into
{x, y, sin(x-y)}
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
fnlist[i];
sin(x-y)
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
varlist[i];
x
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
varlist[j];
x
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
into
{x, y, sin(x-y)}
Jacobian:
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
DBG>
next
cos(x-y)
Jacobian:
9 if not Testzero(tmp) then
...
end if
DBG>
next
cos(x-y)
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
outfrom
cos(x-y)
Jacobian:
5 inds := indets(fnlist[i]);
DBG>
list
Jacobian := proc(fnlist::list, varlist::list(name))
local J, i, j, m, n, tmp, inds;
1* m := nops(fnlist);
2 n := nops(varlist);
3 J := Matrix(m,n,storage = sparse);
4 for i to m do
5 ! inds := indets(fnlist[i]);
6 for j to n do
...
end do
...
end do;
...
end proc
DBG>
i;
2
Jacobian:
5 inds := indets(fnlist[i]);
DBG>
j;
3
Jacobian:
5 inds := indets(fnlist[i]);
DBG>
into
{x, cos(x)}
Jacobian:
6 for j to n do
...
end do
DBG>
into
{x, cos(x)}
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
into
{x, cos(x)}
Jacobian:
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
DBG>
i;
2
Jacobian:
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
DBG>
j;
1
Jacobian:
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
DBG>
into
0
Jacobian:
9 if not Testzero(tmp) then
...
end if
DBG>
outfrom
0
Jacobian:
7 if member(varlist[j],inds) then
...
end if
DBG>
list
Jacobian := proc(fnlist::list, varlist::list(name))
local J, i, j, m, n, tmp, inds;
...
2 n := nops(varlist);
3 J := Matrix(m,n,storage = sparse);
4 for i to m do
5 inds := indets(fnlist[i]);
6 for j to n do
7 ! if member(varlist[j],inds) then
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
...
end if
...
end do
...
end do;
...
end proc
DBG>
outfrom
0
Jacobian:
11 J
DBG>
list
Jacobian := proc(fnlist::list, varlist::list(name))
local J, i, j, m, n, tmp, inds;
...
6 for j to n do
7 if member(varlist[j],inds) then
8 tmp := Normalizer(diff(fnlist[i],varlist[i]));
9 if not Testzero(tmp) then
10 J[i,j] := tmp
end if
end if
end do
end do;
11 ! J
end proc
DBG>
cont