| 1 | initial version |
You have two different x in your code - one is a symbolic variable defined by x = var('x') and another is a polynomial variable (generator of R). For example, in (8.5*pi^4 + 0.166*pi^2*x^2)*x, the x inside the parentheses is symbolic, while the one outside is polynomial. When you convert a symbolic expression (even if it involves symbolic x) into R, Sage interprets it as a scalar and turns it into a polynomial of degree 0. Here is a simple example:
sage: x = var('x')
sage: R = PolynomialRing(SR, x)
sage: R(x+pi*x^2)
pi*x^2 + x
sage: _.dict()
{0: pi*x^2 + x}
If your goal is to recognize x inside a symbolic expression and turn it into a polynomial variable, then you can do via converting the expression into a string first:
sage: R(str(x+pi*x^2))
pi*x^2 + x
sage: _.dict()
{1: 1, 2: pi}
| 2 | No.2 Revision |
You have two different x in your code - one is a symbolic variable defined by x = var('x') and another is a polynomial variable (generator of R). For example, in (8.5*pi^4 + 0.166*pi^2*x^2)*x, the x inside the parentheses is symbolic, while the one outside is polynomial. When you convert a symbolic expression (even if it involves symbolic x) into R, Sage interprets it as a scalar and turns it into a polynomial of degree 0. Here is a simple example:
sage: x = var('x')
sage: R = PolynomialRing(SR, x)
sage: R(x+pi*x^2)
pi*x^2 + x
sage: _.dict()
{0: pi*x^2 + x}
If your goal is to recognize x inside a symbolic expression and turn it into a polynomial variable, then you can do so via converting the expression into a string first:
sage: R(str(x+pi*x^2))
pi*x^2 + x
sage: _.dict()
{1: 1, 2: pi}
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.