rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

solve returns nonlinear solution to linear equations #2823

Open rtoy opened 1 week ago

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 22:15:21 Created by *anonymous on 2010-05-19 09:44:40 Original: https://sourceforge.net/p/maxima/bugs/1988


It is present in CVS maxima, too.

(%i1) build_info();

Maxima version: 5.21.1 Maxima build date: 14:2 5/18/2010 Host type: i686-pc-linux-gnu Lisp implementation type: CMU Common Lisp Lisp implementation version: CVS 19d 19d-release (19D)

(%o1) ""

eqs are linear in x,y and z. The solution should be linear (affine).

(%i2) eqs:[z/sqrt(2*A^2+1)-A*y/sqrt(2*A^2+1)
-A*x/sqrt(2*A^2+1)+A/sqrt(2*A^2+1),
-B*z/sqrt(2*B^2+16)-B*y/sqrt(2*B^2+16)
+4*x/sqrt(2*B^2+16)
+B/sqrt(2*B^2+1)]$

neqs are similar. (%i3) neqs:subst(B=A,eqs)$

(%i4) solve(eqs,[x,y,z])$

(%i5) map(lambda([t],is(rhs(t)=0)),first(diff(%,last(%rnum_list),2)));

This output should be all true. (%o5) [false,true,false] (%i6) solve(neqs,[x,y,z])$

(%i7) map(lambda([t],is(rhs(t)=0)),first(diff(%,last(%rnum_list),2)));

And it is all true for neqs. (%o7) [true,true,true]

Note that algsys doesn't have this problem. (%i8) algsys(eqs,[x,y,z])$

(%i9) map(lambda([t],is(rhs(t)=0)),first(diff(%,last(%rnum_list),2)));

(%o9) [true,true,true] (%i10) algsys(neqs,[x,y,z])$

(%i11) map(lambda([t],is(rhs(t)=0)),first(diff(%,last(%rnum_list),2)));

(%o11) [true,true,true]

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 22:15:22 Created by willisbl on 2010-05-19 11:10:09 Original: https://sourceforge.net/p/maxima/bugs/1988/#90bf


The problem is still present with B : 0. Also, I think the bug is in linsolve

(%i80) eqs:[z/sqrt(2*A^2+1)-A*y/sqrt(2*A^2+1) -A*x/sqrt(2*A^2+1)+A/sqrt(2*A^2+1), -B*z/sqrt(2*B^2+16)-B*y/sqrt(2*B^2+16) +4*x/sqrt(2*B^2+16) +B/sqrt(2*B^2+1)]$ (%i81) ee : subst([B = 0],eqs); (%o81) [-(y*A)/sqrt(2*A^2+1)-(x*A)/sqrt(2*A^2+1)+A/sqrt(2*A^2+1)+z/sqrt(2*A^2+1),x] (%i82) linsolve(ee,[x,y,z]); (%o82) [x=0,y=%r21,z=%r21^2-%r21]