Numerical representation

Jon Herman jfc.herman at gmail.com
Mon Mar 7 16:54:06 EST 2011


Thanks Terry! Of course, speed is not my main concern at this point and I'm
more worried about precision...would you have some input on this discussion?
:)

Jon



On Mon, Mar 7, 2011 at 2:35 PM, Terry Reedy <tjreedy at udel.edu> wrote:

> On 3/7/2011 1:59 PM, Jon Herman wrote:
>
>> And for the sake of completeness, the derivative function I am calling
>> from my integrator (this is the 3 body problem in astrodynamics):
>>
>> def F(mu, X, ti):
>>
>>     r1= pow((pow(X[0]+mu,2)+pow(X[1],2)+pow(X[2],2)),0.5)
>>
>
>    x0 = X[0]; x1 = X[1]; x2 = X[2]
>    r1 = sqrt((x0+mu)**2) + x1*x1 + x2*x2)
>    etc...
> might be faster. Certainly, repeated lookups of pow is slow
> and above is easier to read.
>
>      r2= pow((pow(X[0]+mu-1,2)+pow(X[1],2)+pow(X[2],2)),0.5)
>>
>>     Ax= X[0]+2*X[4]-(1-mu)*(X[0]+mu)/r1**3-mu*(X[0]-(1-mu))/r2**3
>>     Ay= X[1]-2*X[3]-(1-mu)*X[1]/r1**3-mu*X[1]/r2**3
>>     Az= -(1-mu)*X[2]/r1**3-mu*X[2]/r2**3
>>
>>     XDelta=array([X[3], X[4], X[5], Ax, Ay, Az])
>>
>>     return XDelta
>> \
>>
>
>
> --
> Terry Jan Reedy
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110307/9d622b74/attachment.html>


More information about the Python-list mailing list