About this calculator
The Law of Cosines Calculator applies the cosine rule to find a missing side from two sides and the included angle, or an angle from three known sides. It is useful for non-right triangles where Pythagoras does not apply.
law of cosines calculator method
The cosine rule generalises Pythagoras. For side c, the formula is c^2 = a^2 + b^2 - 2ab cos(C). Rearranged, it can also find angle C when all three sides are known.
- c^2 = a^2 + b^2 - 2ab cos(C)
- c = sqrt(a^2 + b^2 - 2ab cos(C))
- cos(C) = (a^2 + b^2 - c^2) / 2ab
- C = cos^-1((a^2 + b^2 - c^2) / 2ab)
How to use the law of cosines calculator
- Choose whether to find a side or an angle.
- For side mode, enter sides a and b plus included angle C.
- For angle mode, enter sides a, b, and c.
- Substitute values into the cosine rule.
- Take the square root for a side, or inverse cosine for an angle.
- Calculate remaining angles and area for context.
Worked examples
Find side c
Input: a = 5, b = 7, C = 60 degrees
Calculation: c = sqrt(5^2 + 7^2 - 2 x 5 x 7 x cos(60))
Result: c about 6.24
Find angle C
Input: a = 5, b = 7, c = 6
Calculation: C = cos^-1((5^2 + 7^2 - 6^2) / (2 x 5 x 7))
Result: C about 55.15 degrees
Cosine rule vs Pythagoras
If C is 90 degrees, cos(C) is zero and the cosine rule becomes a^2 + b^2 = c^2. That is why Pythagoras is a special case of the cosine rule.
Common mistakes to avoid
- Using the wrong side label
- Triangle formulas depend on matching sides with their opposite angles or with the correct right-triangle role. If a result looks impossible, recheck the labels before changing the formula.
- Forgetting triangle validity
- Not every set of side lengths can form a triangle. The longest side must be shorter than the sum of the other two sides.
- Rounding too early
- Keep extra decimal places while calculating, especially when using square roots, sine, cosine, or inverse trig. Round the final answer to the precision required.
Edge cases
- A right triangle must have one angle of exactly 90 degrees.
- The hypotenuse must be the longest side in a right triangle.
- Special triangle ratios only apply to exact 30-60-90 and 45-45-90 triangles.
- The sine rule can produce an ambiguous SSA case where two triangles are possible.
Limitations
This calculator is for educational maths support. It uses standard geometry and trigonometry formulas with decimal approximations. For exams, coursework, engineering, surveying, or construction, follow the required method, units, tolerances, and checking process.
Frequently asked questions
Which triangle calculator should I use?
Use Pythagoras or the right triangle calculator for right-angled triangles, special triangle calculators for exact 30-60-90 or 45-45-90 triangles, and the sine or cosine law calculators for non-right triangles.
What do sides a, b, and c mean?
In general triangle notation, side a is opposite angle A, side b is opposite angle B, and side c is opposite angle C. Some right-triangle pages also label c as the hypotenuse.
Why do triangle angles add to 180 degrees?
In ordinary flat Euclidean geometry, the interior angles of a triangle always add to 180 degrees. That rule is used throughout these calculators.
Can the calculator handle any units?
Yes for lengths, as long as all side inputs use the same unit. Area results are in square units based on the unit entered.
Why is my result impossible?
The inputs may not form a valid triangle, the hypotenuse may not be the longest side, or a side may have been paired with the wrong angle.
Related calculators
- Law of Sines Calculator
- Triangle Calculator
- Trigonometry Calculator