# [Maxima] Solving (systems of) non-linear equations?

Chris Sangwin sangwinc at for.mat.bham.ac.uk
Mon Mar 19 10:01:52 CDT 2007

```Alasdair,

Here is an example which may help (tested Maxima 5.11.0, Windows)

(See http://personal.atl.bellsouth.net/e/d/edwin222/ellipsedevice.htm for
mathematical background)

poly_depends_varsp(ex,vars):=block([sov],sov:setify(listofvars(ex)),vars:setify(vars),subsetp(sov,vars))\$

/* Takes a list of polynomials (Grobner basis) gb, and */
/* a list of variables vars, and returns the expressions in gb which
depend only on the vars */
poly_isolate(gb,vars):= if listp(gb) then
if gb#[] then
if poly_depends_varsp(first(gb),vars)
then
append([first(gb)],poly_isolate(rest(gb),vars))
else poly_isolate(rest(gb),vars)
else []
else []\$

/* Trammel of Archimedes */
/* (0,t): coordinate of one end of line, constrained to move on the y-axis
*/
/* (s,0): coordinate of one end of line, constrained to move on the x-axis
*/
/* (x,y): point on line */
P1:s^2+t^2-a^2;         /* line is of fixed length */
P2:s*y+t*x-s*t;         /* (x,y) lies on the line through (0,t) and (s,0)
*/
P3:(x-s)^2+y^2-b^2;     /* constrain point on line to be b away from (s,0)
*/
/* Note, this gives two solutions */
P4:x^2+(y-t)^2-(b-a)^2; /* constrain point on line to be b-a away from
(0,t) */

sgen:ev([P1,P2,P3,P4]);

/*pg:poly_grobner(sgen,[s,t,a,b,x,y]);*/
prg:poly_reduced_grobner(sgen,[s,t,a,b,x,y]);

map(listofvars,prg);
map(lambda([ex],poly_depends_varsp(ex,[a,b,x,y])),prg);

sol:poly_isolate(prg,[a,b,x,y]);
/* Now we can really see that the trammel of Archemedes is an ellipse....
!*/
format(sol[1],%poly(y,x),factor);
print("This is an ellipse....");
```