Re: Numerical representation

2011-03-08 Thread Jon Herman
Thanks all for the input, the remark about printing intermediate steps was a very good one (and so obvious I can't believe it took me this long to get there...) The error was in my loop where I multiply by the "b" or "beta" coefficients. The range for this loop (marked by j) is set up properly in

Re: Numerical representation

2011-03-07 Thread Robert Kern
On 3/7/11 2:52 PM, Jon Herman wrote: It really is exactly the same process, but sure. Below is my Matlab translation of the python code I posted earlier, it functions at the increased accuracy I've shown above. k(:,1)=feval(deq, ti, x, mu); for n = 2:1:13 nn=n-1;

Re: Numerical representation

2011-03-07 Thread Katie T
The main choices for arbitrary point precision seem to be mpmath (which is pure python) and GMP (C++ but with python wrapper; GMP is heavily used in academia) Links: http://code.google.com/p/mpmath/ http://gmpy.sourceforge.net/ Katie -- CoderStack http://www.coderstack.co.uk The Software Devel

Re: Numerical representation

2011-03-07 Thread Jon Herman
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 wrote: > On 3/7/2011 1:59 PM, Jon Herman wrote: > >> And for the sake of completeness, th

Re: Numerical representation

2011-03-07 Thread Terry Reedy
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]

Re: Numerical representation

2011-03-07 Thread Jon Herman
It really is exactly the same process, but sure. Below is my Matlab translation of the python code I posted earlier, it functions at the increased accuracy I've shown above. k(:,1)=feval(deq, ti, x, mu); for n = 2:1:13 nn=n-1; Xtemp1 = 0.0; for j = 1:1:

Re: Numerical representation

2011-03-07 Thread Chris Rebert
>>> On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman wrote: I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8) integrator in Python, which requires an extreme numerical precision for my particular application. Unfortunately, I can not seem to attain it. The

Re: Numerical representation

2011-03-07 Thread Jon Herman
And for the sake of additional completeness (I'm sorry I didn't think of all this in one go): my derivative function in Python produces results that agree with MATLAB to order e-16 (machine precision), so the error is definitely building up in my integrator. On Mon, Mar 7, 2011 at 11:59 AM, Jon

Re: Numerical representation

2011-03-07 Thread Jon Herman
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) 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-

Numerical representation

2011-03-07 Thread Jon Herman
Sorry Robert, I'd missed your post when I just made my last one. The output I am getting in Python looks as follows: array([ 9.91565050e-01, 1.55680112e-05, -1.53258602e-05, -5.75847623e-05, -9.64290960e-03, -8.26333458e-08]) This is the final state vector, consisting of 6 states (p

Re: Numerical representation

2011-03-07 Thread Jon Herman
I'm starting to run out of ideas of what to do...I've imported the true division (I'm using Python 2.7) to make sure I wasn't accidentally using any integers but the results remain identical, so it's not a division problem. I've copied the loop I'm running below, is there any mathematical operation

Re: Numerical representation

2011-03-04 Thread Jon Herman
Actually, I import numpy in my code for array creation...in the documentation I did not manage to find anything that would solve this precision problem I mentioned however. If you're familiar with it, would you happen to know what capability of numpy might solve my problem? On Fri, Mar 4, 2011 a

Re: Numerical representation

2011-03-04 Thread Robert Kern
On 3/4/11 4:32 PM, Jon Herman wrote: Hello all, I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8) integrator in Python, which requires an extreme numerical precision for my particular application. Unfortunately, I can not seem to attain it. The interesting part is if I take

Re: Numerical representation

2011-03-04 Thread Robert Kern
On 3/4/11 5:49 PM, Santoso Wijaya wrote: Have you taken a look at numpy? [1] It was written for exactly this kind of usage. ~/santa [1] http://numpy.scipy.org/ While numpy does provide arrays much like MATLAB's, it won't help at all for the precision issues the OP is encountering (and hones

Re: Numerical representation

2011-03-04 Thread Santoso Wijaya
Have you taken a look at numpy? [1] It was written for exactly this kind of usage. ~/santa [1] http://numpy.scipy.org/ On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman wrote: > Hello all, > > I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8) > integrator in Python, which requi

Numerical representation

2011-03-04 Thread Jon Herman
Hello all, I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8) integrator in Python, which requires an extreme numerical precision for my particular application. Unfortunately, I can not seem to attain it. The interesting part is if I take my exact code and translate it to Matl