I am trying to solve the equation: log(1+x)/x - 1/(1+x) == 2/3 * q * x**2
for x
with q = 4e-4
I tried
import numpy as np
import scipy.optimize as so
q = 4e-4
eqn = lambda x: np.log(1+x) / x - 1 / (1+x) - 2/3 * q * x**2
sol = so.fsolve(eqn, 1)[0]
print(sol)
and
q = 4e-4
eqn = lambda x: np.log(1+x) / x - 1 / (1+x) - 2/3 * q * x**2
sol = so.root_scalar(eqn, bracket=(1e-6, 1e20)).root
print(sol)
but get absurd answers.
I tried plotting the equation as follows:
I am expecting the answer to be x ~ 20
. How do I get this?