I am trying to do some calculations in python and now need to find the derivative of the a function, that I have derived prior and is now called derivative(x(t), t):
t = sp.symbols('t')
x = sp.symbols('x')
B = sp.symbols('B')
C = sp.symbols('C')
x = sp.Function('x')(t)
Lx = B * sp.diff(x,t) * C
Because the derivative of x is called Derivative(x(t),t) by SymPy,the function Lx is equal to B*Derivative(x(t),t)*C and the derivative of our function must be called the following:
ELx = sp.diff(Lx,Derivative(x(t),t))
But I allways get an error message:
NameError: name 'Derivative' is not defined what should I do.
I mean I can define the Derived function with antoher varibale, but the logic and cleaner way looks like this.
You are calling Derivative() without that being defined. According to the documentation of sympy the correct way to calculate a derivative is
sp.diff().The following code should do what you're trying to achieve:
References: https://docs.sympy.org/latest/tutorials/intro-tutorial/calculus.html