The law of cosines relates the three sides of any triangle to one of its angles: c2 = a2 + b2 − 2abcosC, where C is the angle across from side c. Use it to find the third side when you know two sides and the angle between them, or to find an angle when you know all three sides.
The law of cosines is the Pythagorean theorem with a correction for the angle. At 90° the correction is 0.
Formal definition and notation
In a triangle with sidesa, b, c opposite angles A, B, C: a2 = b2 + c2 − 2bccosA, b2 = a2 + c2 − 2accosB and c2 = a2 + b2 − 2abcosC. Solved for an angle, cosC = a2 + b2 − c22ab. When C = 90°, cosC = 0 and the law reduces to the Pythagorean theorem, so it generalizes that theorem to all triangles. It solves the SAS and SSS cases, where the law of sines cannot start.
It is the Pythagorean theorem plus a correction term, −2abcosC.
If C is obtuse, cosC is negative, so c2 is larger than a2 + b2.
If C is acute, cosC is positive, so c2 is smaller than a2 + b2.
Finding an angle with cos−1 never has an ambiguous case, because cosine is different for every angle from 0° to 180°.
In SSS, find the largest angle first (across from the longest side); then the law of sines can finish the job.
The angle in the formula must be the one between the two sides you square.
Law of cosines
Law of cosines
c2 = a2 + b2 − 2abcosC
a,b
the two sides that form angle C
C
the angle between them
c
the side across from C
For an angle from three sides: cosC = a2 + b2 − c22ab, then C = cos−1(…).
Law of Cosines examples, step by step
Example 1: Two sides and the included angle
Warm-up
In triangle ABC, a = 7, b = 9 and C = 60°. Find c to the nearest hundredth.
c2 = 72 + 92 − 2(7)(9)cos 60°.
cos 60° = 0.5, so c2 = 49 + 81 − 63 = 67.
c = √67 ≈ 8.19.
Answer:c = √67 ≈ 8.19.
Example 2: Three sides: find the largest angle
Core
A triangle has sides 5, 7 and 9. Find its largest angle to the nearest tenth of a degree.
The largest angle is across from the longest side, 9. Call it C.
cosC = 52 + 72 − 922(5)(7), which is 25 + 49 − 8170 = −770 = −0.1.
C = cos−1(−0.1) ≈ 95.7°. The negative cosine shows the angle is obtuse.
Answer: The largest angle is about 95.7 degrees.
Example 3: Two ships
Test-style
Two ships leave the same port. One sails 30 miles and the other 40 miles, and the angle between their paths is 110°. How far apart are they, to the nearest tenth of a mile?
The paths are two sides with the 110° angle between them (SAS).
d2 = 302 + 402 − 2(30)(40)cos 110°, so d2 = 2500 − 2400 cos 110°.
cos 110° ≈ −0.3420, so d2 ≈ 2500 + 820.8 = 3320.8.
d ≈ √3320.8 ≈ 57.6.
Answer: The ships are about 57.6 miles apart.
Common mistakes
✗ MistakeUsing an angle that is not between the two sides: with a = 7, b = 9, plugging in angle A.
✓ InsteadUse the angle formed by a and b, which is C: c2 = a2 + b2 − 2abcosC.
The formula needs the included angle, the one across from the side you are finding.
✗ MistakeSubtracting before multiplying: c2 = (49 + 81 − 126) cos 60° = 2.
a2 + b2 = c2 holds only for right triangles. The law of cosines works for all triangles and becomes the Pythagorean theorem when C = 90°.
Quick check: 3 questions
Question 1 of 3
Which facts call for the law of cosines?
Show answer and explanation
Answer: C. SAS (and SSS) have no known angle-side pair, so the law of cosines is needed. The first two cases suit the law of sines, and a right triangle only needs SOH CAH TOA.
Question 2 of 3
In a triangle, a = 3, b = 5 and C = 120°. What is c?
Show answer and explanation
Answer: B.c2 = 9 + 25 − 2(3)(5)cos 120°, which is 34 − 30(−0.5) = 49, so c = 7. √19 uses cos 120° = +0.5, √34 ignores the angle, and 8 just adds the sides.
Question 3 of 3
If C = 90°, what does c2 = a2 + b2 − 2abcosC become?
Show answer and explanation
Answer: D.cos 90° = 0, so the last term disappears and you get the Pythagorean theorem. The first choice uses cos 90° = 1, and the others drop the squares or change the sign.
Law of Cosines: frequently asked questions
When do you use the law of cosines instead of the law of sines?
Use the law of cosines when you know two sides and the angle between them (SAS) or all three sides (SSS). In those cases no angle is paired with its opposite side, so the law of sines has too many unknowns. After one use of the law of cosines, the law of sines can often finish the triangle.
How is the law of cosines related to the Pythagorean theorem?
It extends it. In c2 = a2 + b2 − 2abcosC, the extra term corrects for the angle. When C = 90°, cosC = 0, the term vanishes, and you get c2 = a2 + b2. For an obtuse angle the term adds length; for an acute angle it takes length away.
Updated November 2026·Reviewed by the Effortless Math team·Standards: CCSS HSG-SRT.D.10, CCSS HSG-SRT.D.11
Cite this entry
Effortless Math Team. “Law of Cosines.” Effortless Math Dictionary. Updated November 2026. https://www.effortlessmath.com/math-dictionary/law-of-cosines/
Flashcard
TermLaw of Cosinesc2 = a2 + b2 − 2abcosC
DefinitionFinds a side from SAS or an angle from SSS in any triangle. a = 3, b = 5, C = 120°: c2 = 34 + 15 = 49, so c = 7.
TriangleA triangle is a polygon with three sides and three angles. Its three corners are called vertices, and the angle measures in any triangle add to 180 degrees. Triangles are classified by their sides (equilateral, isosceles, scalene) and by their angles (acute, right, obtuse).Geometry · Grade 3, Grade 4, Grade 5SideA side is one of the straight line segments that form the outline of a polygon. Two sides meet at each corner, or vertex. A triangle has 3 sides and a square has 4, and adding the lengths of all the sides gives the perimeter.Geometry · Kindergarten, Grade 1, Grade 2Pythagorean TheoremThe Pythagorean theorem says that in a right triangle, a2 + b2 = c2. The legs are a and b, the two sides that form the right angle. The hypotenuse, c, is the longest side across from the right angle. Legs of 3 and 4 give 9 + 16 = 25, so the hypotenuse is 5.Geometry · Grade 8, Algebra 1Law of SinesThe law of sines says that in any triangle, each side divided by the sine of its opposite angle gives the same number: asinA = bsinB = csinC. Use it to solve triangles that have no right angle when you know two angles and a side, or two sides and an angle opposite one of them.Trigonometry · Geometry, Algebra 2, PrecalculusSquareA square is a quadrilateral with four equal sides and four right angles. It is a special rectangle and a special rhombus at the same time. For a square with side s, the perimeter is 4s, the area is s2, and each diagonal is s√2.Geometry · Kindergarten, Grade 2, Grade 3CosineCosine is the trigonometric ratio that compares the side adjacent to an angle with the hypotenuse of a right triangle: cos θ = adjacenthypotenuse. On the unit circle, cos θ is the x-coordinate of the point at angle θ. The cosine of an angle equals the sine of its complement.Trigonometry · Geometry, Algebra 2, PrecalculusDegreeA degree is the standard unit for measuring an angle, written with the symbol °. One degree is 1360 of a full turn, so a full turn is 360°, a straight angle is 180° and a right angle is 90°. An angle that turns through 25 one-degree angles measures 25°.Geometry · Grade 4, Grade 5, Grade 7MileA mile (mi) is a US customary unit of length for long distances, equal to 5,280 feet or 1,760 yards. One mile is about 1.61 kilometers, so it is longer than a kilometer. Road distances and speed limits in the United States use miles and miles per hour.Measurement · Grade 4, Grade 5, Grade 6Order of OperationsThe order of operations is the agreed sequence for evaluating an expression: parentheses first, then exponents, then multiplication and division from left to right, then addition and subtraction from left to right. Without it the same expression would have several answers. Many students remember it as PEMDAS.Algebra · Grade 5, Grade 6, Grade 7Square RootA square root of a number is a value that, multiplied by itself, gives that number. The square root of 36 is 6 because 6 × 6 = 36. Every positive number has two square roots, such as 6 and −6, but the radical sign √ means the principal square root, which is the non-negative one.Number System · Grade 8, Algebra 1Right TriangleA right triangle is a triangle with one right angle, an angle of exactly 90 degrees. The two sides that form the right angle are the legs, and the longest side, across from the right angle, is the hypotenuse. Its sides follow the Pythagorean theorem: a2 + b2 = c2.Geometry · Grade 4, Grade 6, Grade 8Obtuse AngleAn obtuse angle is an angle that measures more than 90 degrees and less than 180 degrees. It opens wider than a square corner but does not flatten into a straight line. Angles of 100, 135 and 179 degrees are obtuse. A triangle can have at most one obtuse angle.Geometry · Grade 4, Grade 5, Grade 7LengthLength is how long something is: the distance from one end of an object to the other. You measure it by counting equal units laid end to end with no gaps or overlaps, such as inches, feet, centimeters or meters. A new pencil is about 7 inches long.Measurement · Grade 1, Grade 2, Grade 3Acute AngleAn acute angle is an angle that measures more than 0 degrees and less than 90 degrees. It is narrower than the square corner of a page. Angles of 15, 45 and 89 degrees are all acute; 90 degrees is a right angle, so it is not acute. Every triangle has at least two acute angles.Geometry · Grade 4, Grade 5, Grade 7VectorA vector is a quantity that has both a size, called its magnitude, and a direction. It is drawn as an arrow from an initial point to a terminal point and written in components, such as v = ⟨ 4, 3 ⟩: 4 units right and 3 units up. Velocity and force are vectors; speed and mass are not.Trigonometry · PrecalculusSOH CAH TOASOH CAH TOA is a memory aid for the three basic trigonometric ratios in a right triangle: Sine is Opposite over Hypotenuse, Cosine is Adjacent over Hypotenuse, and Tangent is Opposite over Adjacent. Name the sides from the angle you are using, choose the ratio that links the sides you know and need, then solve.Trigonometry · Geometry, Algebra 2, PrecalculusTrigonometryTrigonometry is the branch of math that studies how the angles and the side lengths of triangles are related. Its three main ratios, sine, cosine and tangent, compare two sides of a right triangle. Knowing one side and one acute angle, or two sides, you can find every other side and angle without measuring them.Trigonometry · Geometry, Algebra 2, Precalculus