Generating trigonometric tables
Tablestrigonometric functionsuseful innumberareas. Beforeexistencefast pocket calculators, trigonometric tables were essentialnavigation, scienceengineering. The calculationmathematical tables was an important areastudy, which led todevelopment offirst mechanical computing devices.Modern computerspocket calculators now generate trigonometric function values on demand, using special librariesmathematical code. Often, these libraries use pre-calculated tables internally,computerequired value by using an appropriate interpolation method.
Interpolationsimple look-up tablestrigonometric functionsstill usedcomputer graphics, where accurate calculationseither not needed, or cannot be made fast enough.
Another important applicationtrigonometric tablesgeneration schemes isfast Fourier transform (FFT) algorithms, wheresame trigonometric function values (called twiddle factors) must be evaluated many times ingiven transform, especially incommon case where many transforms ofsame sizecomputed. In this case, calling generic library routines every timeunacceptably slow. One option iscalllibrary routines once,build uptablethose trigonometric values that will be needed, but this requires significant memorystoretable. The other possiblity, sinceregular sequencevaluesrequired, isuserecurrence formulacomputetrigonometric values onfly. Significant research has been devotedfinding accurate, stable recurrence schemesorderpreserveaccuracy ofFFT (whichvery sensitivetrigonometric errors).
| Tablecontents |
|
2 A better, but still imperfect, recurrence formula 3 References |
A quick, but inaccurate, approximation
A quick, but inaccurate, algorithmcalculatingtableN approximations snsin(2&pin/N)cncos(2πn/N) is:
- s0 = 0
- c0 = 1
- sn+1 = sn + d × cn
- cn+1 = cn - d × sn
ThissimplyEuler methodintegratingdifferential equation:
Unfortunately, thisnotuseful algorithmgenerating sine tables becausehassignificant error, proportional1/N.
For example,N = 256maximum error insine values~0.061 (s202 = -1.0368 instead-0.9757). For N = 1024,maximum error insine values~0.015 (s803 = -0.99321 instead-0.97832), about 4 times smaller. Ifsinecosine values obtained werebe plotted, this algorithm would drawlogarithmic spiral rather thancircle.
A better, but still imperfect, recurrence formula
A simple recurrence formulagenerate trigonometric tablesbased on Euler's formula andrelation:
- c0 = 1
- s0 = 0
- cn+1 = wr cn - wi sn
- sn+1 = wi cn + wr sn
This method would produce an exact tableexact arithmetic, but has errorsfinite-precision floating-point arithmetic. In fact,errors grow as O(ε N) (in bothworstaverage cases), where ε isfloating-point precision.
A significant improvement isusefollowing modification toabove,trick often usedgenerate trigonometric valuesFFT implementations:
- c0 = 1
- s0 = 0
- cn+1 = cn - (αcn + β sn)
- sn+1 = sn + (β cn - α sn)
See also:
To come- Buneman's recurrence algorithmaccurate FFTs (Proc. IEEE 75, 1434 (1987)), or some similarly improved scheme (see Tasche, below).
- Calculating accurate approximationstrigonometric functions (CORDIC schemes, etcetera)
- Arbitrary-precision arithmetic methods (quadratically convergent schemes based on arithmetic-geometric mean, relatedfast methodscomputing pi)
References
- Manfred TascheHansmartin Zeuner, "Improved roundoff error analysisprecomputed twiddle factors," J. Computational AnalysisApplications 4 (1), 1-18 (2002).
- James C. Schatzman, "Accuracy ofdiscrete Fourier transform andfast Fourier transform," SIAM J. Sci. Comput. 17 (5), 1150-1166 (1996).
