Skip to main content

Understand the Law of Cosines: Formula, Proof, and Uses

Most students assume trigonometry only works when there is a right angle in the triangle. That assumption leaves you stuck the moment a problem gives you a triangle with no 90° corner, which is most triangles you will encounter in real-world applications.

HelpcalculatePublished April 30, 2026Updated April 30, 202612 min read
Student solving triangle law of cosines problem
Student solving triangle law of cosines problem

The law of cosines solves that problem directly, handling everything from navigation routes to surveying land and even calculating the distance between clock hands. This article walks you through the formula, a clear geometric proof, when to use it versus the law of sines, real-world examples, and the mistakes that trip students up most often.

TL;DR

  • The law of cosines generalizes the Pythagorean theorem for all triangles, including obtuse and acute.
  • It is essential for solving for sides or angles when only partial triangle information is available.
  • Proper application involves correct angle selection, attention to cosine sign, and calculator mode.

Key Takeaways

PointDetails
Universal triangle solverThe law of cosines lets you solve any triangle, not just right triangles.
Unique solutionsIt provides clear, unique answers for SAS and SSS triangle cases without ambiguity.
Connects with PythagorasThis formula generalizes the Pythagorean theorem and expands your problem-solving power.
Real-world geometryMastering it helps in navigation, science, and practical measurement tasks.
Avoid common pitfallsAlways check your units and solve for the largest unknown angle first to prevent mistakes.

What is the law of cosines?

The law of cosines is a formula that relates the three sides of any triangle to one of its angles. It works for acute triangles, obtuse triangles, and even right triangles. Think of it as the Pythagorean theorem's more capable sibling: it handles every case, not just the 90° special case.

For any triangle with sides a, b, and c opposite to angles A, B, and C respectively, the law of cosines states:

a² = b² + c² - 2bc · cos(A)

b² = a² + c² - 2ac · cos(B)

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

Each version of the formula is just a cyclic rearrangement. You pick the version based on which side or angle you are solving for.

The connection to the Pythagorean theorem is direct. When angle A equals 90°, cos(90°) equals zero, so the term "2bc · cos(A)" drops out entirely. What remains is a² = b² + c², which is exactly the Pythagorean theorem. The law of cosines does not replace that theorem. It generalizes it.

Here is a quick reference table for the variables:

SymbolMeaningNotes
a, b, cSide lengthsAlways positive
A, B, COpposite anglesBetween 0° and 180°
cos(A)Cosine of angle ANegative if A is obtuse
Square of side aThe "unknown" in SAS problems

You can find more helpful explanations and worked examples across our math articles if you want to see other formula breakdowns alongside this one.

Visual proof: How and why the law of cosines works

Knowing the formula is useful. Understanding where it comes from makes it stick. Here is a geometric proof you can follow step by step, using only concepts you already know.

The proof works by dropping an altitude from one vertex of the triangle down to the opposite side, splitting the original triangle into two right triangles. Then you apply the Pythagorean theorem to each piece and substitute using the definition of cosine.

Step-by-step geometric proof
  1. Start with triangle ABC. Label side a opposite angle A, side b opposite angle B, and side c opposite angle C.
  2. Drop an altitude h from vertex B down to side b. Call the foot of that altitude point D. This splits the triangle into two right triangles.
  3. In the right triangle on the left, the horizontal segment from A to D has length x. By the definition of cosine, cos(A) = x / c, so x = c · cos(A).
  4. The remaining horizontal segment from D to C has length (b - x), or equivalently (b - c · cos(A)).
  5. Apply the Pythagorean theorem to the right triangle on the right: a² = h² + (b - c · cos(A))².
  6. Expand the squared term: a² = h² + b² - 2bc · cos(A) + c² · cos²(A).
  7. From the left right triangle, h² = c² - c² · cos²(A) = c²(1 - cos²(A)). Substitute this in.
  8. After simplification, the c² · cos²(A) terms cancel, leaving: a² = b² + c² - 2bc · cos(A).

That is the full formula, derived from scratch. The same logic applies when angle A is obtuse. In that case, point D falls outside the triangle, but the algebra works out identically because cos(obtuse angle) is negative, which adjusts the sign automatically.

Key insight: The law of cosines works for obtuse triangles because cosine naturally handles negative values. You do not need a separate formula for different triangle types.

Pro Tip: Always draw a labeled diagram before you start any triangle problem. Marking which sides and angles are known versus unknown takes about 30 seconds and prevents the most common setup errors.

If you want to practice the right triangle foundations that underpin this proof, the right triangle calculator at HelpCalculate.com lets you experiment with different side and angle combinations instantly.

Law of cosines vs. the law of sines: When and why to use each

You have got the logic and formula. But which law do you use when facing different triangle problems? The answer depends entirely on what information you are given at the start.

Use the law of cosines when you have:

  • Two sides and the included angle (SAS): for example, sides b and c with angle A between them.
  • All three sides (SSS): you want to find any or all angles.

Use the law of sines when you have:

  • Two angles and any side (AAS or ASA).
  • Two sides and a non-included angle (SSA), though this case can be tricky.

One major advantage the law of cosines has over the law of sines is certainty. There is no ambiguous case with the law of cosines. When you use it for SAS or SSS problems, arccos always returns a unique angle in the range [0°, 180°], so you always get exactly one answer. The law of sines in the SSA case can produce zero, one, or two valid triangles, which is why it is called the ambiguous case.

Here is a side-by-side comparison to keep things clear:

ScenarioGiven informationBest law to useAmbiguous?
SASTwo sides + included angleLaw of cosinesNo
SSSAll three sidesLaw of cosinesNo
AASTwo angles + one sideLaw of sinesNo
ASATwo angles + included sideLaw of sinesNo
SSATwo sides + non-included angleLaw of sinesYes, possibly
Visual comparison
Infographic comparing Law of Cosines and Law of Sines
Tips after you choose a law

For quick calculations and checking your setup before solving, the math calculators at HelpCalculate.com cover a wide range of triangle scenarios.

Pro Tip: When you are given all three sides (SSS), always solve for the largest angle first. The largest angle is opposite the longest side. Solving it first avoids potential rounding errors that can cascade through the remaining calculations.

Applications: Law of cosines in real problems and science

Once you know how and when to use the law of cosines, it is time to see it in action on real problems. These examples reflect the types of scenarios you will encounter in coursework and beyond.

Engineer using triangle measurements on a map
Example 1: Distance between clock hands

A classic problem: a clock has an hour hand 4 inches long and a minute hand 6 inches long. At 4:00, the angle between them is 120°. What is the distance between the tips?

Using the law of cosines: d² = 4² + 6² - 2(4)(6) · cos(120°).

cos(120°) = -0.5, so: d² = 16 + 36 - 48(-0.5) = 52 + 24 = 76.

Therefore d = √76 ≈ 8.72 inches.

Notice that because the angle is obtuse, cos(obtuse) is negative, which makes the side opposite to it longer than it would be in an acute triangle. That is a built-in check: if your obtuse triangle produces a short opposite side, something went wrong.

Example 2: Navigation and boat rescue

A coast guard station receives a distress call. A boat is 15 miles from Point A and 20 miles from Point B. The angle at the boat between the two points is 110°. How far apart are Points A and B?

d² = 15² + 20² - 2(15)(20) · cos(110°)

d² = 225 + 400 - 600(-0.342) = 625 + 205.2 = 830.2

d ≈ 28.8 miles

The law of cosines is essential for navigation, surveying, and any real-world situation where triangles do not have right angles. GPS systems, aircraft routing, and land surveying all rely on these calculations.

Quick reference: Common law of cosines scenarios
Problem typeWhat you knowWhat you find
Clock handsTwo arm lengths + angleDistance between tips
NavigationTwo distances + included angleDirect distance
SurveyingAll three boundary lengthsInterior angles of land plot
Physics vectorsTwo force magnitudes + angleResultant force magnitude
Solve any application problem systematically

Step-by-step approach for any application problem:

  1. Identify the triangle and label all known sides and angles.
  2. Confirm you have SAS or SSS information.
  3. Write the correct version of the law of cosines formula.
  4. Substitute known values carefully, paying attention to sign.
  5. Solve for the unknown, then verify: all angles must sum to 180°, all sides must be positive.

Use the right triangle calculator to verify sub-problems when you break complex figures into simpler components. For broader problem types, the math problem tools at HelpCalculate.com can help you cross-check your final answers.

Common mistakes and expert tips for using the law of cosines

Even with a powerful formula, small mistakes can lead you astray. Here is how top students stay accurate and confident.

The most frequent errors students make:

  • Wrong angle selection: Using angle B when the formula requires angle A (the angle between the two known sides in SAS). Always re-read the problem after labeling your diagram.
  • Sign errors with obtuse angles: Forgetting that cos(obtuse) is negative. If your answer seems too small for an obtuse triangle, check the cosine sign first.
  • Degrees vs. radians mismatch: Your calculator must be in the correct mode. A cosine calculated in radians when you meant degrees will give a completely wrong answer. Always verify your calculator mode before starting.
  • Skipping the square root: Solving for a² and forgetting to take the square root at the end. The formula gives you the square of the side, not the side itself.
  • Rounding too early: Rounding intermediate values before the final step introduces cumulative errors. Keep full decimal precision until the last calculation.

One critical numerical detail: always clamp cosine values to the range [-1, 1] before taking arccos. In real-world computations, floating-point arithmetic can produce values like 1.0000001 due to rounding, and arccos of any value outside [-1, 1] is undefined. This matters whether you are working by hand or writing code.

When solving SSS problems, compute the largest angle first (opposite the longest side). This strategy avoids a subtle problem: if you solve a smaller angle first and it is slightly off due to rounding, the error propagates when you subtract from 180° to find the remaining angles.

Pro Tip: Use online calculators to check your work, but always solve the problem by hand first. Checking a result you already computed builds genuine understanding. Jumping straight to a calculator means you are practicing button-pressing, not problem-solving.

For additional study strategies and worked examples, browse the homework strategies section at HelpCalculate.com.

Why mastering the law of cosines pays off beyond trigonometry class

Here is the perspective worth considering: most students treat the law of cosines as a formula to memorize for an exam, then forget. That approach misses the bigger lesson entirely.

What the law of cosines actually teaches you is how a simple idea, the Pythagorean theorem, can be extended to handle far more complex situations by adding one additional term. That pattern of thinking, taking something you know and asking "how does this generalize?", is exactly how engineers design structures, how physicists model forces, and how software developers write algorithms for 3D graphics and game engines.

Every time a game engine calculates the angle between two vectors, it uses a version of the law of cosines. Every time a structural engineer checks whether two beams form a safe angle under load, the same logic applies. The formula is not just a math class tool. It is a fundamental building block of applied science and technology.

Learning to see the law of cosines as a generalization of Pythagoras also trains you to recognize patterns across different formulas. That skill, spotting structural similarities between equations, is what separates students who merely pass exams from those who genuinely understand mathematics. It makes learning new formulas faster because you start recognizing families of ideas rather than isolated facts.

The advanced math strategies available at HelpCalculate.com can help you build this kind of connected mathematical thinking across multiple topics.

Take your trigonometry practice further: Interactive math tools

Ready to put what you have learned to the test? Practicing with real problems is the fastest way to move from understanding the law of cosines conceptually to applying it accurately under exam conditions.

HelpCalculate.com

HelpCalculate.com offers a full suite of free math calculators that let you input triangle values and instantly verify your results. These tools are designed for students who want to check their work, explore edge cases, and build confidence before a test. You can experiment with different side lengths and angles to see exactly how the formula behaves with acute, obtuse, and right triangles side by side. For a change of pace, the math practice games section offers interactive challenges that reinforce core skills in a more engaging format. Both resources are free and require no account to use.

FAQ

Where is the law of cosines used in real life?

The law of cosines is used in navigation, surveying, engineering, and any application requiring unknown sides or angles in non-right triangles, including GPS routing and structural analysis.

Does the law of cosines work for right triangles?

Yes. When the angle is 90°, cos(90°) equals zero, so the formula reduces exactly to the Pythagorean theorem, confirming it works for all triangle types.

What are the most common mistakes students make with the law of cosines?

The most frequent errors involve using the wrong angle, forgetting that cosine values must be clamped to [-1, 1] before taking arccos, and having the calculator set to the wrong angle mode (degrees vs. radians).

How is the law of cosines different from the law of sines?

The law of cosines is best for SAS and SSS cases and always gives a unique solution via arccos, while the law of sines fits AAS and ASA cases but can produce an ambiguous result in SSA scenarios.