Trigonometry calculator
Sine, cosine and tangent, in degrees or radians. Where the answer is a number you could write down exactly, it is shown beside what the machine actually computed — and they are not always the same. Nothing you type here leaves your browser — it is worked out on your own device, so there is nothing to send and nothing to log.
Why a right angle is not quite a right angle
Computers work in radians, and a degree is π ÷ 180 radians. π is irrational, so no computer holds it exactly — and the moment 30 is multiplied by an approximation of π ÷ 180, the angle being worked with is not 30° any more:
| sin(30°) | 0.49999999999999994, where the answer is 0.5 |
|---|---|
| sin(180°) | 1.2246467991473532e-16, where the answer is 0 |
| cos(90°) | 6.123233995736766e-17, where the answer is 0 |
These are not bugs in any one language — Python, C and a pocket calculator that works in binary all give the same answers, because the fault is in representing π rather than in the sine. This page shows both numbers rather than quietly rounding the computed one to the exact one, because the gap is the thing worth knowing about.
The tangent of a right angle looks like an answer
tan(90°) is undefined: it is sine over cosine, and the cosine of 90° is zero. What a computer returns is:
tan(90°) = 16331239353195370
Sixteen quadrillion. Not an error, not Infinity, not NaN — a perfectly ordinary integer-looking number that will pass straight through any check for those three. It is what you get by dividing 1 by the 6.1×10-17 that cos(90°) actually computes to. This page says the answer is undefined and shows you what the machine returned anyway.
The angles that prove nothing
sin(0°) is exactly 0. cos(0°) is exactly 1. sin(90°) is exactly 1. All three are right to the last bit, because 0 times anything is 0 and the sine peaks at exactly 1 — so any implementation, however broken its degree conversion, passes all three.
They are also the first three anybody types into a new trigonometry calculator. The value that discriminates is 30°, where the answer is a simple half and the machine cannot produce it.