Cosine Calculator
Type three sides to get every angle, or two sides and the angle between them to get the third side. Sides of 3, 4 and 5 put a 90 degree angle across from the 5, which is the law of cosines agreeing with Pythagoras.
Pick what you have. The page returns cos(x) for any angle, the missing side or angle of a triangle through the law of cosines, or the angle between two vectors. Everything runs in your browser.
| Cosine |
All calculations run in your browser, and nothing you type is uploaded or stored.
Find the cosine of an angle, a missing side, or a missing angle: three sides, two sides with the angle between them, and two vectors all run through the law of cosines.
Key takeaways
- cos C = (a squared + b squared - c squared) / (2ab) turns three sides into an angle
- With C at 90 degrees the cosine is 0 and the law of cosines becomes Pythagoras
- Sides of 7, 8 and 9 inches give angles of 48.19, 58.412 and 73.398 degrees
- Two sides of 200 ft and 150 ft at 72 degrees leave a third side of 209.664 ft
- cos 60 radians is -0.952413, not 0.5, because radians and degrees are different units
On this page
Cosine is a ratio before it is a button
In a right triangle, the cosine of an angle is the side next to that angle divided by the longest side. A wheelchair ramp 100 inches long that covers a 96 inch run has a cosine of 96 / 100 = 0.96 at the bottom, and arccos(0.96) = 16.26 degrees. That is the whole idea: measure two sides, divide, and the angle falls out. NASA's Glenn Research Center teaches the same three ratios to flight students (NASA, updated 2025), starting from a wing instead of a circle.
Put the angle at the center of a unit circle and cosine becomes the x coordinate of the point where the angle lands. At 60 degrees the point is (0.5, 0.866), so cos 60 = 0.5. At 120 degrees the point is (-0.5, 0.866), so cos 120 = -0.5. Cosine reads left and right; sine reads up and down. The NIST Digital Library of Mathematical Functions, section 4.14 (NIST, 2026) defines the six circular functions this way and lists the identities that follow.
Two properties come straight from that picture. A cosine never leaves the range -1 to 1, since it is a coordinate on a circle of radius 1. And it is even, so cos(-40) equals cos(40), which matters when a bearing arrives as a negative number.
| Angle | Radians | Cosine | What the number says |
|---|---|---|---|
| 0 degrees | 0 | 1.0000 | full reach to the right |
| 30 degrees | 0.5236 | 0.8660 | still mostly rightward |
| 45 degrees | 0.7854 | 0.7071 | equal up and right |
| 60 degrees | 1.0472 | 0.5000 | half the reach |
| 90 degrees | 1.5708 | 0.0000 | no rightward reach at all |
| 120 degrees | 2.0944 | -0.5000 | leaning back to the left |
| 150 degrees | 2.6180 | -0.8660 | nearly straight back |
| 180 degrees | 3.1416 | -1.0000 | full reach to the left |
The law of cosines is Pythagoras with a correction
The Pythagorean theorem only works when the triangle has a right angle. The law of cosines covers every triangle: c squared = a squared + b squared - 2 x a x b x cos C, where C is the angle between sides a and b and c is the side across from that angle. The Texas A&M Math 150 textbook, section 8.5 proves it by dropping an altitude and applying Pythagoras twice, which is worth reading once.
When C is 90 degrees, cos C is 0 and the last term vanishes, leaving c squared = a squared + b squared. When C opens wider than 90 degrees, the cosine turns negative, so the last term is added rather than subtracted, and c grows past the Pythagorean answer. That single sign is the entire difference between an acute and an obtuse triangle, and it is why the law of cosines needs no special case for obtuse shapes.
| What you want | Formula |
|---|---|
| side c from a, b and the angle between them | c = square root of (a squared + b squared - 2 x a x b x cos C) |
| cos C from three sides | cos C = (a squared + b squared - c squared) / (2 x a x b) |
| angle C from three sides | C = arccos of that quotient |
| right angle check | cos C = 0 exactly when a squared + b squared = c squared |
Which line you need depends on what you have. Three sides is the SSS case and the second formula applies. Two sides with the angle between them is the SAS case and the first formula applies. Two sides with an angle that is not between them is the SSA case, which can produce two different triangles from the same measurements. This page does not guess at SSA, because a calculator that silently picks one of two valid answers is worse than no calculator.
Three sides in, three angles out
Take a triangle with sides of 7, 8 and 9 inches, and call the 9 inch side c. The angle across from it is C, and the cosine comes from the three sides alone.
cos C = (49 + 64 - 81) / (2 x 7 x 8) = 32 / 112 = 0.285714, and arccos(0.285714) = 73.398 degrees. Angle A, across from the 7 inch side, works the same way: cos A = (64 + 81 - 49) / (2 x 8 x 9) = 96 / 144 = 0.666667, so A = 48.19 degrees. The third angle needs no trigonometry at all: 180 - 73.398 - 48.19 = 58.412 degrees.
| Side | Angle across from it | Cosine of that angle | Check by hand |
|---|---|---|---|
| 7 in | 48.19 degrees | 0.666667 | 96 / 144 |
| 8 in | 58.412 degrees | 0.523810 | 66 / 126 |
| 9 in | 73.398 degrees | 0.285714 | 32 / 112 |
One habit saves a lot of grief: solve for the largest angle first. The largest angle is across from the longest side, and it is the only one that can be obtuse. If you start with a small angle, arccos returns an acute value, and an obtuse triangle will quietly answer 20 degrees when the truth is 160. Solving the big angle first also gives you a cheap check, since the other two must then be acute.
The area of the same triangle comes from two sides and the angle between them: 0.5 x 7 x 8 x sin(73.398) = 26.83 square inches. Heron's formula gives the same 26.83 from the three sides alone, which is a useful cross check when the numbers matter.
Two sides and the angle between them
Two property lines meet at a corner at 72 degrees, one 200 ft and the other 150 ft. The distance straight across the lot is the third side. Square both sides and subtract twice their product times the cosine.
c squared = 40,000 + 22,500 - 2 x 200 x 150 x cos 72 = 62,500 - 60,000 x 0.309017 = 62,500 - 18,541.02 = 43,958.98. The square root is 209.664 ft. Notice how much the correction term matters: without it, Pythagoras would claim 250 ft for a triangle that is nowhere near a right angle.
From there the other angles come back through the same law rearranged. Twice 150 times 209.664 gives 62,899.2, the denominator. cos A = (22,500 + 43,958.98 - 40,000) / 62,899.2 = 26,458.98 / 62,899.2 = 0.42066, so A = 65.124 degrees. The last angle is 180 - 72 - 65.124 = 42.876 degrees, and the three add to 180 exactly.
| Side a | Side b | Angle between | Third side | Other two angles |
|---|---|---|---|---|
| 200 ft | 150 ft | 72 degrees | 209.664 ft | 65.124 and 42.876 degrees |
| 120 ft | 90 ft | 35 degrees | 69.3276 ft | 96.875 and 48.125 degrees |
| 60 in | 60 in | 60 degrees | 60 in | 60 and 60 degrees |
The second row is the case that surprises people. Two sides of 120 ft and 90 ft with a narrow 35 degrees between them leave a third side of only 69.33 ft, and the angle across from the 120 ft side is 96.875 degrees, an obtuse angle. A narrow included angle pushes the opposite angle past 90, and no sketch drawn by eye will show it.
Degrees, radians, and the mode trap
Degrees split a full turn into 360 parts. Radians measure the same turn by the length of arc on a unit circle, so a full turn is 2 x pi = 6.2832 radians and one radian is 57.2958 degrees. Both are just labels on the same rotation, but the labels are not interchangeable inside a calculator.
Here is what the mix-up looks like. Set a calculator to radians and type 60. That is 60 radians, not 60 degrees. Nine full turns take 56.5487 radians, so 60 radians lands 3.4513 radians past the ninth turn, which points the same way as 197.7468 degrees, and cos 60 rad = -0.952413. The degree answer, 0.5, is nowhere in sight.
| Input | Read as | Cosine |
|---|---|---|
| 60 in degree mode | 60 degrees | 0.5 |
| 60 in radian mode | 3437.7468 degrees, same direction as 197.7468 | -0.952413 |
| 1 in radian mode | 57.2958 degrees | 0.540302 |
| 2 in radian mode | 114.5916 degrees | -0.416147 |
| pi in radian mode | 180 degrees | -1 |
A quick sanity check catches most of these. If an angle should be acute and the cosine comes back below zero, the angle is obtuse, which usually means the mode is wrong or a supplement was used. If a cosine near 1 shows up where you expected a small number, the mode is the first thing to inspect and the formula is the last.
Cosine and the dot product
Two arrows that point the same way have a cosine of 1. Arrows at a right angle have a cosine of 0. Arrows pointing exactly opposite have -1. The dot product turns that into arithmetic: u dot v = |u| x |v| x cos theta, so cos theta = (u dot v) / (|u| x |v|).
Take u = (3, 4, 0) and v = (5, 0, 0). The dot product is 3 x 5 + 4 x 0 + 0 x 0 = 15. The lengths are 5 and 5, so cos theta = 15 / 25 = 0.6 and theta = 53.13 degrees. Nothing about the two arrows needed plotting.
A three dimensional pair runs the same way. u = (1, 2, 2) and v = (2, 0, 1): the dot product is 2 + 0 + 2 = 4, the lengths are 3 and 2.2361, so cos theta = 4 / 6.7082 = 0.596285 and theta = 53.396 degrees. Game engines, robot arms, and satellite pointing all run this line of code millions of times a second, which is why the cosine is the workhorse of 3D math rather than the sine.
| u | v | Dot product | Cosine | Angle |
|---|---|---|---|---|
| (3, 4, 0) | (5, 0, 0) | 15 | 0.6 | 53.13 degrees |
| (1, 2, 2) | (2, 0, 1) | 4 | 0.596285 | 53.396 degrees |
| (2, -1, 3) | (1, 4, 2) | 4 | 0.233285 | 76.509 degrees |
A cosine close to 1 carries useful information about tolerance. cos theta = 0.99 means the two directions are 8.11 degrees apart, and cos theta = 0.9999 means 0.81 degrees. That is why a machine alignment spec is often written as a minimum cosine rather than as an angle: the number stays well behaved near zero, where the angle does not.
Where cosine shows up in ordinary work
The law of cosines solves any distance you cannot walk. A surveyor standing at a property corner measures two lines and the angle between them, and the third line comes out of the formula. A carpenter checking a deck for square uses the 3-4-5 triangle, which is the law of cosines with the cosine set to zero: 9 + 16 = 25, so the angle between the 3 ft and 4 ft sides is exactly 90 degrees.
Roof and stair work lean on the same numbers. A brace that spans a corner, a hip rafter that meets two others, and a stair stringer all reduce to a triangle with two known sides and a known angle. So does a phone's step counter, which turns a stream of small accelerations into distance.
| Job | What is known | Cosine | Answer |
|---|---|---|---|
| deck corner | 3 ft, 4 ft, 5 ft | 0 | exactly 90 degrees, the deck is square |
| cabinet frame | 30 in, 30 in, 42 in | 0.02 | 88.854 degrees, off square by 1.146 |
| lot line | 200 ft, 150 ft, 72 degrees between | 0.309017 | 209.664 ft across |
| two headings | (1, 2, 2) and (2, 0, 1) | 0.596285 | 53.396 degrees apart |
The cabinet row is the useful one. Two 30 inch rails with a 42 inch diagonal give a cosine of 0.02, which is 88.854 degrees, so the corner sits 1.146 degrees off square. Over 30 inches that is 0.6 in of drift at the far end, enough to show as a gap against a door. Small cosines near zero are hard to read by eye and easy to read on a calculator.
Errors that survive the arithmetic
Pairing a side with the wrong angle. In the law of cosines, side c sits across from angle C. Type the 9 inch side as a and the 9 inch side as c, and the formula answers a question about a different triangle. The safe habit is to label the sketch before touching the calculator.
Three sides that cannot close. Sides of 2, 3 and 6 fail before any angle is computed, because 2 + 3 is less than 6 and the two short sides cannot reach across the long one. The formula still returns a number: cos C = (4 + 9 - 36) / 12 = -1.9167, which is outside the -1 to 1 range and is the giveaway. This page reports that the sides do not form a triangle instead of returning an angle from an impossible cosine.
Rounding the cosine before taking the arccosine. Near 0 and 180 degrees, a tiny change in cosine moves the angle a long way. cos theta = 0.9999 is 0.81 degrees and cos theta = 0.9995 is 1.81 degrees. Rounding 0.99985 to 0.9999 turns an angle of 1 degree into 0.81 degrees, a 19 percent error from one digit. Keep four to six decimals until the arccos is done.
Trusting an inverse function to pick the right angle. arccos always returns a value between 0 and 180 degrees, so it can only ever give the angle that belongs to that cosine. If the triangle might be obtuse, solve for the largest angle first, then fill the others with the angle sum. The arithmetic is not wrong in that case; the order of the steps is.
Frequently asked questions
What is the cosine of 60 degrees?
0.5. On the unit circle the point at 60 degrees is (0.5, 0.866), and cosine reads the first coordinate. In a 30-60-90 triangle the side next to the 60 degree angle is half the hypotenuse, which gives the same 0.5.
What is the law of cosines formula?
c squared = a squared + b squared - 2 x a x b x cos C, where C is the angle between sides a and b and c is the side across from it. Rearranged for the angle, cos C = (a squared + b squared - c squared) / (2 x a x b).
Can the law of cosines find an angle from three sides?
Yes, that is the SSS case. Sides of 7, 8 and 9 inches give cos C = (49 + 64 - 81) / 112 = 0.285714, so the angle across from the 9 inch side is 73.398 degrees, and the other two angles are 48.19 and 58.412 degrees.
How is the law of cosines different from the Pythagorean theorem?
Pythagoras is the special case where the angle between the two known sides is 90 degrees, because cos 90 is 0 and the correction term disappears. For any other angle the -2ab cos C term adds or subtracts the amount by which the triangle leans.
Why is cos 60 radians not 0.5?
Because 60 radians is 60 radians, not 60 degrees. Nine full turns take 56.5487 radians, so 60 radians points the same way as 197.7468 degrees, and the cosine of that angle is -0.952413. Switch the unit to degrees to get 0.5.
What does a negative cosine mean?
The angle is between 90 and 270 degrees, so the point on the unit circle sits left of center. Cos 120 = -0.5 and cos 180 = -1. A negative cosine in a triangle means the angle is obtuse, past 90 degrees.
What is the angle between two vectors with a dot product of 15 and lengths 5 and 5?
53.13 degrees. cos theta = 15 / (5 x 5) = 0.6, and arccos(0.6) = 53.13 degrees. That is the same cosine as a 3-4-5 triangle, which is not a coincidence: those vectors are the 3 and 4 legs.
How do I find the third side of a triangle with two sides and the angle between them?
Square both sides, subtract twice their product times the cosine of the angle, then take the square root. For 200 ft and 150 ft at 72 degrees: 40,000 + 22,500 - 60,000 x 0.309017 = 43,958.98, and the square root is 209.664 ft.
What happens if the three sides cannot form a triangle?
The cosine comes out outside the -1 to 1 range, which no angle can produce. Sides of 2, 3 and 6 give (4 + 9 - 36) / 12 = -1.9167, and the two short sides cannot reach across the long one. This calculator reports that the sides do not form a triangle.
Is cosine even or odd?
Even: cos(-x) = cos(x). Cos(-40) = cos(40) = 0.766044, and cos(-120) = cos(120) = -0.5. Sine is the odd one, which is why bearings given as negative angles still work in a cosine formula.
How many degrees is 1 radian?
57.2958 degrees. A full turn is 2 x pi radians, or 6.2832 radians, so one radian is 360 / 6.2832 = 57.2958 degrees. Cos 1 rad = 0.540302, which is the same as cos 57.2958 degrees.
Why should I solve for the largest angle first?
Because arccos returns a value between 0 and 180 degrees, and only the largest angle can be obtuse. In the 7-8-9 triangle the largest angle is 73.398 degrees, so the shape is acute. Had it been 110 degrees, solving a smaller angle first could hide that.
What is cos 90 degrees?
Exactly 0. The point at 90 degrees is (0, 1), so there is no horizontal reach at all. That zero is what turns the law of cosines into the Pythagorean theorem whenever the triangle has a right angle.
How accurate are the values on this page?
Cosines are shown to six decimals and angles to three, which is within 0.001 degrees. Cos 40 is 0.766044 and the page prints 0.766044. For alignment work, use the unrounded value, since rounding a cosine near 1 moves the angle quickly.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.