Basic algebraic equations query in Maxima




On Mon, 19 Apr 2010, Brian Wylie wrote:

< Hi,
< 
< I have a really humble request: if someone can correct me on the
< syntax I'm using below, I'd be really grateful. I'm new to Maxima, and
< have looked through the wxMaxima-distribution-included "Introduction
< to Maxima", but having Matlab/Scilab experience, am struggling to see
< how I should structure my code correctly.
< 
< I'm giving three expressions to Maxima: one each for real variables x,
< y, and z, but each first given in a form of a measured variable, ie
< xMeas, yMeas, zMeas. Ultimately, I want expressions for x, y, z as
< functions of xMeas, yMeas, zMeas, and all the other constants
< introduced, where y contains nested x to be substituted in, and z
< contains nested x and y to be substituted in.
< 
< My code:
< 
< kill(all);
< EqX1: xMeas = a*x + x0;
< x: solve(EqX1, x);
< EqY1: yMeas = b*(y*cos(rho)+x*sin(rho)) + y0;
< y:solve(EqY1, y);
< EqZ1: zMeas = c*(z*cos(phi)*cos(%lambda) + x*sin(phi)*cos(%lambda) +
< y*sin(%lambda)) + z0;
< z: solve(EqZ1, z);
 
Welcome to Maxima.

I think that your approach is perhaps too prescriptive.
Solve is able to solve your equations simultaneously, and
this leads to more extensible code:

kill(all);
IO: [xMeas = a*x + x0,
     yMeas = b*(y*cos(rho)+x*sin(rho)) + y0,
     zMeas = c*(z*cos(phi)*cos(%lambda) + x*sin(phi)*cos(%lambda) +
y*sin(%lambda)) + z0];
vars : [x,y,z];
solve(IO,vars);
subst(%,vars);


If you decide to add a 4th equation+variable, you need only to make
two minor edits. 

Leo

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.