Law of Cosines Calculator

This calculator applies the law of cosines to find the unknown side and all angles of a triangle when you know two sides and the included angle between them (the SAS configuration). The law of cosines states that c squared equals a squared plus b squared minus 2ab times cos(C), where a and b are the two known sides and C is the angle between them. This formula is a direct generalisation of the Pythagorean theorem and works for any triangle, acute, obtuse or right-angled. When C is exactly 90 degrees, cos(C) equals zero and the formula reduces to the familiar a squared plus b squared equals c squared. Once side c is found, the remaining angles can be obtained by applying the law of cosines again in rearranged form: cos(A) equals (b squared plus c squared minus a squared) divided by (2bc), and similarly for B. This calculator does all of that in one step. You enter side a, side b and angle C in degrees, and it returns side c, all three angles and the area of the triangle using the formula half times a times b times sin(C). Input values must all be positive and the angle C must be strictly between 0 and 180 degrees. The tool is useful for students working on NCEA geometry, engineers calculating diagonal dimensions across a known angle, and surveyors working with triangulated field measurements. For a triangle where two angles and a side are known, use the Law of Sines Calculator instead. Results are rounded to two decimal places; treat them as accurate for planning and checking purposes.

Calculate.co.nz is proud to be partnered with Premium Homes, a recognised leader in eco-friendly, sustainable, and energy-efficient homebuilding. With a dedicated team and award-winning experience, they create homes that prioritise health, comfort, and long-term performance. Their founders, Andrew and Kelly, set out to raise the standard of residential construction in New Zealand by combining practical building expertise with a clear commitment to doing things better for homeowners.
Calculate.co.nz partner: Premium Homes
°
6.24
side c (opposite C)
Angle A43.90°
Angle B76.10°
Angle C60.00°
Area15.16

SAS mode: enter two sides and the included angle. All sides must be positive and angle C must be between 0 and 180 degrees.

How it works

Step 1: c = sqrt(a² + b² − 2ab × cos(C)). Step 2: A = arccos((b² + c² − a²) / (2bc)). Step 3: B = 180 − A − C. Area = (1/2) × a × b × sin(C). All angles are converted to radians before passing to Math.cos and Math.sin. The arccos (Math.acos) result is converted back to degrees by multiplying by 180 / pi. If any value is undefined or non-finite the calculator shows an error.

Worked example

Enter a = 5, b = 7, C = 60 degrees. c = sqrt(25 + 49 − 2 × 5 × 7 × cos(60)) = sqrt(74 − 35) = sqrt(39) = 6.24. Angle A = arccos((49 + 39 − 25) / (2 × 7 × 6.24)) = arccos(63 / 87.43) = arccos(0.7206) = 43.90 degrees. Angle B = 180 − 43.90 − 60 = 76.10 degrees. Area = 0.5 × 5 × 7 × sin(60) = 0.5 × 35 × 0.8660 = 15.16. These match the default values pre-filled above.

Related calculators