Skip to content
    Trigonometry

    Cosine Rule Calculator: Solve Triangles Using the Law of Cosines

    You already know Pythagoras: a² + b² = c². But what if the triangle has no right angle? The cosine rule is Pythagoras with a correction term that works for every triangle. In this guide you'll learn the formula, how to find a side or an angle with it, and the sign mistake that catches almost everyone.

    Math Solver Academic Editorial Board7 min read

    Key takeaways

    • The cosine rule is c² = a² + b² − 2ab × cos(C).
    • Use it when you know two sides and the angle between them (SAS), or all three sides (SSS).
    • To find an angle, rearrange to cos(C) = (a² + b² − c²) ÷ 2ab.
    • When C = 90°, cos(C) = 0 and the rule becomes Pythagoras.
    • For obtuse angles cos(C) is negative, so the third side gets longer.
    In this guide
    1. 01What is the cosine rule?
    2. 02Why does the cosine rule matter?
    3. 03The formula
    4. 04How to use the cosine rule step by step
    5. 05Common mistakes to avoid
    6. 06Tips and tricks
    7. 07Where you'll use it in real life
    8. 08Quick summary
    9. 09Frequently asked questions

    What is the cosine rule?

    The cosine rule, also called the Law of Cosines, connects all three sides of a triangle with one of its angles. It works in every triangle: acute, right-angled or obtuse.

    Think of it as a smarter Pythagorean theorem. Pythagoras only works when the angle is exactly 90°. The cosine rule adds a correction, −2ab × cos(C), that adjusts for any angle.

    Why does the cosine rule matter?

    The sine rule needs a side and its opposite angle to get started. Very often you don't have that pair. If you know two sides and the angle between them, or all three sides, the cosine rule is the only direct way in.

    Pythagoras is the special case. The cosine rule is the full story for every triangle.

    The formula

    c² = a² + b² − 2ab × cos(C)
    SymbolWhat it meansExample
    cThe side opposite angle C (the one you find)6.24 m
    a, bThe two sides that meet at angle C5 m, 7 m
    CThe angle between a and b, in degrees60°
    cos(C)Cosine of the angle, from your calculatorcos(60°) = 0.5

    To find an angle when you know all three sides, rearrange it:

    cos(C) = (a² + b² − c²) ÷ 2ab

    How the angle changes the answer

    Angle Ccos(C)Effect on c
    Less than 90°positivec is shorter than in a right triangle
    Exactly 90°0c² = a² + b² (Pythagoras)
    More than 90°negativec is longer than in a right triangle

    How to use the cosine rule step by step

    1. 1Label the triangle. Call the unknown side c and the angle opposite it C. The other two sides are a and b.
    2. 2Square the two known sides and add them: a² + b².
    3. 3Work out `2ab × cos(C)` with your calculator in degree mode.
    4. 4Subtract to get c².
    5. 5Take the square root to get c.

    Try it yourself. Enter two sides and the angle between them in the calculator below to find the third side with every step shown.

    Try it yourself

    Pre-filled with the example — change any value.

    🧮
    Trigonometry
    High School

    Cosine Rule

    Find the length of a side using the cosine rule

    c² = a² + b² - 2ab cos(C)

    xy(0.7, 0.7)
    cos: 0.71
    sin: 0.71
    tan: 1.0
    m
    120
    m
    121
    degrees
    1180

    💡 Example

    Reference
    Inputs:a=5, b=7, C=60
    Result:6.24 m
    Open the full Cosine Rule calculator

    Finding an angle (SSS)

    For a triangle with sides 5, 6 and 7, the largest angle is opposite the side of 7. So cos(C) = (25 + 36 − 49) ÷ (2 × 5 × 6) = 12 ÷ 60 = 0.2, and C = cos⁻¹(0.2) ≈ 78.46°. You can check inverse values with the inverse trig calculator.

    Common mistakes to avoid

    • Using an angle that is not between a and b. The cosine rule needs the included angle.
    • Radian mode. cos(60) in radians is about −0.95, which gives a wrong side. Use degree mode.
    • Forgetting the square root. The formula gives c², not c.
    • Mixing signs with obtuse angles. With C = 120°, cos(C) = −0.5, so −2ab × cos(C) becomes a plus. For a = 5, b = 7: c² = 74 + 35 = 109, so c ≈ 10.44.

    Tips and tricks

    • Find the largest angle first in an SSS problem. It is opposite the longest side, and it is the only angle that can be obtuse.
    • Sanity check: c must be shorter than a + b and longer than the difference between a and b.
    • Right angle? Use the simpler Pythagorean theorem calculator. The law of cosines calculator gives the same results as this one.

    Where you'll use it in real life

    • Navigation: a ship sails 5 km, turns, and sails 7 km. The cosine rule gives its distance from the start.
    • Surveying: finding the length across a field from two measured sides and the angle between them.
    • Engineering: finding the length of a support beam in a roof or bridge.
    • Sport: the distance between two players on a pitch from their distances and angle to a third point.

    Quick summary

    Use the cosine rule c² = a² + b² − 2ab × cos(C) when you know two sides and the angle between them, or rearrange it to find an angle when you know all three sides. Work out 2ab × cos(C) before subtracting, keep your calculator in degrees, and take the square root at the end. The calculator above shows every step.

    Frequently asked questions

    Can I use the cosine rule for right triangles?

    Yes. When the angle is 90°, cos(90°) = 0, so the rule becomes the Pythagorean theorem c² = a² + b². Pythagoras is simply quicker.

    How do I find an angle using the cosine rule?

    Rearrange it to cos(C) = (a² + b² − c²) ÷ 2ab, work out the right side, then use inverse cosine (cos⁻¹) to get angle C.

    When should I use the cosine rule instead of the sine rule?

    Use the cosine rule when you know two sides and the angle between them, or all three sides. In those cases you do not have a side with its opposite angle, which the sine rule needs.

    Why did I get a negative number under the square root?

    Usually the brackets were wrong: work out 2ab × cos(C) first, then subtract it from a² + b². Also check your calculator is in degree mode.

    #cosine rule#trigonometry#triangles#law of cosines#calculator
    Updated

    Keep reading

    Sponsored ToolsAd

    More tools on Ytools →
    Calcu.click — 25+ Free Smart Calculators preview

    Calcu.click — 25+ Free Smart Calculators

    Brand new calculation platform with 0ms reactive math, 100% client-side privacy, and dedicated subdomains. Fast calculators for EMI, SIP, Mortgage, Income Tax, BMI, Age, Percentage, and more.

    25+ CalculatorsFinanceHealth0ms Real-TimeFree
    Keyboard Arena preview

    Keyboard Arena

    Master touch typing with real-time WPM speed tests, mechanical switch audio, A-Z finger biomechanics drills, 40+ structured lessons, and competitive arcade games.

    Typing TestWPMTouch Typing
    Flutter Log Explorer preview

    Flutter Log Explorer

    Real-time structured log viewer and search explorer for Flutter & Dart. Zero-config capture from Debug Adapter (DAP) & Dart VM Service with smart classification and filters.

    FlutterDartVS Code ExtensionOpen VSX