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 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?

No, there is no difference in how they store numbers. Both use double-precision floating point numbers, almost certainly IEEE-754 doubles on your platform. Can you show us the output you get and the output you expect?

They do *display* floating point numbers differently. MATLAB will often truncate floats while Python will display as many digits as necessary (often more, actually) to faithfully reconstruct the binary floating point number. This can create the perception that MATLAB is doing things more accurately.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to