Ultimately, my goal is to numerically differentiate the expression 'u' (see code) with respect to t, with respect to X and three times with respect to X.
First idea was to just write the expression down numerically, providing arrays (linspaces) for X and t. This resulted in the error "'Add' object has no attribute 'cosh'". The only thing I know about this error is that it indicates I should use sympy-functions instead of numpy-functions or the other way around. But, using a symbpolic expression (sympy-functions) and then trying to lambdify gave the same error, this time with no attribute 'sinh'.
I don't know where I'm going wrong with this. The symbolic expression is defined just fine, the error only occurs when I add the first lambdify into the code.
import numpy as np
import sympy as sp
c_1=1.35
c_2=0.7
X = sp.Symbol('X')
t = sp.Symbol('t')
u = sp.Function('u')(X,t)
u = 2*(c_1-c_2)*(c_1*(sp.cosh(sp.sqrt(c_2)*(X-c_2*t)/2))**2 + c_2*(sp.sinh(sp.sqrt(c_1)*(-X-c_1*t)/2))**2)/((sp.sqrt(c_1)-sp.sqrt(c_2))*sp.cosh((sp.sqrt(c_1)*(-X-c_1*t) + sp.sqrt(c_2)*(X-c_2*t))/2)+ (sp.sqrt(c_1)+sp.sqrt(c_2))*sp.cosh((sp.sqrt(c_1)*(-X-c_1*t)-sp.sqrt(c_2)*(X-c_2*t))/2))**2
Y= np.linspace(-20,20,100)
T = np.linspace(-35,35,300)
U = sp.lambdify(X,u,"numpy")
U2 = sp.lambdify(t,U(Y),"numpy")(T)
Does anybody know how to fix my code to prevent this error, or know another method to numerically differentiate u as I described above?