Law of cosines calculator

Type sides a and b and the angle γ between them, in degrees. The calculator finds the third side c. With 3, 4 and 90° you get 5. That is the same 3-4-5 as Pythagoras.

γ is the angle between a and b, not an angle opposite c under another label. 5, 5 and 60° give 5.000000, not a clean 5.

Input data

Results

Enter data and click Calculate.

How it works

The law of cosines generalises Pythagoras. c² = a² + b² − 2ab cos γ, then the square root. With 3, 4 and 90°, cos 90° = 0, so you are left with √(9+16) = 5. The result is 5.

The fields are side a, side b and angle γ in degrees. γ sits between those two sides. 5, 5 and 60° make an equilateral: the result is 5.000000, because cos(60°) is not a clean 1/2 in machine float.

7, 8 and 60° give 7.549834. An acute angle shortens c versus the sum of squares. An obtuse angle, for example 120°, lengthens c.

Pythagoras is on the neighbouring page when the angle is right and you know the two legs. The law of sines finds a side from one side and two angles. Heron finds an area from three sides, not a side from an angle.

The header units switch does not turn cm into inches. 3, 4, 90 stay 5 on the same scale.

3, 4, 90° gives 5. 5, 5, 60° gives 5.000000. 7, 8, 60° gives 7.549834.

Formula

c = √(a² + b² − 2ab · cos(γ°))

How to use

  1. Type sides a and b, for example 3 and 4.
  2. Type the angle γ between them, for example 90.
  3. Click Calculate. c is 5.
  4. 5, 5 and 60° give 5.000000.
  5. When you know one side and two angles, go to the law of sines.

3, 4, 90° gives 5

c = √(a² + b² − 2ab cos γ). With 3, 4 and 90° c is 5. With 5, 5 and 60° it is 5.000000.

cosines
The third side from two sides and the included angle. 3-4-90 gives 5.
γ
The angle between a and b, in degrees. 90° drops the cosine term. 60° with 5 and 5 gives 5.000000.
Pythagoras
The special case at 90°. 3 and 4 give 5. Same result here, another formula.

Examples

Example 1

  • a = 3
  • b = 4
  • γ = 90°

5

What is c with 3, 4 and 90°? 5. Same 3-4-5 as Pythagoras.

Example 2

  • a = 5
  • b = 5
  • γ = 60°

5.000000

What is c with 5, 5 and 60°? 5.000000. Equilateral, leftover from π.

Example 3

  • a = 7
  • b = 8
  • γ = 60°

7.549834

What is c with 7, 8 and 60°? 7.549834.

Related calculators

Common questions

What is c with 3, 4 and 90°?

5. cos 90° = 0, so Pythagoras remains: √(9+16) = 5.

What does the law of cosines mean?

The third side from two sides and the included angle. c² = a² + b² − 2ab cos γ.

Which angle do I type?

γ between a and b. The third field. Not an angle opposite c under another label.

What about 5, 5 and 60°?

5.000000. Equilateral. The calculator does not round to a bare 5, because cos 60° misses 1/2.

What about 7, 8 and 60°?

7.549834. An acute angle shortens c versus √(49+64).

Does 120° lengthen the side?

Yes. cos 120° is negative, so −2ab cos γ adds to the sum of squares.

How is this different from Pythagoras?

Pythagoras is the γ = 90° case. Here the angle may be acute or obtuse.

Do the units have to be centimetres?

No. As long as a and b share one scale. 3, 4, 90 stay 5.

Does the order of a and b change c?

Not at the same γ. 3, 4, 90 and 4, 3, 90 both give 5.

Where is the area from three sides?

On Heron’s formula. Here you find the missing side, not the area.

Knowledge sources

The calculator computes the same formula as the definition below.

Page updated in 2026.