William Stein wrote:
>
>
> On Sun, Aug 9, 2009 at 2:03 PM, Dr. David Kirkby
> <david.kirkby at onetel.net <mailto:david.kirkby at onetel.net>> wrote:
>
>
> Seen with Sage 4.1.1.rc0, with updated ECL 9.8.1 and Maxima 5.19.0.
>
> Should this be reported to the Maxima list?
>
> I've not created a trac ticket for this, as I don't know enough to fill
> it in properly.
>
> File
> "/export/home/drkirkby/sage/sage-4.1.1.rc0/devel/sage/sage/symbolic/expression.pyx",
> line 5329:
> sage: solve(Q*sqrt(Q^2 + 2) - 1,Q)
> Expected:
> [Q == 1/sqrt(-sqrt(2) + 1), Q == 1/sqrt(sqrt(2) + 1)]
> Got:
> [Q == 1/sqrt(sqrt(2) + 1)]
>
>
> This seems like a bug in Maxima to me, at first glance. For comparison,
> here is what Mathematica does (which is the same as Sage right now):
>
> sage: var('Q')
> Q
> sage: m = mathematica(Q*sqrt(Q^2 + 2) == 1); m
> Q*Sqrt[2 + Q^2] == 1
> sage: m.Solve(Q)
> {{Q -> Sqrt[-1 + Sqrt[2]]}, {Q -> (-I)*Sqrt[1 + Sqrt[2]]}}
> sage: m.NSolve(Q)
> {{Q -> 0. - 1.5537739740300396*I}, {Q -> 0.6435942529055826}}
> sage: f = Q*sqrt(Q^2 + 2) - 1
> sage: s = solve(Q*sqrt(Q^2 + 2) - 1,Q, solution_dict=True)
> sage: N(s[0][Q])
> 9.51412161947174e-17 - 1.55377397403004*I
> sage: N(s[1][Q])
> 0.643594252905583
>
> So I think this is a bug. It should return both solutions, but is only
> returning the one real solution. Note that this is the behavior of the
> default Maxima mode even in 5.16.3.
>
> sage: !maxima
> Maxima 5.16.3 http://maxima.sourceforge.net
> Using Lisp ECL 9.4.1
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) solve(Q*sqrt(Q^2+2)-1,Q)
> ;
> 1
> (%o1) [Q = ------------]
> 2
> sqrt(Q + 2)
>
>
> In fact, I can't coerce Maxima to return both solutions *no matter* what
> I do, setting domain:complex, etc. Notice that in fact what Maxima
> does is
> return the "solution" 'Q == 1/sqrt(Q^2 + 2)', which is no solution at
> all since Q is in the right hand side. Sage (in expression.pyx in the
>
> "if explicit_solutions is not False:" part of the code around line
> 5318), looks at each solution, then calls Maxima's to_poly_solve on it.
>
> Here to_poly_solve is a function that is loaded when the maxima
> interface initialization code is run, i.e., "load(topoly_solver)" is
> executed. The maxima interface used by Sage's calculus code is started
> in calculus.py with this line:
>
> maxima = Maxima(init_code = ['display2d:false; domain: complex;
> keepfloat: true; load(topoly_solver)'],
> script_subdirectory=None)
>
> So, my conclusion is that the topoly_solve package is somehow broken in
> the new version of Maxima. In Maxima 5.16.3 we have:
>
> sage: !maxima
> Maxima 5.16.3 http://maxima.sourceforge.net
> Using Lisp ECL 9.4.1
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) load(topoly_solver); domain:complex;
> (%o1)
> /Users/wstein/sage/build/64bit/sage/local/share/maxima/5.16.3/share/cont\
> rib/topoly_solver.mac
> (%i2) (%o2) complex
> (%i3) to_poly_solve(Q = 1/sqrt(Q^2 + 2),Q);
> Assuming that sqrt(Q^2+2) # 0
> (%o3) [[Q = - sqrt(- sqrt(2) - 1)], [Q = sqrt(sqrt(2) - 1)]]
>
> Notice that we got both solutions! Does exactly the same input in
> Maxima 5.19 not work right?
>
> William
No, I only get one solution:
(%i5) drkirkby at smudge:[~/sage/sage-4.1.1.rc0] $ ./local/bin/maxima
;;; Loading
#P"/export/home/drkirkby/sage/sage-4.1.1.rc0/local/lib/ecl-9.8.1/defsystem.fas"
;;; Loading
#P"/export/home/drkirkby/sage/sage-4.1.1.rc0/local/lib/ecl-9.8.1/cmp.fas"
;;; Loading
#P"/export/home/drkirkby/sage/sage-4.1.1.rc0/local/lib/ecl-9.8.1/sysfun.lsp"
Maxima 5.19.0 http://maxima.sourceforge.net
Using Lisp ECL 9.8.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) load(topoly_solver); domain:complex;
(%o1)
/export/home/drkirkby/sage/sage-4.1.1.rc0/local/share/maxima/5.19.0/shar\
e/contrib/topoly_solver.mac
(%o2) complex
(%i3) to_poly_solve(Q = 1/sqrt(Q^2 + 2),Q);
1
(%o3) [[Q = -----------------]]
sqrt(sqrt(2) + 1)
(%i4)
With Mathematica 7 I get two solutions (not sure what version you are
using).
In[4]:= Solve[ Q Sqrt[Q^2 + 2] -1 ==0,Q]
Out[4]= {{Q -> Sqrt[-1 + Sqrt[2]]}, {Q -> -I Sqrt[1 + Sqrt[2]]}}
Anyway, it is time for me to go to bed now. If you want to look at the
test log in Sage, it is here as an attachment. It is not on 't2' at this
point.
http://sagetrac.org/sage_trac/ticket/6709
Dave