From: Bruce S. <bas...@un...> - 2002-11-24 23:55:32
|
The error message is easy to explain: the statement "derivative(t,x,xdot,xddot)" is your first mention of xddot, so Python complains. I gather that what you intend is that t, x, and xdot are inputs and xddot is an output, in which case the appropriate structure looks like this, using "return" to get back the result of the operation: def derivative(t, x, xp): xmu = 1.407645794e16 r = mag(x) r3 = r**3 return -xmu*x/r3 t = 2451545.0 x=vector(1.,1.,1.) xdot=vector(1.,1.,1.) xddot = derivative(t, x, xdot) print xddot |