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:nn Xtemp1 = Xtemp1 + beta(n,j) * k(:,j); end x=xwrk+ dt * Xtemp1; ti=twrk+alph(n)*dt; k(:,n)=feval(deq, ti, x, mu); end Xtemp2=0.0; for l = 1:1:13 Xtemp2=Xtemp2+ch(l)*k(:,l); end x=xwrk + dt * Xtemp2; t=twrk+dt; On Mon, Mar 7, 2011 at 1:50 PM, Chris Rebert <c...@rebertia.com> wrote: > >>> On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman <jfc.her...@gmail.com> > 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 interesting part is if I take my exact code and translate it to > >>>> Matlab code (so I use the exact same process and numbers), I get a far > >>>> superior precision (the one I am expecting, in fact). This leads me to > think > >>>> I need to call a certain command in my Python script in order to make > sure > >>>> no truncation errors are building up over my integration. > >>>> > >>>> Has anyone had similar problems? Is there a difference between how > >>>> Matlab and Python store numbers, and if so how do I make Python more > >>>> accurate? > >>>> > <snip> > On Mon, Mar 7, 2011 at 10:36 AM, Jon Herman <jfc.her...@gmail.com> wrote: > > 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 > > I am making here that may have an accuracy problem? Thanks for any advice > > you can give! > > > <Python code snipped> > > Since the problem is quite possibly due to an imperfection in the > translation process, I think also posting your MATLAB integrator code > for comparison would be advisable. > > Cheers, > Chris > -- > Please avoid top-posting: > http://en.wikipedia.org/wiki/Top-posting >
-- http://mail.python.org/mailman/listinfo/python-list