Problem with the 'solve' function - results/whether or not it returns anything dependent depend on the order (or presense) of the list of variables given to solve -- consider following MWE:
like : 28*log((1-s)*r)+18*log(s*(1-s)*r)+18*log(s*s*(1-s)*r)
+436*log((1-s)*(1-r)+s*(1-s)*(1-r)+s*s*(1-s)*(1-r)+s*s*s);
dlike_s : diff(like,s)=0;
dlike_r : diff(like,r)=0;
If I try solve([dlike_s,dlike_r],[s,r]);
(%i4) solve([dlike_s,dlike_r],[s,r]);
(%o4) []
if I simply switch the order of the variables...
(%i5) solve([dlike_s,dlike_r],[r,s]);
(%o5) [[r = 50653/(454750+4000*sqrt(4021)),s = -(sqrt(4021)+5)/74],
[r = -50653/(4000*sqrt(4021)-454750),s = (sqrt(4021)-5)/74]]
Further, if I leave the list of variables off altogether:
(%i6) solve([dlike_s,dlike_r]);
(%o6) [[r = 50653/(454750+4000*sqrt(4021)),s = -(sqrt(4021)+5)/74],
[r = -50653/(4000*sqrt(4021)-454750),s = (sqrt(4021)-5)/74]]
Also, same is true if 'algsys' is used instead of 'solve'.
Diff:
Diff:
Another example from the mailing list 2016-05-11: "Solve command succeeds or fails based on order variables are specified in the argument"
The first is definitely an algsys problem. I will have a look.
I have simplified the original equations and changed variables, but the bug is still there.
I have traced the working solution through algsys and followed the process manually in maxima. Here is the manual workings for the first solution found by maxima at %o3 (see batch file bug3013.mac attached). It is the second solution in the list.
Last edit: David Billinghurst 2016-10-05
This is what maxima attempts for the failed case.
1. algsys choses to eliminate y first
2. we solve for x successfully
3. substitute x into eq1 and eq2
4. equations for y are cubic
5. solutions are correct, but too complicated as maxima can't denest cube roots
6. fail
We could make progress by any of:
1. chosing to first eliminate x. This is based on a heuristic and it may be possible to do better.
2. denesting cube roots. Not trivial but the correct solution.
3. switching to a numerical solution at some point. This is done if solve can't find a symbolic solution, but not when solve finds a "complicated" solution. Perhaps we could numerically evaluate constant expressions in presultant and do something - at least give a warning - if the result is close to zero.
Last edit: David Billinghurst 2016-10-05
Here is a reduced test case for the failure above. It should return the real solution of Y2 above.