# converting symbolic solve output to numbers [was "numerical value"]

Let's say:

$$z = [x = -1/3 * sqrt(3), x = 1/3 * sqrt(3)]$$

How can I make numerical value of that?

numerical_approx(z)
N(z)
n(z)
z.n()
RR(z)

DON'T WORK!

edit retag close merge delete

Thanks for your questions. It might be helpful to not use all capital letters for your titles, however; 'netiquette' usually reserves all-caps for extreme emphasis.

Sort by » oldest newest most voted z = solve(gen_legendre_P(2, 0, x) == 0, x)
for i in range(len(z)):
print z[i].rhs().n()

more

You could also use "for eq in z: print eq.rhs().n()" if you're not going to need the index for anything. And if you do need the index, I find it somewhat more Pythonic to use "for i, eq in enumerate(z):".

but it's problem when we choose 9 or even worst when we choose 10. Look

y = solve(gen_legendre_P(10, 0, x) == 0, x); print "Nultocke: [", for i in range(len(y)): print y[i].rhs().n(digits=2);

when we use 10 ERROR : Traceback (click to the left of this block for traceback) ... TypeError: cannot evaluate symbolic expression numerically

and when we use 9 we get numbers like: -0.96 - 7.5e-6*I lol.. How can I repair that?