What is the Fastest Multiprecision Package for Trigonometric Functions?

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
Click For Summary

Discussion Overview

The discussion focuses on identifying the fastest multiprecision package for calculating trigonometric functions, specifically the tangent function. Participants share their experiences and test results using various software tools, including Pari, Maple, and Mathematica, to evaluate performance at different precision levels.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports that Pari's tangent routine has a time complexity of \mathcal{O}(n^2) or \mathcal{O}(n^2\log n), leading to impractical computation times for high precision.
  • Another participant offers to test Maple and seeks clarification on the specific precision levels required for testing.
  • Testing results from Maple indicate that it struggles with high precision calculations, with times exceeding 900 seconds for 1,000,000 digits.
  • Results from Mathematica show significantly faster computation times, with a noted caution that it may leverage previous results for efficiency.
  • A participant expresses satisfaction with Mathematica's performance, reporting a time of 1462 seconds for calculating tan(1) to 10,000,000 places.

Areas of Agreement / Disagreement

Participants generally agree that Maple is not suitable for high precision tangent calculations, while Mathematica appears to be more efficient. However, there is no consensus on a definitive "best" package, as performance may vary based on specific use cases and system configurations.

Contextual Notes

Participants note that different software may use varying algorithms, which affects performance. There is also mention of Mathematica's caching mechanism, which could influence timing results.

Who May Find This Useful

Individuals interested in high precision calculations of trigonometric functions, particularly those working in computational mathematics or related fields, may find this discussion relevant.

CRGreathouse
Science Advisor
Homework Helper
Messages
2,832
Reaction score
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:
Physics news on Phys.org
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?
 
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:
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:
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.
 
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];]
 
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.
 

Similar threads

  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 20 ·
Replies
20
Views
5K
  • · Replies 49 ·
2
Replies
49
Views
12K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 13 ·
Replies
13
Views
4K