to_poly_solve causes TypeError on certain equations [closed]
sage: x, theta = var('x, theta')
sage: assume(x > 0, theta >= 0, theta < 2 * pi)
sage: assume(x, 'real')
sage: assume(theta, 'real')
sage: solve(x/cos(theta) == sqrt(sin(theta)), theta, to_poly_solve=true)
This code causes an error (below)
The assume() lines seemingly aren't causing the issue (error happens without them). This code will still crash:
sage: x, theta = var('x, theta')
sage: solve(x/cos(theta) == sqrt(sin(theta)), theta, to_poly_solve=true)
I encountered this issue while working on a more complex equation, and this is the simplest version of the problem I could reproduce.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 solve(x/cos(theta) == sqrt(sin(theta)), theta, to_poly_solve=true)
File /usr/lib/python3.14/site-packages/sage/symbolic/relation.py:1202, in solve(f, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain, *args)
1199 return [[]]
1201 if len(f) == 1:
-> 1202 return _solve_expression(f[0], x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
1204 if algorithm == 'sympy':
1205 from sympy import solve as ssolve
File /usr/lib/python3.14/site-packages/sage/symbolic/relation.py:1505, in _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
1503 s = m.to_poly_solve(x, options='algexact:true')
1504 T = string_to_list_of_solutions(repr(s))
-> 1505 X.extend([t[0] for t in T])
1506 except TypeError as mess:
1507 if ignore_exceptions:
TypeError: 'sage.symbolic.expression.Expression' object is not subscriptable
I am running sagemath 10.8 with GNU/Linux
Looks like a bug. Please report at https://github.com/sagemath/sage/issues
https://github.com/sagemath/sage/issu... I have made the appropriate issue on the github