Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Precision Issue in Mathematica

  1. Oct 18, 2009 #1
    Hello,

    I have an equation that when I wrote using Mathematica to get results, the results were wrong in some places. This has nothing to do with the code, which is a 100% correct code. It is a presicion issue. But when I increased the precision, say up to 20, even to 10, the code takes a lot (I mean a huge amount) of running time, and I got no results. The question is: how can I increase the precision to get accurate results in an efficient way in time?

    Thanks in advance
     
  2. jcsd
  3. Oct 18, 2009 #2

    Dale

    Staff: Mentor

    Arbitrary-precision numbers are inherently slower to compute than machine-precision numbers. It is an unavoidable trade-off, so there is only going to be so much that you can do since you need the precision.

    However, in general, when trying to speed up an algorithm the most important thing to do is to measure the different parts of your algorithm and actually find out where the bottleneck is. NEVER simply assume that you know which part is the slowest. Test it and find out for sure. Once you have identified the slowest part you can try to code it in an algebraically equivalent but more efficient manner or you can parallelize it etc. depending on the details.
     
  4. Oct 19, 2009 #3
    I am affraid that, I have nothing to do with the equations. But, I will try.

    Furthermore, my equation consists of more than 10 summations, and has many derivatives in each iteration. So, I think it is natural to be slow. But it is affordable for the case of machine-precision numbers.

    Regards
     
  5. Oct 19, 2009 #4

    Dale

    Staff: Mentor

    FYI, my final project for my dissertation involved a calculation that took 27 PC-days of computation. I parallelized the function and ran it over one weekend using all of my lab's computers as a jury-rigged cluster. Many universities now offer this kind of thing on a more "official" basis. If it is really a problem you might look into the resources available.
     
  6. Oct 19, 2009 #5
    Wow. Parallelism is a smart idea. I don't know, but I think the inter-dependence of the code may make this process difficult. Anyway, it is not that necessary for my thesis, whereas I beleive that your project was worthy (27 PC-days).

    But I felt that when I increased the precesion, the running time was largely incraesed relative to the corresponding machine-precision numbers.

    Best regards
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Precision Issue in Mathematica
  1. Mathematica issue (Replies: 4)

Loading...