Skip to the calculator
Rule Calculator

Law of Cosines Calculator

With side a 5, side b 7, angle c (between a and b) 60 °, law of cosines comes to 6.2450 — side c. It is reached in 5 steps, the last of which is sqrt(5 ^ 2 + 7 ^ 2 - 2 * 5 * 7 * cos(1.0471976)), and each one is printed on the page with its numbers filled in. The formula is the one published by Encyclopedia of Mathematics, not an approximation fitted to it.

Solves a triangle from two sides and the angle between them: the third side, the other two angles and the area, using c² = a² + b² − 2ab·cos C.

Formula and sources checked · How we check

Side a 5, Side b 7, Angle C (between a and b) 60 °

6.2450

Side c for the example below. Editing a field recomputes the calculator below; this figure holds the answer the page was loaded with.

It is written into the HTML rather than drawn by a script, so a search engine reading this page without running JavaScript still finds an answer.

Side c
6.2450
Side c
sqrt(5 ^ 2 + 7 ^ 2 - 2 * 5 * 7 * cos(1.0471976))6.245
Angle A
acos(max(-1, min(1, (7 ^ 2 + 6.244998 ^ 2 - 5 ^ 2) / (2 * 7 * 6.244998)))) * 180 / pi43.898 °
Angle B
180 - 43.897886 - 6076.102 °
Perimeter
5 + 7 + 6.24499818.245
Area
0.5 * 5 * 7 * sin(1.0471976)15.155

Ask about this in the chat

Worked example

c² = 25 + 49 − 2 × 5 × 7 × cos 60° = 74 − 35 = 39, so c = 6.2450. Angle A works out at 43.8979 degrees and angle B at 76.1021, and the area is 15.1554 square units. Set angle C to 90 degrees and the cosine term vanishes: what is left is Pythagoras.

How to work it out yourself

  1. 1.The angle has to be the one between the two sides you know. An angle anywhere else gives the ambiguous case, which this form does not accept.
  2. 2.Read the third side first, then the two remaining angles. The largest angle is opposite the longest side, which is the sanity check.
  3. 3.For all three sides and no angle, enter any two of them with a guessed angle and rearrange: cos C = (a² + b² − c²)/(2ab). The step for angle A on this page is that rearrangement.

The formula

  1. Side csqrt(5 ^ 2 + 7 ^ 2 - 2 * 5 * 7 * cos(1.0471976))
  2. Angle Aacos(max(-1, min(1, (7 ^ 2 + 6.244998 ^ 2 - 5 ^ 2) / (2 * 7 * 6.244998)))) * 180 / pi
  3. Angle B180 - 43.897886 - 60
  4. Perimeter5 + 7 + 6.244998
  5. Area0.5 * 5 * 7 * sin(1.0471976)

Source: Encyclopedia of Mathematics — cosine theorem, NIST DLMF §4.14 — trigonometric functions

Questions people actually ask

How is this related to Pythagoras?
It is Pythagoras with a correction term. When C is 90 degrees, cos C is zero and c² = a² + b². For a smaller angle the third side is shorter than Pythagoras predicts, for a larger one it is longer, and 2ab·cos C is exactly the amount.
Can I use it with three sides and no angle?
Yes — rearranged. cos C = (a² + b² − c²)/(2ab), then take the arccosine. That is how the angle A step on this page is computed once side c is known.
Why does an obtuse angle make the third side longer?
Because the cosine goes negative past 90 degrees, so −2ab·cos C becomes an addition. Opening the angle between two sticks moves their far ends apart, and the formula says so.

Related

Put this calculator on your site

Free, no attribution required beyond the link.

<iframe src="https://rulecalculators.com/embed/law-of-cosines" width="100%" height="420" style="border:1px solid #e7e4de;border-radius:12px" title="Law of Cosines Calculator"></iframe>
Did this answer your question?