Quantcast
Channel: ASKSAGE: Sage Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 4

Can I get a polynomial type from a symbolic expression type?

Previous: Answer by rws for I am doing some things to a symbolic variable C...sage: C = var('C') sage: # ... do a whole bunch of stuff with C as a symbolic variable, sage: # and at some point get sage: g = solve(f, C) sage: print(g) [0 == 25*C^5 - 325*C^4 + 16276*C^3 - 228488*C^2 - 5940688] sage: # implicit solution is polynomial in C ... resulting in a polynomial in C that is typed as a symbolic expression:sage: print g[0].rhs() 25*C^5 - 325*C^4 + 16276*C^3 - 228488*C^2 - 5940688 sage: type(g[0].rhs()) <type 'sage.symbolic.expression.Expression'> I need to call quo_rem on this expression, so I need it to be a <type 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'> I can copy and paste the output of print(g[0].rhs()) into something new and getsage: P.<C> = PolynomialRing(QQ) sage: p0 = 25*C^5 - 325*C^4 + 16276*C^3 - 228488*C^2 - 5940688 sage: type(p0) <type 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'> and now I can call quo_rem on p0.How can I get the polynomial type out of the symbolic expression without having to resort to copy and paste?
$
0
0
I am doing some things to a symbolic variable C... sage: C = var('C') sage: # ... do a whole bunch of stuff with C as a symbolic variable, sage: # and at some point get sage: g = solve(f, C) sage: print(g) [0 == 25*C^5 - 325*C^4 + 16276*C^3 - 228488*C^2 - 5940688] sage: # implicit solution is polynomial in C ... resulting in a polynomial in C that is typed as a symbolic expression: sage: print g[0].rhs() 25*C^5 - 325*C^4 + 16276*C^3 - 228488*C^2 - 5940688 sage: type(g[0].rhs()) I need to call `quo_rem` on this expression, so I need it to be a I can copy and paste the output of `print(g[0].rhs())` into something new and get sage: P. = PolynomialRing(QQ) sage: p0 = 25*C^5 - 325*C^4 + 16276*C^3 - 228488*C^2 - 5940688 sage: type(p0) and now I can call `quo_rem` on p0. How can I get the polynomial type out of the symbolic expression without having to resort to copy and paste?

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images