# Solving equation analytically

I was going through an article. I have the following functions,

f[r_] := 1 - (2*M*r^2)/(r^3 + g^3) + (8/3)*Pi*P*r^2
v[r_] := f[r]/r^2


Now I want to solve v'[r]==0 for r. Clearly This cannot be solved analytically. But there they solved it somehow and got the following result.

r = M + M^2/(M^3 - g^3 + Sqrt[g^6 - 2*g^3*M^3])^(1/3) + (M^3 - g^3 + Sqrt[g^6 - 2*g^3*M^3])^(1/3)


Can anyone tell me how can it be solved in mathematica or what method did they use? Thanks in advance.

• in V 14 I get lots of solutions all Root objects. Can you show the complete code you used? But to answer you, basically Mathematica evaluated v'[r] first, then solved the resulting equation for $r$ . That is all. Commented May 5 at 7:34
• You code for r=... is incomplete ? Commented May 5 at 8:52
• @MariuszIwaniuk edited Commented May 6 at 6:39
• Yours solution for r is only approximation is not equal .You can check it yourself. $r\approx M+\frac{M^2}{\sqrt[3]{M^3-g^3+\sqrt{g^6-2 g^3 M^3}}}+\sqrt[3]{M^3-g^3+\sqrt{g^6-2 g^3 M^3}}$. Commented May 6 at 7:27

f[r_] = 1 - (2*M*r^2)/(r^3 + g^3) + (8/3)*Pi*P*r^2;
v[r_] = f[r]/r^2;


Let's substitute $$\rho=r/M$$ and $$\gamma=g/M$$ to simplify the equation:

FullSimplify[v'[r] /. {r -> ρ*M, g -> γ*M}]


$$-\frac{2 \left(\gamma ^6+2 \gamma ^3 \rho ^3+(\rho -3) \rho ^5\right)}{M^3 \rho ^3 \left(\gamma ^3+\rho ^3\right)^2}$$

You are looking for the zeros of this derivative: $$\gamma^6+2\gamma^3 \rho^3+(\rho-3) \rho^5=0$$, which depends only of $$\gamma$$:

SolveValues[γ^6 + 2 γ^3 ρ^3 + (-3 + ρ) ρ^5 == 0, ρ]
(*    {Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 1],
Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 2],
Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 3],
Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 4],
Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 5],
Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 6]}    *)


Let's make a plot to find out where these zeros are:

DensityPlot[γ^6 + 2 γ^3 ρ^3 + (-3 + ρ) ρ^5, {γ, 0, 10}, {ρ, 0, 10},
MeshFunctions -> {#3 &}, Mesh -> {{0}}, MeshStyle -> White,
PlotPoints -> 100]


So only two branches of the solutions are real-valued and usable:

Plot[{Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 1],
Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 2]},
{γ, 0, 1.4}, PlotLegends -> {1, 2}]


Now you can pick one branch and try to find approximations:

Series[Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 1], {γ, 0, 3}]
(*    γ^(6/5)/3^(1/5) + 2 γ^(9/5)/(5*3^(4/5)) + 1/25*3^(3/5)*γ^(12/5) + 2*γ^3/45 + O[γ]^(16/5)    *)


So on the blue brach, for small $$\gamma$$ we have $$\rho\approx \gamma^{6/5}/3^{1/5}$$, which means $$r \approx g^{6/5} \cdot (3M)^{-1/5}$$.

For small $$\gamma$$, the yellow branch is $$\rho\approx 3-\frac29\gamma^3$$. Your approximate expression also refers to this branch:

$$\rho \approx 1 + \left(1-\gamma^3+\gamma^{3/2}\sqrt{\gamma^3-2}+1\right)^{\frac13}+\left(1-\gamma ^3+\gamma^{3/2}\sqrt{\gamma^3-2}\right)^{-\frac13}$$

a[γ_] = 1 + (1-γ^3+γ^(3/2)Sqrt[γ^3-2])^(1/3) + (1-γ^3+γ^(3/2)Sqrt[γ^3-2])^(-1/3);
Plot[{Root[γ^6 + 2 γ^3 #1^3 - 3 #1^5 + #1^6 &, 2], a[γ]}, {γ, 0, 1}]


Check the degree of approximation:

γ^6 + 2 γ^3 ρ^3 + (-3 + ρ) ρ^5 /. ρ -> a[γ] // FullSimplify
(*    γ^6    *)


Indeed it looks like this approximation was found by simply neglecting the term $$\gamma^6$$.

To get a better asymptotic expression for small $$\gamma$$ we can solve directly,

AsymptoticSolve[γ^6 + 2 γ^3 ρ^3 + (-3 + ρ) ρ^5 == 0, ρ -> 3, {γ, 0, 30}]

(*    {{ρ -> 3 - 2 γ^3/9 - γ^6/27 - 70 γ^9/6561 - 665 γ^12/177147
- 260 γ^15/177147 - 79112 γ^18/129140163
- 310726 γ^21/1162261467 - 1260545 γ^24/10460353203
- 141502900 γ^27/2541865828329 - 599764165 γ^30/22876792454961}}    *)

• This was great help. Thanks a lot. Commented May 6 at 7:57

An exact solution, better than the approximation you give, is

r[M_, g_] = M (1/2 + 5/2 HypergeometricPFQ[{-1/3, -1/6, 1/6, 1/3, 1/2},
{-1/5, 1/5, 2/5, 3/5},
(1728 g^3)/(3125 M^3)]);


It satisfies the same limit for small $$g$$,

Series[r[M,g], {g, 0, 3}]
(*    3 M - (2 g^3)/(9 M^2) + O[g]^4    *)


and it satisfies the equation:

g^6 + 2 g^3 r[M,g]^3 + r[M,g]^5 (-3 M + r[M,g]) // FullSimplify
(*    should give 0 but fails to simplify properly    *)

Plot[r[1, g], {g, 0, (3125/1728)^(1/3)}]


For me

 res= (  Collect[(D[v[r], r] //
Together // Numerator // FullSimplify), r]

-2 g^6 - 4 g^3 r^3 + 6 M r^5 - 2 r^6


   res/.
{r -> M +
M^2/(M^3 - g^3 +
Sqrt[g^6 - 2*g^3*M^3])^(1/3) +
(M^3 - g^3 + Sqrt[g^6 - 2*g^3*M^3])^(1/3)} // FullSimplify

Out[]= -2 g^6


By

 Reduce[0 == -2 g^6 - 4 g^3 r^3 + 6 M r^5 - 2 r^6] /.
{a_ == b_ :>   a^3 == b^3} // Union


$$g^3= \pm \sqrt{3 M} \ r^{5/2}-r^3$$

that not really is looking like a solvable equation for $$g\ne 0$$

• I think they made some approximation. I don't think this is an exact solution. Commented May 6 at 6:42
• Yes, the approximation sets $g^6\approx0$, which is pretty accurate for small $g$. Commented May 6 at 11:37

If you want only approximation use: AsymptoticSolve, because exact analytical solution can't be found.

f[r_] := 1 - (2*M*r^2)/(r^3 + g^3) + (8/3)*Pi*P*r^2
v[r_] := f[r]/r^2

NSolve[v'[r] == 0, r, Reals, WorkingPrecision -> 20] /. M -> 10^5 /. g -> 10
{{r -> 1.2733095874827712477}, {r -> 299999.9999999777778}}

Simplify[AsymptoticSolve[v'[r] == 0, r, g -> 0, Reals], Assumptions -> M > 0]
{{r -> g^(6/5)/(3^(1/5) M^(1/5))}, {r -> -((2 g^3)/(9 M^2)) + 3 M}}

% /. M -> 10^5 /. g -> 10 // N
{{r -> 1.27226}, {r -> 300000.}}