Law of Cosines

EXPLORE THIS TOPIC IN the MathWorld Classroom LawofCosines

Let a, b, and c be the lengths of the legs of a triangle opposite angles A, B, and C. Then the law of cosines states

a^2=b^2+c^2-2bccosA
(1)
b^2=a^2+c^2-2accosB
(2)
c^2=a^2+b^2-2abcosC.
(3)

Solving for the cosines yields the equivalent formulas

cosA=(-a^2+b^2+c^2)/(2bc)
(4)
cosB=(a^2-b^2+c^2)/(2ac)
(5)
cosC=(a^2+b^2-c^2)/(2ab).
(6)

This law can be derived in a number of ways. The definition of the dot product incorporates the law of cosines, so that the length of the vector from X to Y is given by

|X-Y|^2=(X-Y)·(X-Y)
(7)
=X·X-2X·Y+Y·Y
(8)
=|X|^2+|Y|^2-2|X||Y|costheta,
(9)

where theta is the angle between X and Y.

LawOfCosinesTriangles

The formula can also be derived using a little geometry and simple algebra. From the above diagram,

c^2=(asinC)^2+(b-acosC)^2
(10)
=a^2sin^2C+b^2-2abcosC+a^2cos^2C
(11)
=a^2+b^2-2abcosC.
(12)

The law of cosines for the sides of a spherical triangle states that

cosa=cosbcosc+sinbsinccosA
(13)
cosb=cosccosa+sincsinacosB
(14)
cosc=cosacosb+sinasinbcosC
(15)

(Beyer 1987). The law of cosines for the angles of a spherical triangle states that

cosA=-cosBcosC+sinBsinCcosa
(16)
cosB=-cosCcosA+sinCsinAcosb
(17)
cosC=-cosAcosB+sinAsinBcosc
(18)

(Beyer 1987).

For similar triangles, a generalized law of cosines is given by

 aa^'=bb^'+cc^'-(bc^'+b^'c)cosA
(19)

(Lee 1997). Furthermore, consider an arbitrary tetrahedron A_1A_2A_3A_4 with triangles T_1=DeltaA_2A_3A_4, T_2=DeltaA_1A_3A_4, T_3=DeltaA_1A_2A_4, and T_4=A_1A_2A_3. Let the areas of these triangles be s_1, s_2, s_3, and s_4, respectively, and denote the dihedral angle with respect to T_i and T_j for i!=j=1,2,3,4 by theta_(ij). Then

 s_k=sum_(j!=k; 1<=i<=4)s_icostheta_(ki),
(20)

which gives the law of cosines in a tetrahedron,

 s_k^2=sum_(i!=k; 1<=j<=4)s_j^2-2sum_(i,j!=k; 1<=i,j<=4)s_is_jcostheta_(ij)
(21)

(Lee 1997). A corollary gives the nice identity

 s_1s_1^'=s_2s_2^'+s_3s_3^'+s_4s_4^'-(s_2s_3^'+s_2^'s_3)costheta_(23) 
 -(s_3s_4^'+s_3^'s_4)costheta_(34)-(s_2s_4^'+s_2^'s_4)costheta_(24).
(22)

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.