8000 Bug in solve with option to_poly_solve · Issue #20436 · sagemath/sage · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Bug in solve with option to_poly_solve #20436
Open
@bgrenet

Description

@bgrenet

As reported in a question of ask.sagemath.org, 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')
%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:

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! **

CC: @kcrisman @rwst

Component: symbolics

Keywords: maxima, solve

Issue created by migration from https://trac.sagemath.org/ticket/20436

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0