What is the Fastest Multiprecision Package for Trigonometric Functions?

  • Thread starter CRGreathouse
  • Start date
In summary, the conversation revolved around finding a tool to solve a problem involving subquadratic trig functions. The individual was looking for a faster alternative to Pari, which had a tangent routine that was too slow for high precision calculations. Suggestions were made for testing other platforms such as Math'ca and Maple, and testing was done for calculating the tangent of 1 to 10,000, 100,000, 200,000, and 300,000 digits. It was found that Mathematica was the most efficient solution, taking only 1462 seconds to calculate the tangent to 10 million places. However, it was noted that Mathematica may use previous results in its calculations.
  • #1
CRGreathouse
Science Advisor
Homework Helper
2,844
0
I'm looking for a tool to solve a problem I've been working on. In particular, I want something that implements subquadratic trig functions -- actually just the tangent would work for me. :) I've been using Pari, but its tangent routine seems to be [itex]\mathcal{O}(n^2)[/itex] or [itex]\mathcal{O}(n^2\log n)[/itex] based on timing, and for high precision this simply takes too long. 10,000 digits in Pari takes half a second, but 100,000 takes more than a minute, and ten million takes over a week, which isn't feasible.

Any suggestions? Can anyone test their preferred platform (Math'ca, Maple, etc.) to see how long these take? I was testing tan(1) if you want comparability. I tested Maxima, but it seemed to be inappropriate for the task: in addition to apparently also using a quadratic method, it took ~30 times longer than Pari for similar precisions.
 
Last edited:
Mathematics news on Phys.org
  • #2
I could to test Maple (11) for you, if you told me how.

So what you want is the amount of time (in seconds) that it takes maple to calculate tan(1) to the 10 000th, 100 000th, 1 000 000th, and 10 000 000th digit?
 
  • #3
Dragonfall said:
I could to test Maple (11) for you, if you told me how.

So what you want is the amount of time (in seconds) that it takes maple to calculate tan(1) to the 10 000th, 100 000th, 1 000 000th, and 10 000 000th digit?

That would be great. I'd just test it to 10 000, 100 000, 200 000, and 300 000 digits, though -- 10 000 000 would probably take a long time.

The commands should be something like this:
Code:
digits := 10000; settime := time(); tan(1): time() − settime;
digits := 100000; settime := time(); tan(1): time() − settime;
digits := 200000; settime := time(); tan(1): time() − settime;
digits := 300000; settime := time(); tan(1): time() − settime;
 
Last edited:
  • #4
1 000: 0.078s
10 000: 0.280s
100 000: 24.031s
200 000: 97.719s
300 000: 216.750s
1 000 000: > 900s.

It does not seem Maple can be of much help.
 
Last edited:
  • #5
From Mathematica 6.0 on single core Athlon64 3400+, 2GB RAM, Vista Ultimate OS:

Code:
Timing[N[Tan[1], 100000]][[1]]
2.14
Timing[N[Tan[1], 200000]][[1]]
5.422
Timing[N[Tan[1], 300000]][[1]]
9.203
Timing[N[Tan[1], 1000000]][[1]]
44.531

Times are in seconds. Note that Mathematica cautions that it tables previous results for like calculations, so it probably used the previous tangents as stepping stones for the larger numbers.
 
  • #6
Yes, Mathematica seems like the solution for me. It took only (!) 1462 seconds to calculate tan(1) to 10,000,000 places:

Timing[N[Tan[1], 10000000];]
 
  • #7
Dragonfall said:
1 000: 0.078s
10 000: 0.280s
100 000: 24.031s
200 000: 97.719s
300 000: 216.750s
1 000 000: > 900s.

It does not seem Maple can be of much help.

Thank you for running the tests! I appreciate it. It looks like Maple also uses a quadratic algorithm.
 

1. What is a multiprecision package?

A multiprecision package is a software library that allows for the representation and manipulation of numbers with higher precision than the standard data types used in programming languages. This is useful for scientific and mathematical computations that require more accuracy.

2. Why is a good multiprecision package important for scientific research?

In scientific research, accuracy and precision are crucial in obtaining reliable results. A good multiprecision package allows for more precise calculations, which can lead to more accurate and trustworthy conclusions.

3. What features should I look for in a good multiprecision package?

A good multiprecision package should have a wide range of data types, support for basic arithmetic operations, advanced mathematical functions, and efficient algorithms for fast computation. It should also have error handling capabilities and be compatible with various programming languages.

4. Are there any popular multiprecision packages available?

Yes, there are several popular multiprecision packages, such as GMP (GNU Multiple Precision Arithmetic Library), MPFR (Multiple Precision Floating-Point Reliable Library), and Boost.Multiprecision. These packages are widely used in scientific computing and have been tested and optimized for accuracy and performance.

5. How can I choose the best multiprecision package for my needs?

The best way to choose a multiprecision package is to consider your specific needs and requirements. Some packages may have better performance for certain types of calculations, while others may have a wider range of data types. It is also important to consider the documentation, community support, and compatibility with your programming language of choice.

Similar threads

  • Programming and Computer Science
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
1K
  • Programming and Computer Science
2
Replies
49
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
20
Views
4K
  • Special and General Relativity
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top