You can try this:

sage: R.<X,Y> = SR[]
sage: pi*X-sqrt(2)*Y^2
(-sqrt(2))*Y^2 + pi*X

but Idon't know what is/is not possible with the result...

sage: (Y^2-X^2).factor()
---------------------------------------------------------------------------
NotImplementedError 

John Cremona

On Wednesday, May 16, 2012 1:42:46 PM UTC+1, Marcin Kostur wrote:
>
> Hi,
>
> I was trying to convert expressions to polynomials and back
>
> This works:
>
> R.<X,Y> = PolynomialRing(QQ,2,'XY')
> print R( (x+y^2).subs({x:X,y:Y}) )
>
>  and I can e.g. use methods as monomials() etc.
>
> However I would like to use SR - as the coeffs might have some symbols:
>
> R.<X,Y> = PolynomialRing(SR,2,'XY')
> print R( X+Y^2 ) 
> print R( (x+y^2).subs({x:X,y:Y}) )
>
> The last line throws:
>
> TypeError: no canonical coercion from Multivariate Polynomial Ring in X,
> Y over Symbolic Ring to Symbolic Ring
>
>
> My question is: how to make an multivariate polynomial from symbolic 
> expression ?
>
> the best
>
> Marcin
>
>
>
On Wednesday, May 16, 2012 1:42:46 PM UTC+1, Marcin Kostur wrote:
>
> Hi,
>
> I was trying to convert expressions to polynomials and back
>
> This works:
>
> R.<X,Y> = PolynomialRing(QQ,2,'XY')
> print R( (x+y^2).subs({x:X,y:Y}) )
>
>  and I can e.g. use methods as monomials() etc.
>
> However I would like to use SR - as the coeffs might have some symbols:
>
> R.<X,Y> = PolynomialRing(SR,2,'XY')
> print R( X+Y^2 ) 
> print R( (x+y^2).subs({x:X,y:Y}) )
>
> The last line throws:
>
> TypeError: no canonical coercion from Multivariate Polynomial Ring in X,
> Y over Symbolic Ring to Symbolic Ring
>
>
> My question is: how to make an multivariate polynomial from symbolic 
> expression ?
>
> the best
>
> Marcin
>
>
>

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to