I'm trying to do the following in Maxima (within Moodle STACK):
c : matrix([5],[3],[1],[0],[0])
x : matrix([x1],[x2],[x3],[s1],[s2]);
base0 : matrix([0],[0],[5],[0],[1]);
z : transpose(c).x;
zval : subst(base0,x,z);
but all I get as output is x3+3⋅x2+5⋅x1
, which is supposed to be the numerical value of the function z
at the point base0
. I had a similar problem with the solve
-function a little while back, but this time not even the explicit insertion of the components into the expression like so
zval : subst(matrix([0],[0],[5],[0],[1]),matrix([x1],[x2],[x3],[s1],[s2]),matrix([5],[3],[1],[0],[0]).matrix([x1],[x2],[x3],[s1],[s2]));
works. The problem with solve
was never fixed, so I'm wondering if I'm just going to have to calculate things by hand from now on.
subst
is solely a syntactic substitution -- it is looking for an explicit occurrence of the value x
in z
, and it doesn't guess that you mean to equate the i'th elements of base0
and x
.
I get what I think is the intended result by constructing a list of equations to represent the intended substitutions.
(%i6) eqs:makelist(x[i,1] = base0[i,1],i,1,5)
(%o6) [x1 = 0, x2 = 0, x3 = 5, s1 = 0, s2 = 1]
(%i7) zval:subst(eqs,z)
(%o7) 5