fazan
fazan

Reputation: 195

How to integrate a function of r that contains the first derivative of r in python?

I have to integrate a function over a variable that contains the derivative of this variable.

I'm using jupyter and here is my code:

from sympy import *
m, p, g, a, t=symbols('m, p, g, a, t')
r=Function('r')
integrate((r*(p**2/(m**2*r**4)-2*a*g)-r(t).diff(t)**2*4*a**2*r)/(1+4*a**2*r**2),r)

r(t).diff(t) is my clumsy way of attempting to write \dot{r}.

I get the following error :

TypeError: unsupported operand type(s) for ** or pow(): 'UndefinedFunction' and 'int'

Any help would be very appreciated.

Upvotes: 1

Views: 118

Answers (1)

ch271828n
ch271828n

Reputation: 17607

You need to have r(t) instead of r. Try the following: integrate((r(t)*(p**2/(m**2*r(t)**4)-2*a*g)-r(t).diff(t)**2*4*a**2*r(t))/(1+4*a**2*r(t)**2), r(t))

Upvotes: 1

Related Questions