Precision Issue in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter EngWiPy
  • Start date Start date
  • Tags Tags
    Mathematica Precision
Click For Summary

Discussion Overview

The discussion centers around issues of precision in Mathematica, particularly how increasing precision affects computation time and the efficiency of algorithms. Participants explore the trade-offs between arbitrary-precision and machine-precision calculations, as well as strategies for optimizing performance in complex calculations involving multiple summations and derivatives.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that their results in Mathematica were incorrect due to precision issues, despite the code being correct, and seeks advice on efficiently increasing precision.
  • Another participant explains that arbitrary-precision numbers are inherently slower than machine-precision numbers and emphasizes the importance of identifying bottlenecks in the algorithm to improve speed.
  • A participant shares their experience of a lengthy computation for a dissertation project, highlighting the benefits of parallelizing the function and utilizing multiple computers.
  • There is a concern raised about the inter-dependence of code potentially complicating the parallelization process, despite recognizing it as a smart idea.
  • One participant expresses that increasing precision significantly increases running time compared to machine-precision calculations.

Areas of Agreement / Disagreement

Participants generally agree that increasing precision leads to longer computation times and that there are inherent trade-offs involved. However, there is no consensus on the best approach to efficiently manage these precision issues or on the feasibility of parallelization in this specific context.

Contextual Notes

Participants mention the complexity of the equations involved, including multiple summations and derivatives, which may contribute to the observed slow performance. There is also an acknowledgment of the limitations of arbitrary-precision calculations in terms of speed.

EngWiPy
Messages
1,361
Reaction score
61
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
 
Physics news on Phys.org
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.
 
DaleSpam said:
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.

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
 
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.
 
DaleSpam said:
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.

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

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K