Ask Your Question

Cannot evaluate symbolic expression to a numerical value

asked 2021-04-16 17:06:47 +0200

Dr. Banana gravatar image

I'm trying to do this: (sqrt(10*y*(10-y))+sqrt(1000)*acos(sqrt(y/10))-15*sqrt(2*6.673*10^(-11)*50000000000)).roots( ring=RealField(100)) Unfortunately I get the error in the title. Also any other way of solving the above equation numerically would be appreciated. I was able to do it in maxima using find_root but was hoping for a better function (one that doesn't require specifying an interval). I couldn't use find_root in sage because it returns the error 'unable to simplify to float approximation' and ofcourse solve doesn't return explicit solutions.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-04-16 19:16:59 +0200

rburing gravatar image

updated 2021-04-16 19:17:37 +0200

From the documentation of roots:

Return roots of self that can be found exactly, possibly with multiplicities. Not all roots are guaranteed to be found.

Warning: This is not a numerical solver


ring - a ring (default None): if not None, convert self to a polynomial over ring and find roots over ring

The latter explains why you get the error in the title: the expression is not a polynomial, so the conversion fails.

The expression itself is only defined as a real number if y is between 0 and 10 (due to the $\sqrt{y(10-y)}$), so:

sage: var('y')
sage: f = sqrt(10*y*(10-y))+sqrt(1000)*acos(sqrt(y/10))-15*sqrt(2*6.673*10^(-11)*50000000000)
sage: f.find_root(0,10)
sage: find_root(f,0,10)

By plotting f you see that it's the only root.

In general there is no magic method to find an interval where a root may live. It is however always a good idea to check the domain of definition first.

edit flag offensive delete link more



A visual exploration of the complex region around 0 suggests that the real root approximated by rburing is the only one "close to 0" :

complex_plot(lambda u:(sqrt(10*u*(10-u))+sqrt(1000)*acos(sqrt(u/10))-15*sqrt(2*6.673*10^(-11)*50000000000)),(-10,10),(-10,10))

image description

A 3D plot of the modulus closer to the real root suggests that this root is indeed unique :

image description

Further analytical work (finding majorants/minorants of moduli) may prove the absence of roots outside this region and the uniqueness of the real root.

This is left to the reader as an exercise ;-)...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-04-17 13:10:47 +0200 )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

1 follower


Asked: 2021-04-16 17:06:47 +0200

Seen: 49 times

Last updated: Apr 16