Law of Cosines

Finds unknown sides or angles in any triangle when you know two sides and the angle between them, or all three sides.

c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C

Solve a problem with Law of Cosines

Type the problem. The solver will use Law of Cosines where Law of Cosines is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Law of Cosines takes
aa
bb
cc
CC
Law of Cosines
SymbolMeaning
aaOne of the two sides that form angle C; must be a positive length. If misread as an angle or negative value, the formula fails to work correctly.
bbThe other side that forms angle C; must be a positive length. Misinterpreting it as an angle or using a negative value produces wrong results.
ccThe side opposite angle C; a positive length you are either solving for or checking. Confusion with an angle measure breaks the entire calculation.
CCThe angle between sides a and b, measured in degrees or radians (must match your unit system throughout); any value from 0° to 180°. Using the angle opposite to side c instead, or treating it as a length, yields completely wrong answers.

When to use it

Reach for the Law of Cosines when you have two sides and the angle between them (SAS), or all three sides (SSS).

Level

Usually taught in: Pre-Calculus · Appears on: ACT

Worked examples

1. Find a side using two sides and the included angle

Problem

Find side cc in triangle ABC where a=3a = 3, b=4b = 4, and C=60°C = 60°.
  1. c2=32+42234cos60c^2 = 3^2 + 4^2 - 2 \cdot 3 \cdot 4 \cdot \cos 60^\circ

    Substitute the known values into the Law of Cosines formula; C=60°C = 60° is the angle between sides aa and bb.

  2. c2=9+162412c^2 = 9 + 16 - 24 \cdot \frac{1}{2}

    Evaluate the squares and use cos60=12\cos 60^\circ = \frac{1}{2}.

  3. c2=9+1612=13c^2 = 9 + 16 - 12 = 13

    Simplify: multiply 2412=1224 \cdot \frac{1}{2} = 12, then subtract from 25.

  4. c=133.606c = \sqrt{13} \approx 3.606

    Take the positive square root (side lengths must be positive).

Answer: c=13c = \sqrt{13}

This is a side-angle-side (SAS) situation: you know two sides and the angle between them. The Law of Cosines is the direct tool to find the third side without needing intermediate angles.

2. Find an angle using all three sides

Problem

Find angle CC in triangle ABC where a=5a = 5, b=7b = 7, and c=6c = 6.
  1. c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C

    Write the Law of Cosines in standard form.

  2. 36=25+492(5)(7)cosC36 = 25 + 49 - 2(5)(7)\cos C

    Substitute the known side lengths: 62=366^2 = 36, 52=255^2 = 25, 72=497^2 = 49.

  3. 36=7470cosC36 = 74 - 70\cos C

    Simplify: 25+49=7425 + 49 = 74 and 257=702 \cdot 5 \cdot 7 = 70.

  4. 70cosC=3870\cos C = 38

    Rearrange to isolate the cosC\cos C term: move 36 to the right as 7436=3874 - 36 = 38.

  5. cosC=3870=1935\cos C = \frac{38}{70} = \frac{19}{35}

    Divide both sides by 70 and reduce the fraction.

  6. C=arccos(1935)57.1C = \arccos\left(\frac{19}{35}\right) \approx 57.1^\circ

    Apply inverse cosine to find the angle; since cosC>0\cos C > 0, we know CC is acute.

Answer: C=arccos(1935)C = \arccos\left(\frac{19}{35}\right)

When all three sides are known (SSS), rearrange the Law of Cosines to solve for cosine of the angle, then use inverse cosine to find the actual angle. This is the primary method for finding any angle in a triangle when all sides are given.

3. Find straight-line distance in a navigation problem

Problem

You drive 45 km due north from home, then turn and drive 30 km in a direction that makes a 65° angle from your northward heading. How far are you now from home?
  1. d2=452+3022(45)(30)cos65d^2 = 45^2 + 30^2 - 2(45)(30)\cos 65^\circ

    Your two driving legs form two sides of a triangle (45 km and 30 km), with a 65° angle between them at your starting point. You want the straight-line distance dd from start to finish.

  2. d2=2025+9002700cos65d^2 = 2025 + 900 - 2700 \cos 65^\circ

    Calculate the squares: 452=202545^2 = 2025 and 302=90030^2 = 900, and the coefficient: 24530=27002 \cdot 45 \cdot 30 = 2700.

  3. d2=29252700(0.4226)292511411784d^2 = 2925 - 2700(0.4226) \approx 2925 - 1141 \approx 1784

    Use cos650.4226\cos 65^\circ \approx 0.4226 from a calculator and subtract.

  4. d178442.2 kmd \approx \sqrt{1784} \approx 42.2 \text{ km}

    Take the positive square root; the answer is in kilometers.

Answer: d42.2 kmd \approx 42.2 \text{ km}

Navigation and real-world geometry problems often give you two distances traveled and the angle at which you changed direction. The Law of Cosines directly yields the displacement from your starting point, which is essential for finding how far away you are.

Common mistakes

Where Law of Cosines usually goes wrong
Answer came out wrong
Using the wrong angle: applying the formula with an angle that is not between the two known sides.
Always verify: the angle in your formula must be the angle between the two sides on the right side of the equation. Check your triangle diagram carefully.
Writing c2=a2+b2+2abcosCc^2 = a^2 + b^2 + 2ab\cos C instead of c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C (using a plus sign instead of minus).
Write the complete formula on paper before substituting: c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C. Seeing the full formula reduces the chance of using the wrong sign.
Using an angle in degrees when your calculator is in radian mode, or vice versa, without checking.
Before computing, confirm your calculator's mode (degree or radian) matches the angle units in your problem. Double-check this every time, as many errors trace back to this single mistake.
The mistakeWhy it is wrongThe fix
Using the wrong angle: applying the formula with an angle that is not between the two known sides.The angle CC in the formula c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C must be the angle at the vertex where sides aa and bb meet, not just any angle in the triangle.Always verify: the angle in your formula must be the angle between the two sides on the right side of the equation. Check your triangle diagram carefully.
Writing c2=a2+b2+2abcosCc^2 = a^2 + b^2 + 2ab\cos C instead of c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C (using a plus sign instead of minus).The formula has a minus sign, not a plus sign. A plus sign produces a completely wrong value and is a frequent algebra slip when substituting values quickly.Write the complete formula on paper before substituting: c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C. Seeing the full formula reduces the chance of using the wrong sign.
Using an angle in degrees when your calculator is in radian mode, or vice versa, without checking.Cosine depends critically on the angle unit: cos60=0.5\cos 60^\circ = 0.5, but cos60 rad0.3\cos 60 \text{ rad} \approx -0.3. Mixing units completely breaks the calculation.Before computing, confirm your calculator's mode (degree or radian) matches the angle units in your problem. Double-check this every time, as many errors trace back to this single mistake.

Tips and when to use something else

  • The Law of Cosines generalizes the Pythagorean Theorem: when C=90°C = 90°, we have cos90°=0\cos 90° = 0, so the formula reduces to c2=a2+b2c^2 = a^2 + b^2.
  • If you know two angles and one side (AAS or ASA), or two sides and an angle opposite one of them (SSA), use the Law of Sines instead—it is simpler and faster than Law of Cosines.
  • When solving for an angle by rearranging to cosC=a2+b2c22ab\cos C = \frac{a^2 + b^2 - c^2}{2ab}, use the inverse cosine function (arccos or cos1\cos^{-1}) on your calculator to find the angle.
  • Always verify that your angle result is between 0° and 180°180° (or 00 to π\pi radians). If arccos gives a value outside this range or an error, you have made an error in your setup or arithmetic.

Frequently asked questions

When should I use Law of Cosines instead of Law of Sines?
Use Law of Cosines when you have side-angle-side (SAS: two sides and the angle between them) or side-side-side (SSS: all three sides). Use Law of Sines when you have angle-angle-side (AAS or ASA) or side-side-angle (SSA) with a known angle. Law of Sines requires at least one known angle, while Law of Cosines works for SAS and SSS without needing any known angle.
Why does the Law of Cosines have a negative sign instead of a positive sign?
The negative sign accounts for how angle CC affects side cc. When CC is obtuse (greater than 90°90°), cosine is negative, which actually makes c2c^2 larger compared to if you just added the squares. When CC is acute (less than 90°90°), cosine is positive, which makes c2c^2 smaller. The minus sign is what captures this geometric relationship correctly.
What if I calculate a negative number under the square root when solving for a side?
A negative value under the square root means the given information describes an impossible triangle—the side lengths or angle do not form a valid triangle. Check that your sides obey the triangle inequality (the sum of any two sides must exceed the third) and that your angle is between 0° and 180°180°. If both are satisfied, you have an arithmetic error.
Does the order of the sides and angles matter in the Law of Cosines formula?
Yes. The formula c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C specifically pairs angle CC with the side cc opposite it. If you want to find side aa instead, write a2=b2+c22bccosAa^2 = b^2 + c^2 - 2bc\cos A. The structure stays identical, but each side must pair with its opposite angle. Mixing up which angle goes with which side is a common error.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18