#20436: Bug in solve with option to_poly_solve
-------------------------+---------------------------------
   Reporter:  bruno      |            Owner:
       Type:  defect     |           Status:  new
   Priority:  major      |        Milestone:  sage-7.2
  Component:  symbolics  |         Keywords:  maxima, solve
  Merged in:             |          Authors:
  Reviewers:             |  Report Upstream:  N/A
Work issues:             |           Branch:
     Commit:             |     Dependencies:
   Stopgaps:             |
-------------------------+---------------------------------
 As reported in a [http://ask.sagemath.org/question/33050 question of
 ask.sagemath.org], there is a bug when one uses the option `to_poly_solve`
 of `solve`:

 {{{#!python
 sage: p = x^10 - 10*x^8 + 35*x^6 + x^5 - 50*x^4 - 5*x^3 + 25*x^2 + 5*x - 1
 sage: p.solve(x, to_poly_solve=True)
 Traceback (most recent call last):
 ...
 TypeError: 'sage.symbolic.expression.Expression' object does not support
 indexing
 }}}

 === Explanation for the bug
 The method `solve` with this option rely on Maxima's `to_poly_solve`
 function, with option `'algexact:true'`, and expect the follwoing behavior
 from Maxima:
 * Either return a list of explicit solutions;
 * Or raise a `TypeError` (with message containing "Error executing code in
 Maxima" or equivalent).
 It happens that this is not the case (anymore?):
 {{{#!python
 sage: (p == 0)._maxima_().to_poly_solve(x, options='algexact:true')
 
%solve([_SAGE_VAR_x^10-10*_SAGE_VAR_x^8+35*_SAGE_VAR_x^6+_SAGE_VAR_x^5-50*_SAGE_VAR_x^4-5*_SAGE_VAR_x^3+25*_SAGE_VAR_x^2+5*_SAGE_VAR_x-1=0],[_SAGE_VAR_x])
 }}}
 Since the value returned by Maxima is not in the expected format,
 conversion to Sage object fails, as exemplified above.

 For completeness, an example where everything works fine follows:
 {{{#!python
 sage: q = x^6 + x^5 + 3*x^4 + 6*x^3 + x - 1
 sage: q.solve(x, to_poly_solve=True)
 [x == -1.635043562439497,
  x == 0.424403370866086,
  x == (0.2765006996266782 - 1.917801305541673*I),
  x == (-0.1711805215349513 - 0.595429812852917*I),
  x == (-0.1711805215349513 + 0.595429812852917*I),
  x == (0.2765006996266782 + 1.917801305541673*I)]
 sage: (q == 0)._maxima_().to_poly_solve(x, options='algexact:true')
 
%union([_SAGE_VAR_x=-1.635043562439497],[_SAGE_VAR_x=0.424403370866086],[_SAGE_VAR_x=0.2765006996266782-1.917801305541673*%i],[_SAGE_VAR_x=-0.595429812852917*%i-0.1711805215349513],[_SAGE_VAR_x=0.595429812852917*%i-0.1711805215349513],[_SAGE_VAR_x=1.917801305541673*%i+0.2765006996266782])
 }}}

 === Important note :-)
 **I do not know how to fix this bug! **

--
Ticket URL: <http://trac.sagemath.org/ticket/20436>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to