# Numerical solution to an equation that doesn't have an analytic form

Suppose I have an equation $$d=\int_A^B \dfrac{dr}{\sqrt{1-\dfrac{2M}{r}}}\\ =B\sqrt{1-\dfrac{2M}{B}}-A\sqrt{1-\dfrac{2M}{A}}+M\ln\left( B\sqrt{1-\dfrac{2M}{B}} +B-M\right)-M\ln\left( A\sqrt{1-\dfrac{2M}{A}} +A-M\right),$$ where $$B>A>2M>0$$.

I want to solve this equation for $$B$$ analytically. So far, I have tried

Solve[0.1==B*Sqrt[1-2/B]-3*Sqrt[1-2/3]+Log[B*Sqrt[1-2/B]+B-1]-Log[3*Sqrt[1-2/3]+3-1],B]


where $$d=0.1, A=3, M=1$$. However, Mathematica won't give a number.

Is there another way to solve this? Thanks.

• Use FindRoot instead of Solve. Jun 4, 2020 at 20:07

FindRoot works, but fun function.

inner[M_, xAB_] := Sqrt[1 - (2 M/xAB)];
expr[M_, A_, B_] :=
B*inner[M, B] - A*inner[M, A] + M*Log[B*inner[M, B] + B - M] -
M*Log[A*inner[M, A] + A - M]
FindRoot[expr[M, A, B] ==
d, {{M, 1.}, {A, 3.}, {B, 2, 2, 4}, {d, 0.1}}]

mine = FindRoot[expr[1., 3., B] == 0.1, {B, 2, 2, 4}]
(* Out: {B->3.05828} *)

original=FindRoot[0.1==B*Sqrt[1-2/B]-3*Sqrt[1-2/3]+Log[B*Sqrt[1-2/B]+B-1]-Log[3*Sqrt[1-2/3]+3-1],{B,2,2,4}]
(* Out: {B->3.05828} *)

In:= mine==original
Out= True


PS. Tried Plot[expr[1, 3, B] == 0.1, {B, 0, 10}] to see graph of B. Whew!