T02-Law of Cosines.mws

High School Modules > Trigonometry by Gregory A. Moore  

     The Law of Cosines


Discussion of the law of cosines and applications to solving triangles.

[Directions : Execute the Code Resource section first. Although there will be no output immediately, these definitions are used later in this worksheet.]

 0. Code

>    restart; with(plots):

Warning, the name changecoords has been redefined

>    TriPlot := proc(A,B,C)
local sA,sB,sC,d;
d := 1/4:
sA := [ (C[1]+B[1])/2, (C[2]+B[2])/2];
sB := [ (A[1]+C[1])/2, (A[2]+C[2])/2];
sC := [ (A[1]+B[1])/2, (A[2]+B[2])/2];
display(
    plot( [A,B,C,A], color = blue, thickness = 3, axes = none ),
    textplot( [A[1]-d, A[2]-d, `angle A`]),
    textplot( [B[1]+d, B[2]+d, `angle B`]),
    textplot( [C[1]+d, C[2]-d, `angle C`]),
    textplot( [sA[1]+2*d, sA[2], `side a`]),
    textplot( [sB[1], sB[2]+d, `side b`]),
    textplot( [sC[1]-2*d, sC[2]+d, `side c`])  
        );
end:

>    TriPlotN := proc(A,B,C)
local sA,sB,sC,d, da,db,dc;

d := 1/4:
sA := [ (C[1]+B[1])/2, (C[2]+B[2])/2];
sB := [ (A[1]+C[1])/2, (A[2]+C[2])/2];
sC := [ (A[1]+B[1])/2, (A[2]+B[2])/2];
da := evalf(sqrt( (C[1]-B[1])^2  + (C[2]-B[2])^2 ),3);
db := evalf(sqrt( (C[1]-A[1])^2  + (C[2]-A[2])^2 ),3);
dc := evalf(sqrt( (A[1]-B[1])^2  + (A[2]-B[2])^2 ),3);
display(
    plot( [A,B,C,A], color = blue, thickness = 3, axes = none ),
    textplot( [A[1]-d, A[2]-d, `angle A`]),
    textplot( [B[1]+d, B[2]+d, `angle B`]),
    textplot( [C[1]+d, C[2]-d, `angle C`]),
    textplot( [sA[1]+3*d, sA[2],   cat(`a = `,convert(da,string))]),
    textplot( [sB[1], sB[2]+d,     cat(`b = `,convert(db,string))]),
    textplot( [sC[1]-2*d, sC[2]+d, cat(`c = `,convert(dc,string))])  
        );
end:

 1.  The Law of Cosines


The law of cosines is a generalization of Pythagoras' theorem that applies to non-right triangles.

>    LoC := a^2 + b^2 -2*a*b*cos(theta) = c^2;

LoC := a^2+b^2-2*a*b*cos(theta) = c^2

>    TriPlot([0,0],[10,6],[7,0]);

[Maple Plot]


Here is a table showing how changing the angle of a triangle affects the length of the opposite side (keeping the two sides which form the angle fixed in length).

>    n := 8:    a:= 3: b := 4:
A := array( [seq( [ i*Pi/n, a, b, evalf(sqrt(a^2 + b^2 -2*a*b*cos(i*Pi/n))) ],   
            i = -1..n ) ]):
A[1,1] :=theta: A[1,2]:= 'a': A[1,3] := 'b': A[1,4]:=`c`:
`With a & b fixed, theta increasing makes c increase`;  print(A);

`With a & b fixed, theta increasing makes c increase`

matrix([[theta, a, b, c], [0, 3, 4, 1.], [1/8*Pi, 3, 4, 1.681336141], [1/4*Pi, 3, 4, 2.833626168], [3/8*Pi, 3, 4, 3.976882902], [1/2*Pi, 3, 4, 5.], [5/8*Pi, 3, 4, 5.846742886], [3/4*Pi, 3, 4, 6.4784691...

>    n := 8:    a:= 5: b := 12:
A := array( [seq( [ i*Pi/n, a, b, evalf(sqrt(a^2 + b^2 -2*a*b*cos(i*Pi/n))) ],   
            i = -1..n ) ]):
A[1,1] :=theta: A[1,2]:= 'a': A[1,3] := 'b': A[1,4]:=`c`:
`With a & b fixed, theta increasing makes c increase`;  print(A);

`With a & b fixed, theta increasing makes c increase`

matrix([[theta, a, b, c], [0, 5, 12, 7.], [1/8*Pi, 5, 12, 7.624595471], [1/4*Pi, 5, 12, 9.173177545], [3/8*Pi, 5, 12, 11.09405192], [1/2*Pi, 5, 12, 13.], [5/8*Pi, 5, 12, 14.66021869], [3/4*Pi, 5, 12, 1...

>    a:= 'a': b:= 'b': c:= 'c':

 2.  Solving Triangles - Two Sides & Angle Known


        Example 2.1 :   a = 100, b = 140, and the angle between them is 38 degrees. Find the third side.

>    rad_angle := 38*(Pi/180);

rad_angle := 19/90*Pi

>    subs( {a = 100, b = 140, theta = rad_angle}, LoC);

29600-28000*cos(19/90*Pi) = c^2

>    evalf(%);

7535.69890 = c^2

>    solve(%, c):
abs(%[1]);

86.80840340


Of course, only the positive solution makes sense.

>    TriPlotN([0,0],[140 + 100*cos(142*Pi/180), 100*sin(142*Pi/180)],[140,0]);

[Maple Plot]



        Example 2.2 :   A right triangle has sides 7, 24, and 25. If the two bases are fixed in length, and the right angle is
        increased to 95 degrees, how long will the hypotenuse be?

>    rad_angle := 95*(Pi/180);

rad_angle := 19/36*Pi

>    subs( {a = 7, b = 24, theta = rad_angle}, LoC);

625-336*cos(19/36*Pi) = c^2

>    evalf(%);
solve(%, c):
abs(%[1]);

654.2843296 = c^2

25.57898218



       Example 2.3 :   A right triangle has sides 9, 40, and 41. If the two bases are fixed in length, and the right angle is
        increased to 10%, what percentage increase will the hypotenuse experience?

>    rad_angle := (Pi/2)*1.10;

rad_angle := .5500000000*Pi

>    subs( {a = 9, b = 40, theta = rad_angle}, LoC);

1681-720*cos(.5500000000*Pi) = c^2

>    evalf(%);
solve(%, c):
abs(%[1]);

1793.632815 = c^2

42.35130240

>    %/41;

1.032958595

>    %-1;

.32958595e-1

>    %*100,%;

3.295859500, .32958595e-1



        Example 2.4 :   A bug walks from the origin along the x-axis to the point (200,0). Then the bug turns left, and heads
        off at 71 degrees above the axis, and walks 100 units. How far is the bug away from the origin?

>    angle := 180 - 71;

angle := 109

>    rad_angle := (Pi/2)*angle;

rad_angle := 109/2*Pi

>    subs( {a = 200, b = 100, theta = rad_angle}, LoC);

50000-40000*cos(109/2*Pi) = c^2

>    evalf(%);
solve(%, c):
abs(%[1]);

50000. = c^2

223.6067978

 3.  Solving Triangles - Three Sides Known


The law of cosines has four unknowns - the three sides and an angle. If we know the three sides of a triangle, we can then find "the angle" - which is the angle opposite of the "hyptenuse" (although this is not necessarily a right triangle and the side opposite of the angle is not necessarily the longest side.)

        Example 3.1 :      a = 31,  b = 42, c = 22. Find the angle formed by sides a and b.

>    subs( {a = 31, b = 42, c = 22 }, LoC);

2725-2604*cos(theta) = 484

>    solve( %, theta):
% = evalf(%), `radians`;
evalf( %%*180/Pi), `degrees`;

arccos(747/868) = .5343515039, radians

30.61608595, degrees


In fact, a triangle has three angles and any of them can be considered the angle in the formula. This is selected implicitly by selecting which side is c - which is opposite of the angle in question.



        Example 3.2 :     a = 10, b = 9, c = 8. Find all three angles.

>    `the angle formed by sides a & b is opposite of side c`;
subs( {a = 10, b = 9, c = 8}, LoC);

`the angle formed by sides a & b is opposite of side c`

181-180*cos(theta) = 64

>    Angle_ab := solve( %, theta);
% = evalf(%),` radians`; %% = evalf( %%*180/Pi), ` degrees`;

Angle_ab := arccos(13/20)

arccos(13/20) = .8632118901, ` radians`

arccos(13/20) = 49.45839813, ` degrees`


Ok, we found the angle formed by sides a & b. What about the other angles? We can do this is two different ways - relabel the sides (now we call "a" by "c" and "c" by "a" and use the same formula) or create a new version of the formula with a and c reversed.

>    `the angle formed by sides a & c is opposite of side b`;
subs( {a = 8, b = 9, c = 10}, LoC);

`the angle formed by sides a & c is opposite of side b`

145-144*cos(theta) = 100

>    Angle_ac := solve( %, theta);
% = evalf(%),` radians`; %% = evalf( %%*180/Pi), ` degrees`;

Angle_ac := arccos(5/16)

arccos(5/16) = 1.252972623, ` radians`

arccos(5/16) = 71.79004314, ` degrees`

>    `the angle formed by sides a & c is opposite of side b`;
subs( {a = 10, b = 9, c = 8}, c^2 + b^2 -2*c*b*cos(theta) = a^2);

`the angle formed by sides a & c is opposite of side b`

145-144*cos(theta) = 100

>    Angle_ac := solve( %, theta);
% = evalf(%),` radians`; %% = evalf( %%*180/Pi), ` degrees`;

Angle_ac := arccos(5/16)

arccos(5/16) = 1.252972623, ` radians`

arccos(5/16) = 71.79004314, ` degrees`


We get the same answer either way of course. The third angle is easy to find

>    Angle_bc := Pi - Angle_ab - Angle_ac;
% = evalf(%),` radians`; %% = evalf( %%*180/Pi), ` degrees`;

Angle_bc := Pi-arccos(13/20)-arccos(5/16)

Pi-arccos(13/20)-arccos(5/16) = 1.025408141, ` radians`

Pi-arccos(13/20)-arccos(5/16) = 58.75155875, ` degrees`

>    Angle_ab, Angle_bc, Angle_ac:
evalf(%,3), ` radians`;
evalf(%%*180/Pi,3),` degrees`;

.863, 1.03, 1.25, ` radians`

49.3, 59.0, 71.6, ` degrees`

>   

                
        © 2002 Waterloo Maple Inc