Trigonometric table
In mathematics, tables of trigonometric functions are useful in a number of areas. Before the existence of pocket calculators, trigonometric tables were essential for navigation, science and engineering. The calculation of mathematical tables was an important area of study, which led to the development of the first mechanical computing devices. Trigonometric calculations played an important role in the early study of astronomy. Early tables were constructed by repeatedly applying trigonometric identities to compute new values from old ones.
Modern computers and pocket calculators now generate trigonometric function values on demand, using special libraries of mathematical code. Often, these libraries use pre-calculated tables internally, and compute the required value by using an appropriate interpolation method. Interpolation of simple look-up tables of trigonometric functions is still used in computer graphics, where only modest accuracy may be required and speed is often paramount.
Another important application of trigonometric tables and generation schemes is for fast Fourier transform algorithms, where the same trigonometric function values must be evaluated many times in a given transform, especially in the common case where many transforms of the same size are computed. In this case, calling generic library routines every time is unacceptably slow. One option is to call the library routines once, to build up a table of those trigonometric values that will be needed, but this requires significant memory to store the table. The other possibility, since a regular sequence of values is required, is to use a recurrence formula to compute the trigonometric values on the fly. Significant research has been devoted to finding accurate, stable recurrence schemes in order to preserve the accuracy of the FFT.
A trigonometry table is essentially a reference chart that presents the values of sine, cosine, tangent, and other trigonometric functions for various angles. These angles are usually arranged across the top row of the table, while the different trigonometric functions are labeled in the first column on the left. To locate the value of a specific trigonometric function at a certain angle, you would find the row for the function and follow it across to the column under the desired angle.
Using a trigonometry table involves a few straightforward steps
- Determine the specific angle for which you need to find the trigonometric values.
- Locate this angle along the horizontal axis of the table.
- Choose the trigonometric function you're interested in from the vertical axis.
- Trace across from the function and down from the angle to the point where they intersect on the table; the number at this intersection provides the value of the trigonometric function for that angle.
On-demand computation
The particular polynomial used to approximate a trigonometric function is generated ahead of time using some approximation of a minimax approximation algorithm.
For very high precision calculations, when series-expansion convergence becomes too slow, trigonometric functions can be approximated by the arithmetic-geometric mean, which itself approximates the trigonometric function by the elliptic integral.
Trigonometric functions of angles that are rational multiples of 2π are algebraic numbers. The values for a/b·2π can be found by applying de Moivre's identity for n = a to a bth root of unity, which is also a root of the polynomial xb - 1 in the complex plane. For example, the cosine and sine of 2π ⋅ 5/37 are the real and imaginary parts, respectively, of the 5th power of the 37th root of unity cos + sini, which is a root of the degree-37 polynomial x37 − 1. For this case, a root-finding algorithm such as Newton's method is much simpler than the arithmetic-geometric mean algorithms above while converging at a similar asymptotic rate. The latter algorithms are required for transcendental trigonometric constants, however.
A simple example
To compute the sine function of 75 degrees, 9 minutes, 50 seconds using a table of trigonometric functions such as the Bernegger table from 1619 illustrated above, one might simply round up to 75 degrees, 10 minutes and then find the 10 minute entry on the 75 degree page, shown above-right, which is 0.9666746.However, this answer is only accurate to four decimal places. If one wanted greater accuracy, one could interpolate linearly as follows:
From the Bernegger table:
The difference between these values is 0.0000745.
Since there are 60 seconds in a minute of arc, we multiply the difference by 50/60 to get a correction of *0.0000745 ≈ 0.0000621; and then add that correction to sin to get :
A modern calculator gives sin = 0.96666219991, so our interpolated answer is accurate to the 7-digit precision of the Bernegger table.
For tables with greater precision, higher order interpolation may be needed to get full accuracy. In the era before electronic computers, interpolating table data in this manner was the only practical way to get high accuracy values of mathematical functions needed for applications such as navigation, astronomy and surveying.
To understand the importance of accuracy in applications like navigation note that at sea level one minute of arc along the Earth's equator or a meridian equals one nautical mile.
Half-angle and angle-addition formulas
Historically, the earliest method by which trigonometric tables were computed, and probably the most common until the advent of computers, was to repeatedly apply the half-angle and angle-addition trigonometric identities starting from a known value = 1, cos. This method was used by the ancient astronomer Ptolemy, who derived them in the Almagest, a treatise on astronomy. In modern form, the identities he derived are stated as follows :These were used to construct Ptolemy's table of chords, which was applied to astronomical problems.
Various other permutations on these identities are possible: for example, some early trigonometric tables used not sine and cosine, but sine and versine.
A quick, but inaccurate, approximation
A quick, but inaccurate, algorithm for calculating a table of N approximations sn for sin and cn for cos is:for n = 0,...,N − 1, where d = 2π/N.
This is simply the Euler method for integrating the differential equation:
with initial conditions s = 0 and c = 1, whose analytical solution is s = sin and c = cos.
Unfortunately, this is not a useful algorithm for generating sine tables because it has a significant error, proportional to 1/N.
For example, for N = 256 the maximum error in the sine values is ~0.061. For N = 1024, the maximum error in the sine values is ~0.015, about 4 times smaller. If the sine and cosine values obtained were to be plotted, this algorithm would draw a logarithmic spiral rather than a circle.
A better, but still imperfect, recurrence formula
A simple recurrence formula to generate trigonometric tables is based on Euler's formula and the relation:This leads to the following recurrence to compute trigonometric values sn and cn as above:
for n = 0,..., N − 1, where wr = cos and wi = sin. These two starting trigonometric values are usually computed using existing library functions.
This method would produce an exact table in exact arithmetic, but has errors in finite-precision floating-point arithmetic. In fact, the errors grow as O, where ε is the floating-point precision.
A significant improvement is to use the following modification to the above, a trick often used to generate trigonometric values for FFT implementations:
where α = 2 sin2 and β = sin. The errors of this method are much smaller, O on average and O in the worst case, but this is still large enough to substantially degrade the accuracy of FFTs of large sizes.