Opened 5 years ago

Last modified 4 years ago

#20436 new defect

Bug in solve with option to_poly_solve

Reported by: bruno Owned by:
Priority: major Milestone: sage-7.2
Component: symbolics Keywords: maxima, solve
Cc: kcrisman, rws Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


As reported in a question of, there is a bug when one uses the option to_poly_solve of solve:

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?):

sage: (p == 0)._maxima_().to_poly_solve(x, options='algexact:true')

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:

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')

Important note :-)

I do not know how to fix this bug!

Change History (4)

comment:1 Changed 5 years ago by kcrisman

  • Cc kcrisman rws added

comment:2 Changed 5 years ago by kcrisman

For what it's worth, this already happens in Sage 5.2 (nearly four years old). Likely we just never came across an example where it didn't just return a list of solutions when it couldn't give an exact answer.

comment:3 Changed 5 years ago by kcrisman

(Also, the fix would be to somehow parse or otherwise deal with %solve objects in Maxima.)

comment:4 Changed 4 years ago by kcrisman

I think #22709 is a dup.

Also, a simpler example is just

Note: See TracTickets for help on using tickets.