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.<br><br> k(:,1)=feval(deq, ti, x, mu);<br> <br>
for n = 2:1:13<br> nn=n-1;<br> Xtemp1 = 0.0;<br> for j = 1:1:nn<br> Xtemp1 = Xtemp1 + beta(n,j) * k(:,j);<br> end<br> x=xwrk+ dt * Xtemp1;<br> ti=twrk+alph(n)*dt;<br>
k(:,n)=feval(deq, ti, x, mu);<br> end<br> <br> Xtemp2=0.0;<br> for l = 1:1:13<br> Xtemp2=Xtemp2+ch(l)*k(:,l);<br> end<br> <br> <br> x=xwrk + dt * Xtemp2;<br>
t=twrk+dt;<br> <br> <br> <br><br><div class="gmail_quote">On Mon, Mar 7, 2011 at 1:50 PM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">>>> On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman <<a href="mailto:jfc.herman@gmail.com">jfc.herman@gmail.com</a>> wrote:<br>
>>>><br>
</div><div class="im">>>>> I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8)<br>
>>>> integrator in Python, which requires an extreme numerical precision for my<br>
>>>> particular application. Unfortunately, I can not seem to attain it.<br>
>>>> The interesting part is if I take my exact code and translate it to<br>
>>>> Matlab code (so I use the exact same process and numbers), I get a far<br>
>>>> superior precision (the one I am expecting, in fact). This leads me to think<br>
>>>> I need to call a certain command in my Python script in order to make sure<br>
>>>> no truncation errors are building up over my integration.<br>
>>>><br>
>>>> Has anyone had similar problems? Is there a difference between how<br>
>>>> Matlab and Python store numbers, and if so how do I make Python more<br>
>>>> accurate?<br>
>>>><br>
</div><snip><br>
<div class="im">On Mon, Mar 7, 2011 at 10:36 AM, Jon Herman <<a href="mailto:jfc.herman@gmail.com">jfc.herman@gmail.com</a>> wrote:<br>
> I'm starting to run out of ideas of what to do...I've imported the true<br>
> division (I'm using Python 2.7) to make sure I wasn't accidentally using any<br>
> integers but the results remain identical, so it's not a division problem.<br>
> I've copied the loop I'm running below, is there any mathematical operation<br>
> I am making here that may have an accuracy problem? Thanks for any advice<br>
> you can give!<br>
><br>
</div><Python code snipped><br>
<br>
Since the problem is quite possibly due to an imperfection in the<br>
translation process, I think also posting your MATLAB integrator code<br>
for comparison would be advisable.<br>
<br>
Cheers,<br>
Chris<br>
<font color="#888888">--<br>
Please avoid top-posting:<br>
<a href="http://en.wikipedia.org/wiki/Top-posting" target="_blank">http://en.wikipedia.org/wiki/Top-posting</a><br>
</font></blockquote></div><br>