What Is the Law of Cosines?
The law of cosines (also called the cosine rule) generalises the Pythagorean theorem to any triangle. It links the three side lengths to the cosine of one of the angles, so it works even when the triangle has no right angle. This calculator uses it in the common "SAS" case: you supply two sides and the angle wedged between them, and it returns the missing side along with the other two angles, the perimeter, and the area.
How to Use It
Enter side a, side b, and the included angle C in degrees (the angle that sits between sides a and b). Press calculate. The tool first finds the third side c, then uses the rearranged cosine rule to compute angles A and B. Because the three angles always add to 180°, you can quickly sanity-check the output.
The Formula Explained
To find the side opposite the known angle: $$c^{2} = a^{2} + b^{2} - 2ab\cos(C)$$ Notice that when \(C = 90^\circ\), \(\cos(C) = 0\) and the expression collapses to the familiar \(c^{2} = a^{2} + b^{2}\). To work backwards from three known sides to an angle, rearrange to $$C = \cos^{-1}\!\left(\frac{a^{2} + b^{2} - c^{2}}{2ab}\right)$$ The triangle area is computed as \(\tfrac{1}{2}\cdot a\cdot b\cdot\sin(C)\).
Worked Example
Let \(a = 5\), \(b = 7\), and \(C = 60^\circ\). Then $$c^{2} = 25 + 49 - 2\cdot 5\cdot 7\cdot\cos(60^\circ) = 74 - 70\cdot 0.5 = 39$$ so \(c = \sqrt{39} \approx 6.245\). Angle $$A = \cos^{-1}\!\left(\frac{49 + 39 - 25}{2\cdot 7\cdot 6.245}\right) \approx 43.9^\circ$$ and angle \(B \approx 76.1^\circ\). The three angles \(43.9 + 76.1 + 60 = 180^\circ\) ✓. \(\text{Area} = \tfrac{1}{2}\cdot 5\cdot 7\cdot\sin(60^\circ) \approx 15.16\).
FAQ
What if I only know three sides? Use the second formula to find any angle directly from the side lengths.
Does this work for obtuse triangles? Yes. The cosine of an angle above 90° is negative, which the formula handles automatically.
What units does it use? Sides are unit-free (use any consistent unit), and angles are entered and returned in degrees.