Skip to content
MasterMath

Law of Cosines Calculator

Solve a triangle from two sides and the angle between them, or from all three sides. Unlike the law of sines, it never leaves you with two possible answers.

Result

—

Result—
Side c—
Angle A—
Angle B—
Angle C—
Type of triangle—

How this was worked out

    The formula

    c² = a² + b² − 2ab·cos C

    Where it comes from

    The law of cosines is the Pythagorean theorem with a correction term for triangles that are not right-angled. When C is 90° its cosine is zero, the correction vanishes and you are left with a² + b² = c² exactly.

    How to work it out by hand

    1. To find the third side: square the two known sides, add them, then subtract 2ab·cos C
    2. Take the square root
    3. To find an angle from three sides, rearrange for cos C and take the arccosine
    4. Check the three angles add to 180°

    What is worth knowing

    The absence of ambiguity is the practical advantage. Arccosine returns a unique angle between 0° and 180°, which covers every angle a triangle can have, so there is never a second candidate to weigh up. The sign of the correction term also tells you the shape at a glance: if c² is larger than a² + b², the angle C is obtuse; if smaller, acute; if equal, exactly right. That is the converse of Pythagoras stated in a usable form, and it is how surveying software classifies triangles without computing an angle at all.

    Frequently asked questions

    When should I use the law of cosines?

    When you know two sides and the angle between them, or all three sides. Both are cases the law of sines cannot start from.

    Why is there no ambiguous case?

    Because arccosine returns exactly one angle between 0° and 180°, which is the whole range a triangle angle can occupy.

    How does it relate to Pythagoras?

    It is Pythagoras plus a correction term. At 90° the cosine is zero and the correction disappears.

    How do I tell if a triangle is obtuse?

    Compare c² with a² + b² for the longest side c. Larger means obtuse, smaller means acute, equal means right-angled.