rtoy / maxima

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

solve() result like 0/0 #1353

Open rtoy opened 3 months ago

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-04 09:56:08 Created by jpunktbarth on 2021-08-26 08:07:32 Original: https://sourceforge.net/p/maxima/bugs/3840


(%i1) solve([1.5=a/(a+b), 2=b/(a+b)], [a,b]);
(%o1)                          [[a = 0, b = 0]]

this looks like a 0/0 for me. Even with latest maxima 5.45.1 from .rpm.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-04 09:56:10 Created by robert_dodier on 2021-09-01 23:50:50 Original: https://sourceforge.net/p/maxima/bugs/3840/#ad49


rtoy commented 3 months ago

Imported from SourceForge on 2024-07-04 09:56:13 Created by robert_dodier on 2021-09-01 23:50:50 Original: https://sourceforge.net/p/maxima/bugs/3840/#2d35


Looks like solve has cleared the fractions and gotten a solution for that, and then returned that solution without checking that it's valid for the original equations.

It seems like it wouldn't be too hard to verify that the solution is valid for the original equations -- just substitute the would-be solution into the denominator which was multiplied on both sides and verify the result is nonzero.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-04 09:56:17 Created by macrakis on 2021-09-02 00:18:06 Original: https://sourceforge.net/p/maxima/bugs/3840/#72d2


The original solve is very stupid about things like this, and doesn't even have a way to express restrictions on the values of solutions in general. For example, solve([x/y=x],[x,y]) should exclude the case y=0. I suppose it could use [x=0 , y=1/%r5] to express that idea, but (a) it doesn't have any provision for doing this and (b) that's not very helpful to the user. Similarly, I suppose solve(abs(x)=x,x) could give the solution as x=%c1^2, but is that helpful?

%solve does a much better job of all this, and sure enough returns %if(%c1#0,[x=0,y=%c1],...).

At some point, we should probably deprecate solve and promote %solve, though I do have some issues with %solve as well.