Reputation: 111
How to solve this equation for positive E numerically for a given M value? I tried the FindRoot method in Mathematica, but it never converged to a correct solution. Here, M is any positive real number. My goal is to plot the curve M vs E.
Sqrt[E]*Cos[Sqrt[E]]=-M*Sin[Sqrt[E]]
Upvotes: 2
Views: 618
Reputation: 26531
Here is a method with Mathematica that seems to work:
In[37]:= FindRoot[x + 1/10 Tan[x], {x, # + Abs[#]*10^-14, (# + Pi) (1. - 10^-14)}, Method -> "Brent"] & /@ Range[-Pi/2, 50 Pi, Pi]
Out[37]= {{x -> 0.}, {x -> 1.63199}, {x -> 4.73351}, {x -> 7.86669},
{x -> 11.0047}, {x -> 14.1442}, {x -> 17.2845}, {x -> 20.4252},
{x -> 23.5662}, {x -> 26.7073}, {x -> 29.8485}, {x -> 32.9898},
{x -> 36.1311}, {x -> 39.2725}, {x -> 42.4139}, {x -> 45.5553},
{x -> 48.6967}, {x -> 51.8382}, {x -> 54.9797}, {x -> 58.1212},
{x -> 61.2627}, {x -> 64.4042}, {x -> 67.5457}, {x -> 70.6872},
{x -> 73.8288}, {x -> 76.9703}, {x -> 80.1119}, {x -> 83.2534},
{x -> 86.395}, {x -> 89.5365}, {x -> 92.6781}, {x -> 95.8196},
{x -> 98.9612}, {x -> 102.103}, {x -> 105.244}, {x -> 108.386},
{x -> 111.527}, {x -> 114.669}, {x -> 117.811}, {x -> 120.952},
{x -> 124.094}, {x -> 127.235}, {x -> 130.377}, {x -> 133.518},
{x -> 136.66}, {x -> 139.802}, {x -> 142.943}, {x -> 146.085},
{x -> 149.226}, {x -> 152.368}, {x -> 155.509}}
Essentially, by replacing Sqrt[E] = x
, you only need to solve for x + M Tan[x] == 0
and this for positive M
and x
. You know that Tan[x]
changes sign every multiple of Pi/2 + kPi
. So you know that there is always a root every ]Pi/2 + k Pi, Pi/2 + (k+1) Pi[
. We use Brent's method here, as this ensures to always find a root between a positive and negative value and due to the nature of Tan[x]
we know that values close to the borders of the respective interval have opposite signs.
We also use FindRoot
instead of NSolve
as NSolve
is designed for polynomials.
Upvotes: 0