Learn

Law of Cosines Calculator

A law of cosines calculator with three boxes: enter sides a and b plus the included angle C to get the third side c and both remaining angles instantly - the Pythagorean theorem that works for any triangle.

Type any triangle question - the AI fills the calculator and explains each step

How to use this law of cosines calculator

Three boxes, pre-filled with a = 10, b = 12, C = 30°. Click Calculate. This law of cosines calculator form takes the SAS setup: two sides and the angle between them. The law of cosines calculator is the SAS machine.

  • Side a and side b are the two known sides.
  • Angle C is the included angle, the one squeezed between sides a and b. In degrees.
  • Seven answers come back: the third side c, both remaining angles A and B, plus the perimeter, the area, and the two circle radii — the triangle is fully solved.

The law of cosines calculator keeps full precision, so 10, 12, and 30 return c ≈ 6.013, A ≈ 56.3°, B ≈ 93.7°.

This page is more than a static law of cosines calculator — it is also an AI tutor you can ask questions:

  • Ask in plain words. "Sides 5 and 9 with a 110° angle between them — find the third side." The AI fills the form and runs this law of cosines calculator for you.
  • Take a photo of your homework. The AI reads the triangle and fills the law of cosines calculator boxes for you.
  • Ask about the ideas, not just the answer. "Why does the 2ab cos C term shrink c?" The AI explains step by step — every number still comes from the law of cosines calculator, so nothing is guessed.
  • Keep asking follow-ups. Ask "why?" as often as you need — follow-up questions are welcome.
  • Three sides instead? That is the SSS case: the AI rearranges the same formula to hunt the angles with you.\n\nThe worked law of cosines examples below use the exact numbers this law of cosines calculator pre-fills, so you can follow along and check.

What a law of cosines calculator measures

The Pythagorean theorem has one blind spot: it only works when the angle is 90°. The law of cosines removes that restriction — it is the Pythagorean theorem generalized to every triangle, and this law of cosines calculator runs it. Compare the two:

  • Right angle: c2=a2+b2c^2 = a^2 + b^2
  • Any angle: c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos C

The new term 2abcosC-2ab\cos C is the correction for the tilt. Point the angle wide (C near 180°) and cos C approaches −1, so the correction adds and c stretches. Squeeze it narrow (C near 0°) and cos C approaches 1, so c shrinks toward the gap between the sides. Set C = 90° and cos 90° = 0: the correction vanishes and the law of cosines calculator becomes the Pythagorean theorem exactly.

ABCa = 10b = 12c = ?C = 30°
Law of cosines calculator in one picture: two sides a = 10 and b = 12 with the 30° angle between them — the formula pins the third side c ≈ 6.01 without ever dropping a perpendicular

The formulas this law of cosines calculator uses

Read the picture first: two sides pinned at the angle C, third side waiting. Now the symbols the law of cosines calculator uses:

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

FormulaMeaning
c2=a2+b22abcosCc^2 = a^2 + b^2 - 2ab\cos CSAS: two sides and the included angle give the third side
cosC=a2+b2c22ab\cos C = \dfrac{a^2 + b^2 - c^2}{2ab}SSS: three sides give any angle
A=arccosbacosCcA = \arccos\dfrac{b - a\cos C}{c}second angle, once c is known
B=180°ACB = 180\degree - A - Cthe third angle, by the angle sum

| P=a+b+cP = a + b + c | perimeter, once the third side lands || K=12absinCK = \frac{1}{2}ab\sin C | area from the two known sides and their angle || r=K/sr = K/s | inradius; s=P/2s = P/2 is the semi-perimeter — all four of these ride along in the law of cosines calculator || R=c/(2sinC)R = c/(2\sin C) | circumradius, the circle through all three vertices || Symbol | Meaning | |---|---| | aa, bb, cc | sides opposite angles AA, BB, CC | | CC | the included angle between sides aa and bb |

You knowYou use
Two sides + included angle (SAS)law of cosines
Three sides (SSS)law of cosines, rearranged
Two angles + any side (ASA/AAS)law of sines instead

Every number the law of cosines calculator returns is the first row plus two arccosines. Check any law of cosines calculator output by summing the three angles: they must total 180°. This is the law of cosines calculator's built-in lie detector.

Example 1 - SAS, the textbook classic

Give the law of cosines calculator its home-game: a = 10, b = 12, and the angle between them C = 30°.

  1. Third side: c2=100+1442(10)(12)cos30°=244207.85=36.15c^2 = 100 + 144 - 2(10)(12)\cos 30\degree = 244 - 207.85 = 36.15, so c6.013c \approx 6.013.
  2. Angle A: cosA=(b2+c2a2)/(2bc)=0.555\cos A = (b^2 + c^2 - a^2)/(2bc) = 0.555, so A56.3°A \approx 56.3\degree.
  3. Angle B: 1803056.3=93.7°180 - 30 - 56.3 = 93.7\degree.

These exact numbers come pre-loaded in the law of cosines calculator above — click Calculate and the law of cosines calculator confirms all three instantly.

Example 2 - SSS, finding an angle

Use the law of cosines to find angle measures when all three sides are known. A triangle has sides 20, 25, and 18; find the angle opposite the side 20.

  1. SSS case — rearrange: cosA=(b2+c2a2)/(2bc)\cos A = (b^2 + c^2 - a^2)/(2bc).
  2. \cos A = (625 + 324 - 400)/(2 \. 25 \. 18) = 549/900 = 0.61.
  3. A52.4°A \approx 52.4\degree.

Three sides lock the triangle with no ambiguity — every angle comes out unique. The law of cosines calculator form above covers SAS. For this law of cosines SSS situation, ask the AI to run the rearranged version step by step.

Example 3 - from 3-4-5 to sqrt(13)

Watch the correction term work with the law of cosines calculator: sides a = 3 and b = 4, first with C = 90°, then with C = 60°.

  1. Right angle: c2=9+1624cos90°=25c^2 = 9 + 16 - 24\cos 90\degree = 25, so c=5c = 5 — the classic 3-4-5 triangle.
  2. Narrower: c2=9+1624cos60°=2512=13c^2 = 9 + 16 - 24\cos 60\degree = 25 - 12 = 13, so c=133.61c = \sqrt{13} \approx 3.61.
  3. Smaller angle, smaller third side — the law of cosines calculator promised exactly this; the 2abcosC-2ab\cos C term pulled it in.

The law of cosines calculator shows the sweep live: keep 3 and 4 fixed, walk C from 90° down to 60°. Watch the law of cosines calculator's side c shrink from 5 to 3.61.

Four Common Law of Cosines Mistakes

Four slips the law of cosines calculator catches every day:

  1. Using an angle that is not the included one. The formula wants the angle squeezed between the two known sides. Given angles A or B instead of C? That is a different setup — ask the AI on this law of cosines calculator page which law fits.
  2. Dropping the minus sign. The correction is 2abcosC-2ab\cos C. Write +2abcosC+2ab\cos C and every answer comes out wrong in the same subtle direction.
  3. Feeding radians where degrees belong. The law of cosines calculator takes degrees in the angle box. Feed this law of cosines calculator 30, never 0.52.
  4. Bringing an SSA problem here. Two sides and a non-included angle is the law of sines' ambiguous case — it can give two triangles. That case never reaches a law of cosines calculator: the law of cosines calculator's SAS setup is single-answer by design.
Problem 1

Two paths leave a trailhead at a 50° angle. One is 7 km long, the other 10 km. How far apart are their endpoints, to two decimals? Check your answer with the law of cosines calculator above.

00:00
Page 1
Problem 2

A triangular lot has sides 8, 11, and 13. Find the angle opposite the side of length 13, to one decimal. Check your setup with the law of cosines calculator page AI.

00:00
Page 1

Frequently asked questions

1

When do I use the law of cosines calculator instead of the law of sines?

Cosines for SAS (two sides plus the angle between them) and SSS (three sides). Sines for ASA, AAS, and SSA. Quick test: an angle squeezed between two sides means the law of cosines calculator is the right tool.

2

Where can I find a law of cosines proof?

One line of coordinates does it. Put C at the origin, B at (a, 0), and A at (b·cos C, b·sin C). Then c² = (a − b·cos C)² + (b·sin C)² = a² + b² − 2ab·cos C. That is the whole law of cosines proof — and the same cos law proof in words: the third side is the Pythagorean distance between the two far endpoints.

3

Can this law of cosines calculator handle three sides (SSS)?

The form is SAS. For the law of cosines SSS arrangement, rearrange to cos C = (a² + b² − c²)/(2ab) and take arccos. Or ask the AI on this page: it runs the same law of cosines calculator engine on your three sides.

4

Why is there a minus sign in c² = a² + b² − 2ab·cos C?

The angle tilts side b away from side a, so they overlap less. The overlap is exactly ab·cos C counted twice — the term removes it. At C = 90° nothing overlaps and the term is zero — the law of cosines calculator shows this instantly.

5

Degrees or radians in the law of cosines calculator?

Degrees. Type 30 for thirty degrees, not 0.52. The law of cosines calculator converts to radians internally before the law of cosines calculator computes the cosine.

6

How is the law of cosines related to the Pythagorean theorem?

It is the generalization. Set C = 90° in the law of cosines calculator: cos 90° = 0, the correction dies, and c² = a² + b² drops out. A right triangle gives the law of cosines calculator nothing but Pythagorean answers.

7

Does the law of cosines have an ambiguous case like the sines rule?

No. SAS and SSS each determine exactly one triangle, so every law of cosines calculator run is unique. The two-triangle ambiguity only lives in the sines rule's SSA case.

Related practice