In hydrology, the relationship between evaporative index (EI) and dryness index (DI) is described with the following equation.
EI = (DI * tanh(1/DI) *(1+ sinh(DI) - scosh(DI))^1/2
However, we have trouble solving this in python. Is there an easy way to do this we're not aware about?
We get the error "Could not find root within given tolerance. (4.25389829408258985009 > 2.16840434497100886801e-19)"
we cant find any guesses which fits
import sympy as sp
EIlist = []
DIlist = []
for i in range(6):
EI = mean_ET[i]/mean_perc[i]
EIlist.append(EI)
print(EI)
DI = sp.symbols('DI')
eq1 =sp.Eq(EI, (DI * sp.tanh(1/DI) *(1+ sp.sinh(DI) - sp.cosh(DI)))**1/2)
solutions = sp.nsolve(eq1, DI)
We are hoping to get a numerical solution.
You can solve it by inversion using the standard Newton-Raphson method: your curve of EI against DI appears to be monotonically increasing (as the graph below shows).
Given the appearance of the square root it is easiest to get DI from EI^2.
Output: