Updated · Built and checked by the PlinzoTools team, formulas tested against published sources
Solve for a triangle's third side from two sides and the included angle.
5.0000
The Law of Cosines generalizes the Pythagorean theorem to any triangle, not just right triangles. This tool solves for the third side given two sides and the angle between them.
Enter two sides and the included angle (between them). The third side is calculated instantly.
c² = a² + b² - 2ab·cos(C)
The Law of Cosines calculator covers the case that surveyors and textbooks call side-angle-side, or SAS: you know two sides and the angle that sits between them, and you want the third side. It takes three inputs, side a, side b and the included angle C in degrees, and returns side c to four decimal places. The angle must be greater than 0 and less than 180 degrees, and both sides must be greater than zero. If any input falls outside those ranges the result area stays empty and prompts you to enter valid values, rather than showing a misleading number.
Notice what the tool does not do. It does not accept an angle in radians, it does not solve for the other two angles, and it does not handle the case where you know two sides and an angle that is not between them. That last situation (side-side-angle) is a different problem with its own quirks, because it can have zero, one or two valid triangles.
Suppose two straight fence sections of 5 metres and 7 metres meet at a corner, and the angle between them is 60 degrees. You want to know the distance across the open side, from the far end of one section to the far end of the other.
c² = 5² + 7² - 2 × 5 × 7 × cos(60°) = 25 + 49 - 70 × 0.5 = 39, so c = 6.2450
Now widen the same corner to 120 degrees. The cosine becomes negative (-0.5), so the last term adds instead of subtracts: 25 + 49 + 35 = 109, and c = 10.4403. A wider opening pushes the two free ends farther apart, exactly as you would expect physically. At 90 degrees the cosine term vanishes and you recover the Pythagorean result, which is a handy sanity check on any answer.
Three quick checks catch most input mistakes. First, the answer can never be larger than the sum of the two given sides, and never smaller than the absolute difference between them. With sides of 5 and 7, any valid c lies between 2 and 12. Second, if the included angle is less than 90 degrees, c comes out shorter than the hypotenuse you would get from a right angle; if it is more than 90 degrees, c comes out longer. Third, when the two sides are equal and the angle is small, c is small too. Two sides of 10 with a 10 degree angle give about 1.7431, which matches the isosceles shortcut of twice the side times the sine of half the angle.
Once you have c from this tool, you can rearrange the same law to find an angle. The angle opposite side a satisfies cos(A) = (b² + c² - a²) / (2bc). Take the inverse cosine of that ratio on a scientific calculator and you have A; the last angle is 180 minus the other two. This is the standard way to fully solve an SAS triangle, and it is useful in land measurement, roof framing, robotics arm geometry and any situation where you can measure two lengths and one turn but not the closing distance directly.
The calculation assumes a flat, planar triangle. For long distances on the Earth's surface, curvature matters and spherical formulas are used instead. For everyday drawings, workshop layouts and homework problems, the planar law is exact; the only error comes from the precision of your measurements and the four-decimal display.
When the included angle C is 90°, cos(90°) = 0, and the formula reduces exactly to the Pythagorean theorem (c² = a² + b²).
The angle formed between the two given sides -- not an angle opposite either of them.
The calculator treats those as invalid because the two sides would lie on the same straight line and no true triangle exists. The result stays empty until the angle is strictly between 0 and 180.
Not directly, since the tool outputs only side c. You can rearrange the law by hand as cos(A) = (b squared + c squared - a squared) divided by 2bc, using the c this tool gives you.
No. The formula is symmetric in a and b, so swapping them gives the identical result for c.
The tool displays four decimals and uses full floating-point precision internally. A textbook that rounds the cosine to two or three digits before multiplying can differ in the third or fourth decimal place.
Reference: NIST Weights and Measures