def string_to_list_of_solutions(s): r""" Used internally by the symbolic solve command to convert the output of Maxima's solve command to a list of solutions in Sage's symbolic package. EXAMPLES: We derive the (monic) quadratic formula:: sage: var('x,a,b') (x, a, b) sage: solve(x^2 + a*x + b == 0, x) [x == -1/2*a - 1/2*sqrt(a^2 - 4*b), x == -1/2*a + 1/2*sqrt(a^2 - 4*b)] Behind the scenes when the above is evaluated the function :func:`string_to_list_of_solutions` is called with input the string `s` below:: sage: s = '[x=-(sqrt(a^2-4*b)+a)/2,x=(sqrt(a^2-4*b)-a)/2]' sage: sage.symbolic.relation.string_to_list_of_solutions(s) [x == -1/2*a - 1/2*sqrt(a^2 - 4*b), x == -1/2*a + 1/2*sqrt(a^2 - 4*b)] """ from sage.categories.all import Objects from sage.structure.sequence import Sequence from sage.calculus.calculus import symbolic_expression_from_maxima_string v = symbolic_expression_from_maxima_string(s, equals_sub=True) return Sequence(v, universe=Objects(), cr_str=True)
def string_to_list_of_solutions(s): r""" Used internally by the symbolic solve command to convert the output of Maxima's solve command to a list of solutions in Sage's symbolic package. EXAMPLES: We derive the (monic) quadratic formula:: sage: var('x,a,b') (x, a, b) sage: solve(x^2 + a*x + b == 0, x) [x == -1/2*a - 1/2*sqrt(a^2 - 4*b), x == -1/2*a + 1/2*sqrt(a^2 - 4*b)] Behind the scenes when the above is evaluated the function :func:`string_to_list_of_solutions` is called with input the string `s` below:: sage: s = '[x=-(sqrt(a^2-4*b)+a)/2,x=(sqrt(a^2-4*b)-a)/2]' sage: sage.symbolic.relation.string_to_list_of_solutions(s) [x == -1/2*a - 1/2*sqrt(a^2 - 4*b), x == -1/2*a + 1/2*sqrt(a^2 - 4*b)] """ from sage.categories.all import Objects from sage.structure.sequence import Sequence from sage.calculus.calculus import symbolic_expression_from_maxima_string v = symbolic_expression_from_maxima_string(s, equals_sub=True) return Sequence(v, universe=Objects(), cr_str=True)