What is the law of cosines
The law of cosines finds the third side of any triangle from two sides and the angle between them: c = √(a² + b² − 2ab·cos C). For a = 3, b = 4 and C = 90°, cos 90° = 0, so c = √(9 + 16) = 5.
Think of the −2ab·cos C term as a correction to the Pythagorean theorem: when C is acute the term subtracts and c comes out shorter, and when C is obtuse it adds and c grows longer. Solving the rearranged formula for an unknown angle means taking an inverse cosine, which is what the arccosine calculator does.
How to use this calculator
Enter the two known sides and the included angle C (in degrees) between them. The result is the side opposite that angle. When C = 90° the formula reduces to the Pythagorean theorem.
The word included matters: C must be the angle between sides a and b, not one of the other corners. Both sides should be in the same unit, and the answer comes back in that unit.
Right triangles and beyond
The law of cosines works for any triangle, not just right ones, and is the companion of the law of sines. The cosine term comes from the cosine of the included angle.
A quick check on any result is the triangle inequality: the answer must be smaller than a + b and larger than the difference between a and b. With a = 3 and b = 4 that means c has to sit between 1 and 7, and the answer of 5 comfortably does.
Frequently asked questions
- What is the law of cosines formula?
- c = √(a² + b² − 2ab·cos C), where C is the angle between sides a and b.
- What is the third side when a = 3, b = 4, C = 90°?
- c = 5, because cos 90° = 0 and the formula reduces to √(3² + 4²).
- Does the law of cosines work for any triangle?
- Yes, it applies to all triangles. For a 90° angle it becomes the Pythagorean theorem.
- What units does the angle use?
- Enter the included angle C in degrees; it is converted to radians internally.
- When should I use the law of cosines instead of the law of sines?
- Use the law of cosines when you know two sides and the angle between them, or all three sides. The law of sines needs a known side paired with its opposite angle, so it cannot start from that information.