'name 'DiracDelta' is not defined in calculating the hessian
I'm working on a project and trying to calculate the gradient and the hessian using this symbolic library but I'm getting an error NameError: name 'DiracDelta' is not defined How can I avoid this? Can any one suggest a solution? I've tried to import it from simply but did not work
'''
import sympy as sp
from sympy.functions import *
import math as m
from sympy import DiracDelta
from sympy import *
from sympy.abc import r
r0 = sp.Symbol('r0',real=True)
r1 = sp.Symbol('r1',real=True)
r2 = sp.Symbol('r2',real=True)
v1 = sp.Symbol('v1',real=True)
r_var=[r0,r1,r2,v1]
fun_fc_f_symb1=r_var[3]**2-mu*g*(((1+theta**2)*r_var[1]**2+r_var[2]**2-2*r_var[1]*r_var[2])**(3/2))/Abs(theta*((theta**2+4)\
*r_var[1]**2+2*r_var[2]**2-5*r_var[2]*r_var[1]-r_var[1]*r_var[0]))
gradf_symb1 = sp.derive_by_array(fun_fc_f_symb1, r_var)
hessf_symb1 = sp.derive_by_array(gradf_symb1, r_var)
fs1 = sp.lambdify([r_var], fun_fc_f_symb1, 'numpy')
gradf1 = sp.lambdify(r_var, gradf_symb1, 'numpy')
hessf1 = sp.lambdify(r_var, hessf_symb1, 'numpy')
'''
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|