Ask Your Question
0

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

asked 2011-04-03 12:05:37 +0100

Sagud gravatar image

updated 2011-06-16 15:50:43 +0100

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 11:49:14 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-04-03 12:09:51 +0100

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 12:34:21 +0100 )edit

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

Sagud gravatar imageSagud ( 2011-04-03 15:09:33 +0100 )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 15:09:52 +0100 )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 15:10:40 +0100 )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 15:12:26 +0100 )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 12:05:37 +0100

Seen: 12,694 times

Last updated: Apr 06 '11