I am trying to solve a function which I got which is like
v2 = (1 - d) * sp.diff(h1, x) + (d / ep) * sp.diff(w, y) + d * sp.diff(w, x)
I want to convert symbolic expressions to numerical functions which are x, y and sine and cosine terms using lambdify function from the sympy library.
#I am getting error:
raise TypeError("Argument must be either a string, dict or module but it is: %s" % m)
TypeError: Argument must be either a string, dict or module but it is: 2.38095*s*(y + asin(1 - sin(1)/(x + 1)))**2*sin(1)*cos(asin(1 - sin(1)/(x + 1)) - 1)/(sqrt(1 - (1 - sin(1)/(x + 1))**2)*(x + 1)) + 238.095*(x + 1)*(2*y + 2*asin(1 - sin(1)/(x + 1)))*(s*sin(asin(1 - sin(1)/(x + 1)) - 1) - cos(s + 1)) + 2.38095*(y + asin(1 - sin(1)/(x + 1)))**2*(s*sin(asin(1 - sin(1)/(x + 1)) - 1) - cos(s + 1)) + 4.7619*(y + asin(1 - sin(1)/(x + 1)))*(s*sin(asin(1 - sin(1)/(x + 1)) - 1) - cos(s + 1))*sin(1)/(sqrt(1 - (1 - sin(1)/(x + 1))**2)*(x + 1)) - 0.9*sin(1)/(sqrt(1 - (1 - sin(1)/(x + 1))**2)*(x + 1)**2)
for the following command:
x_vals = np.linspace(0, 10, 100)
x_val = 0
y_val = 0
solution = solve_ivp(v1_func, (x_vals[0], x_vals[-1]), [y_val], t_eval=x_vals)
y_vals = solution.y[0]
and for the command:
v1_func = sp.lambdify((x, y), v1.subs(sp.sin, math.sin).subs(sp.cos, math.cos))
Error:
File <lambdifygenerated-34>:2 in _lambdifygenerated
return 2.38095*s*(y + arcsin(1 - sin(1)/(x + 1)))**2*sin(1)*cos(arcsin(1 - sin(1)/(x + 1)) - 1)/(sqrt(1 - (1 - sin(1)/(x + 1))**2)*(x + 1)) + 238.095*(x + 1)*(2*y + 2*arcsin(1 - sin(1)/(x + 1)))*(s*sin(arcsin(1 - sin(1)/(x + 1)) - 1) - cos(s + 1)) + 2.38095*(y + arcsin(1 - sin(1)/(x + 1)))**2*(s*sin(arcsin(1 - sin(1)/(x + 1)) - 1) - cos(s + 1)) - 0.9*arcsin(1 - sin(1)/(x + 1)) + 4.7619*(y + arcsin(1 - sin(1)/(x + 1)))*(s*sin(arcsin(1 - sin(1)/(x + 1)) - 1) - cos(s + 1))*sin(1)/(sqrt(1 - (1 - sin(1)/(x + 1))**2)*(x + 1))
TypeError: loop of ufunc does not support argument 0 of type Add which has no callable cos method.
I think I am getting error due to sine and cosine terms please help me out. I want that I can solve the above equation as an ODE for the given values of x and y in some range and plot it. The function v2 is a Lyapunov function and finding its derivative along the system to plot its region of attraction.