Python: sympy, I cannot solve the hyperbolic sine equation

Question:

I have one problem that the sympy module is not solve the following equation.

import sympy as sy
from sympy import Symbol
from sympy import *

deld = Symbol('deld')
sinh = sy.sinh
a = (-0.00026478*deld - 1.75012e-9*sinh(0.62831 - 62831.85307*deld) + 1.750123e-9*sinh(62831.85307*deld - 0.62831) + 2.64786e-9)
b = (0.00026478*deld + 1.75012e-9*sinh(0.62831 - 62831.85307*deld) - 1.750123e-9*sinh(62831.85307*deld - 0.62831) - 2.34686e-9)
c= -1

d = sy.solve((a/b)+c, deld)


print (d)

I want to get the numerical value of ‘deld’. But python does not solve this equation with memory error. I already tired to solve this problem with 128GB RAM, But it was failed.

Please any help. Thank you.

Asked By: 전현우

||

Answers:

If you want a numerical solution then in SymPy it is better to use nsolve. The numerical problem that you have posed is extremely ill conditioned so many numerical solvers will struggle. It is also not something that can easily be solved symbolically (which is what you are asking for by calling solve rather than nsolve).

Plotting the function reveals that there is a root in the range [0.6e-5, 0.7e-5]. We can ask nsolve to find that root:

In [62]: nsolve((a/b+c), deld, [0.6e-5, 0.7e-5])
Out[62]: 6.50904815581165e-6
Answered By: Oscar Benjamin
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.