How to get the second derivative using parametric differentiation?

If I have two parametric equations, for example. x = 2*tand y = t**2 - 3, I can distinguish them as follows:

>>> x, y, t = symbols('x, y, t')
>>> x = 2*t
>>> y = t**2 - 3
>>> diff(y)/diff(x)
t

To get the second derivative:

>>> (diff(x,t,1)*diff(y,t,2) - diff(y,t,1)*diff(x,t,2)) / diff(x,t,1)**3
1/2

Is there a shortcut in sympy that I can use to calculate this?

Perhaps wrapping this in a function is what I should do?

>>> def second_derivative(x,y):  
>>>   return (diff(x,t,1)*diff(y,t,2) - diff(y,t,1)*diff(x,t,2)) / diff(x,t,1)**3

Then it becomes:

>>> second_derivative(2*t, t**2 - 3)
1/2
+4
source share
1 answer

I went with creating a custom function:

>>> def second_derivative(x,y):  
>>>   return (diff(x,t,1)*diff(y,t,2) - diff(y,t,1)*diff(x,t,2)) / diff(x,t,1)**3

What is called like this:

>>> second_derivative(2*t, t**2 - 3)
1/2
-1
source

Source: https://habr.com/ru/post/1696163/


All Articles