I'm trying to perform implicit differentiation to the function Lrdot
which is -2*rdot/(1 - 1/r(t))
, wrt an affine parameter s
, where rdot
is dr/ds
. The error below pops up and i'm not sure how to debug.
from sympy import *
from sympy.physics.mechanics import *
r = dynamicsymbols('r')
rdot = dynamicsymbols('r', 1)
t = dynamicsymbols('t')
tdot = dynamicsymbols('t', 1)
phi = dynamicsymbols('phi')
phidot = dynamicsymbols('phi', 1)
s = symbols('s')
def F(x):
return 1-(1/x)
# Largangian
def L(a,b,c, adot, bdot, cdot, photon = true): #r,t,phi
return F(a)*(bdot)**2 - adot**2/F(a) - (a*cdot)**2
L = L(r, t, phi, rdot, tdot, phidot, photon = true)
Lr = diff(L, r)
Lrdot = diff(L, rdot)
diffLrdot = idiff(-2*rdot/(1-1/r), r, s)
print(diffLrdot)
Traceback (most recent call last):
File "/Users/myname/PycharmProjects/untitled/.idea/14.1.py", line 40, in <module>
diffLrdot = idiff(-2*rdot/(1-1/r), r, s)
File "/Users/myname/PycharmProjects/untitled/venv/lib/python3.6/site-packages/sympy/geometry/util.py", line 578, in idiff
f = {s: Function(s.name)(x) for s in eq.free_symbols
File "/Users/myname/PycharmProjects/untitled/venv/lib/python3.6/site-packages/sympy/geometry/util.py", line 579, in <dictcomp>
if s != x and s in dep}
NameError: free variable 'dep' referenced before assignment in enclosing scope