ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 16 Nov 2018 05:53:39 -0600Conversion from symbolic expression to polynomial stuckhttps://ask.sagemath.org/question/44302/conversion-from-symbolic-expression-to-polynomial-stuck/I have a very long symbolic expression with six variables:
> (E_mu, E_xi3, ISP, T, V_mu, V_xi3, Z,
> m, mu, n_I, n_P, xi_1, xi_3)
I call the expression AN. I want to convert it in a polynomial of two variables (mu and xi_3). I tried the following command:
AP = AN.polynomial(None,ring=SR['mu,xi_3'])
This works for simple expressions but the command remains stuck for the given expression. My aim is to get the monomials of the polynomial. mu and xi_3 are random variables and I want to compute the expectation of AN (E[AN]). Thus, I could substitute the expectations in the expression.
AN is a numerator, so it is not a fraction. Moreover, I also tried simply_rational but it did not help to convert.
Is there anyway to convert easily ?
EDIT : [I put the symbolic expression in a framabin.](https://framabin.org/p/?2417942055fc9fc9#Oenpb+BI567QXYcVCzjO4zkLRC0byQaNdhi2XW/CUkY=)borostackFri, 16 Nov 2018 05:53:39 -0600https://ask.sagemath.org/question/44302/Convert expression to univariate polynomial over symbolic ring properlyhttps://ask.sagemath.org/question/25556/convert-expression-to-univariate-polynomial-over-symbolic-ring-properly/If I create polynomial like this
R.<x> = SR[]
var('a')
f = a*x^3+1
I get such list of variables
sage: f.variables()
(x,)
But how to convert existing expression to univariate polynomial over symbolic ring?
When I do like this
var('a')
f = a*x^3+1
P.<x> = SR[]
I get following output
sage: P(f).variables()
()
sage: SR['x'](f).variables()
()
How to convert `f` to polynomial in a right way with `x` as variable.
petRUShkaMon, 19 Jan 2015 04:57:47 -0600https://ask.sagemath.org/question/25556/conversion from polynomial to symbolichttps://ask.sagemath.org/question/23818/conversion-from-polynomial-to-symbolic/I want to convert a huge polynomial from ZZ[] into SR but with the following code I get an expression that is not expanded:
sage: R.<x> = ZZ[]
sage: var('n')
n
sage: p=16*x^5 - 20*x^3 + 5*x
sage: p.subs(x=n)
(4*(4*n^2 - 5)*n^2 + 5)*n
sage: SR(p)
(4*(4*x^2 - 5)*x^2 + 5)*x
Is there a way to get the result in expanded form without using `expand()`? Presumably the unnecessary grouping and subsequent expansion can take some time with huge polynomials, so I would like to prevent this from the start.rwsMon, 18 Aug 2014 09:39:16 -0500https://ask.sagemath.org/question/23818/Convert symbolic expressions like sqrt(2) or exp(1) to rational numbershttps://ask.sagemath.org/question/23583/convert-symbolic-expressions-like-sqrt2-or-exp1-to-rational-numbers/I have coefficents of a rational polynomial f(x) in terms of symbolic expressions like `sqrt(2)` and `exp(1)`.
How can I convert these coefficients to rational number approximations of them, so that I can work in a structure like a polynomial ring? jjackFri, 25 Jul 2014 12:35:04 -0500https://ask.sagemath.org/question/23583/