Ask Your Question
0

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

asked 2011-04-03 05:05:37 -0600

Sagud gravatar image

updated 2011-06-16 08:50:43 -0600

Kelvin Li gravatar image

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 flag offensive close merge delete

Comments

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.

kcrisman gravatar imagekcrisman ( 2011-04-04 04:49:14 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2011-04-03 05:09:51 -0600

Shashank gravatar image
z = solve(gen_legendre_P(2, 0, x) == 0, x)
for i in range(len(z)):
    print z[i].rhs().n()
edit flag offensive delete link more

Comments

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):".

DSM gravatar imageDSM ( 2011-04-03 05:34:21 -0600 )edit

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

Sagud gravatar imageSagud ( 2011-04-03 08:09:33 -0600 )edit

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);

Sagud gravatar imageSagud ( 2011-04-03 08:09:52 -0600 )edit

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

Sagud gravatar imageSagud ( 2011-04-03 08:10:40 -0600 )edit

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

Sagud gravatar imageSagud ( 2011-04-03 08:12:26 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-04-03 05:05:37 -0600

Seen: 11,583 times

Last updated: Apr 06 '11