Skip to content
Calixo

Law of Cosines Calculator for Triangles

Find a triangle's third side from two sides and the included angle — the Law of Cosines, generalizing the Pythagorean theorem to any triangle.

Inputs

°
°

The angle between sides a and b.

Paste this into any page — the widget stays live and updates automatically as this calculator improves. Using WordPress or Notion? See the embed guide.

Saved Scenarios

— select 2+ to compare
Inputs updated · Results recalculated · Just now

Side c

7.0714

Spark says

How it's calculated
A person writes mathematical equations by hand on grid paper using a pencil, promoting learning.
Photo by www.kaboompics.com on Pexels
Close-up of complex equations on a chalkboard, showcasing chemistry and math symbols.
Photo by Vitaly Gariev on Pexels

Formula

c2=a2+b22abcos(C)c^2 = a^2 + b^2 - 2ab\cos(C)
C
— The angle included between sides a and b — the angle opposite the side being found

What is the Law of Cosines Calculator for Triangles?

This calculator finds a triangle's third side using the Law of Cosines, given two sides and the angle between them — working for any triangle, not just right triangles.

Use this when finding a triangle's third side from two sides and the included angle for coursework or a surveying/navigation problem, checking a manually worked Law of Cosines calculation, or solving a triangle that isn't a right triangle, where the Pythagorean theorem alone doesn't apply.

How to use it

  1. 1 Enter the two known side lengths, a and b.
  2. 2 Enter the angle C between those two sides, in degrees.
  3. 3 Read the resulting third side, c.

Understanding Law of Cosines Calculator for Triangles

The Law of Cosines is genuinely best understood as a direct generalization of the Pythagorean theorem, extending that famous right-triangle-only relationship to work for any triangle at all — and seeing exactly how the extra term appears, and why it vanishes precisely in the right-triangle case, clarifies why the two formulas are so closely related rather than being separate, unrelated facts to memorize independently.

The Law of Cosines states c² = a² + b² - 2ab·cos(C), where C is the angle included between sides a and b, and c is the side opposite that angle. Compare this directly to the Pythagorean theorem's a² + b² = c² — the Law of Cosines is identical, with one additional term: -2ab·cos(C). This extra term is exactly what accounts for the included angle not necessarily being a right angle. When C is exactly 90°, cos(90°) equals exactly zero, making that entire extra term vanish, and the Law of Cosines collapses precisely into the ordinary Pythagorean theorem — not an approximation or a coincidental match, but an exact, guaranteed reduction, confirming the Law of Cosines is genuinely the more general relationship, with the Pythagorean theorem as its special case.

Understanding what happens for angles other than 90° reveals why the correction term has the specific sign and behavior it does. For an acute included angle (less than 90°), cosine is positive, making the -2ab·cos(C) term subtract from a²+b² — meaning the resulting side c comes out shorter than the Pythagorean-theorem prediction would give for the same a and b, which makes geometric sense: a triangle 'pinched' at a sharper-than-90° angle has its opposite side pulled in shorter than the right-angle case. For an obtuse included angle (greater than 90°), cosine is negative, making that same term effectively add to a²+b² instead — the opposite side stretches out longer than the right-angle case would predict, again matching the geometric intuition that a wider, more 'open' included angle pushes the opposite side further away.

The Law of Cosines is one of two classical tools (alongside the Law of Sines) that together let you solve for any missing side or angle in any triangle, given enough known information — collectively called 'solving a triangle.' The Law of Cosines specifically handles two genuinely important cases: finding a third side given two sides and their included angle (exactly what this calculator does), and finding any angle given all three sides (a related rearrangement of the same formula, solving for cos(C) instead of c directly). The Law of Sines, by contrast, is generally the more convenient tool when you know a side and its opposite angle together with one other piece of information — the two laws complement each other, covering different starting-information scenarios rather than being redundant alternatives.

Practically, the Law of Cosines shows up constantly in navigation, surveying, and engineering contexts specifically because real-world triangular measurement problems very often don't hand you a convenient right angle to work with. A surveyor measuring two known distances from a fixed point to two separate landmarks, along with the angle between those two sightlines (measured directly with an instrument), can find the direct distance between the two landmarks using exactly this formula, without needing either landmark to be positioned at a right angle from the surveyor's position — a genuinely common, practical scenario the Pythagorean theorem alone simply couldn't handle, precisely because most real-world triangular measurement setups aren't conveniently right triangles to begin with.

Worked examples

Advantages

  • Works for any triangle, not just right triangles — a genuine generalization of the Pythagorean theorem.
  • Correctly reduces to the ordinary Pythagorean theorem exactly when the included angle is 90°, a useful built-in consistency check.
  • Handles any valid angle between 0° and 180°, covering both acute and obtuse triangles.
  • Simple, direct calculation once the angle is correctly identified as the one between the two known sides.

Limitations

  • Requires the included angle specifically — the angle between the two known sides, not a different angle elsewhere in the triangle.

Common mistakes

  • ⚠️ Using an angle that isn't the one between the two known sides — the Law of Cosines specifically requires the included angle (opposite the side being solved for), not any of the triangle's other two angles.
  • ⚠️ Entering the angle in radians when the calculator expects degrees, or vice versa — always double-check which unit a specific tool expects before entering an angle value.
  • ⚠️ Forgetting that this formula solves for the side opposite the given angle — a common mix-up is trying to use it to find a different, non-opposite side without adjusting which values go where.

Tips

  • 💡 Does this work for right triangles too? Yes — with a 90° included angle, cos(90°) = 0, and the formula reduces exactly to the Pythagorean theorem's a² + b² = c², confirming the Law of Cosines is a genuine generalization, not a separate unrelated formula.
  • 💡 Double-check that the angle you're entering is genuinely the one between the two known sides (the included angle), not one of the triangle's other angles.
  • 💡 For a triangle where you know all three sides but need an angle instead, the Law of Cosines can be rearranged to solve for the angle — this calculator specifically solves for a side, given two sides and the included angle.
  • 💡 An included angle close to 180° describes a very 'flat,' nearly straight-line triangle, while an angle close to 0° describes a very 'thin' triangle — useful intuition for sanity-checking whether a result looks reasonable.

Real-life uses

  • Finding a triangle's third side from two sides and the included angle for coursework or a surveying/navigation problem
  • Checking a manually worked Law of Cosines calculation
  • Solving a triangle that isn't a right triangle, where the Pythagorean theorem doesn't directly apply
  • Navigation and surveying problems involving two known distances and a measured angle between them

Frequently asked questions

Does this work for right triangles too?

Yes — with a 90° included angle, cos(90°) = 0, and the formula reduces exactly to the Pythagorean theorem's a² + b² = c², confirming the Law of Cosines is a genuine generalization, not a separate unrelated formula.

What is the 'included angle'?

It's the angle between the two known sides (a and b) — the Law of Cosines specifically requires this angle, not any of the triangle's other two angles.

Can this find an angle instead of a side?

The same formula rearranges to solve for an angle given all three sides — this specific calculator solves for a side given two sides and the included angle, the more common starting scenario.

How is this different from the Law of Sines?

The Law of Cosines suits problems with two sides and an included angle, or all three sides; the Law of Sines suits problems involving a side and its opposite angle — the two laws complement each other for different starting information.

Why does an obtuse angle make the third side longer?

For an obtuse included angle, cosine is negative, which flips the correction term to effectively add to a²+b² rather than subtract — geometrically, a wider included angle pushes the opposite side further away.