VOOZH about

URL: https://www.geeksforgeeks.org/maths/law-of-cosine/

⇱ Law of Cosines - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Law of Cosines

Last Updated : 16 Jun, 2026

The law of cosines is used to find the relation between sides and the angles of the triangle. Suppose we are given the sides of the triangle, and then the angle of the triangle is found.

Where a, b, and c are the sides of the triangle and A, B, and C are the angles of the triangle. This law is also called the Cosine Rule or the Cosine Formula.

Defined as the law that gives the relation between sides and angles of the triangle.

πŸ‘ 2056958278

We can also find the angles of the triangle by the formulas.

  • cos A = [b2 + c2 – a2]/2bc
  • cos B = [a2 + c2 – b2]/2ac
  • cos C = [b2 + a2 – c2]/2ab

The Law of Cosines is a powerful tool for solving triangles that are not right-angled. In particular, it helps in situations where the Law of Sines may not be applicable, such as the following:

  • SAS (Side-Angle-Side): You know two sides and the included angle.
  • SSS (Side-Side-Side): You know all three sides and need to find an angle.

Law of Cosines Proof

Law of cosines is proved using trigonometric identities. Suppose we are given a triangle ABC and BM is the altitude of the triangle and its height is h and AM is equal to r. Also, sides of the triangle a, b, and c; the image for the same is added below.

πŸ‘ 2056958279

In Ξ”ABM,

  • sin A = BM/AB = h/c. (i)
  • cos A = AM/AB = r/c ... (ii)

From equation (i) (ii),

  • h = c(sin A)
  • r = c(cos A)

By Pythagoras Theorem in Ξ”BMC,

a2 = h2 + (b - r)2

Then,

Using h = c(sin A) and r = c(cos A) in above equation

β‡’ a2 = {c(sinA)}2 + {b - c(cosA)}2

β‡’ a2 = c2sin2A + b2 + c2cos2A - 2bc cosA

β‡’ a2 = c2(sin2A + cos2A) + b2 - 2bc cosA

a2 =b2 + c2 - 2bc cosA

This is the cosine formula.

Similarly, the other two formulas are also proved.

  • b2 = c2 + a2 - 2ca cosB
  • c2 = a2 + b2 - 2ab cosC

Real-World Applications

  • Navigation and Surveying: It’s used in determining distances and angles in land surveys.
  • Physics and Engineering: In mechanics, it helps calculate forces acting on an object at various angles.

Solved Examples

Example 1: If two sides of the triangle are 12 cm and 16 cm and the angle between them is 30Β°, then find the third side of the triangle.

Given,

  • b = 12 cm
  • c = 16 cm
  • ∠A = 30Β°

Law of Cosines Formula,

a2 = b2 + c2 - 2bcΒ·cosA

β‡’ a2 = (12)2 + (16)2 - 2(12)(16)cos30Β°

β‡’ a2 = 144 + 256 - (384)(1/2) = 208

β‡’ a = 14.4 cm

Thus, the third side of the triangle is 14.4 cm

Example 2: If two sides of the triangle are 8 cm, 10 cm, and 6 cm, then find the angle 'A' of the triangle.

Given,

  • a = 8 cm
  • b = 10 cm
  • c = 6 cm

Using Cosines Law,

a2 = b2 + c2 – 2bc cos(A)

β‡’ cos A = (b2 + c2 – a2)/2bc

Substituting the given value,

cos(A) = (102 + 62 – 82)/(2 Γ— 10 Γ— 6)

β‡’ cos(A) = (100 + 36 - 64)/120 = 72/120 = 3/5

β‡’ A = cos-1 (3/5)

Example 3: Find ∠A of triangle ABC, where sides of the triangle, a, b, and c, are 1 cm, 1 cm, and √2 cm.

Using cosine rule,

cos A = [b2 + c2 – a2]/2bc

β‡’ cos A = {(1)2 + (√2)2 - (1)2}/2(1)(√2) = 2/2√(2)

β‡’ cos A = 1/√(2)

β‡’ A = cos-1(1/√(2)) = 45Β°

Practice Problems

Problem 1: If two sides of the triangle are 20 cm and 22 cm and the angle between them is 45Β°, then find the third side of the triangle.

Problem 2: If two sides of the triangle are 3 cm, 4 cm, and 5 cm, then find the angle 'A' of the triangle.

Probelm 3: If two sides of the triangle are 8 cm and 12 cm and the angle between them is 60Β° then find the third side of the triangle.

Problem 4: If two sides of the triangle are 12 cm, 18 cm, and 16 cm, then find the angle 'A' of the triangle.

Related Articles

Comment

Explore