High School Modules > Trigonometry by Gregory A. Moore
The Cosine Graph
An exploration of the many variations of the cosine graph.
[Directions : Execute the Code Resource section first. Although there will be no output immediately, these definitions are used later in this worksheet. Note that this worksheet is graphic intensive at times. If you experience problems it may be necessary to re-execute the "0. Code" section before executing each subsection. ]
0. Code
| > | restart; with(plots): |
Warning, the name changecoords has been redefined
| > | SolidPlot := proc(f,a,b) local c; c := COLOR(RGB, .4, .4, .8); plot( f(x), x = a..b, filled = true, color=c, style=patchnogrid); end: |
| > | SolidPlotRCol := proc(f,a,b) local c; c := COLOR(RGB, 5*evalf(rand()/10^13,2), 5*evalf(rand()/10^13,2), 5*evalf(rand()/10^13,2) ); plot( f(x), x = a..b, filled = true, color=c, style=patchnogrid); end: |
| > | SolidPlotCol := proc(f,a,b, COL) local box,i,n,x1,x2,xmid,delta,y1,y2,A,B, m,M,slope, concav, col: plot( f(x), x = a..b, filled = true, color=COL, style=patchnogrid); end: |
| > | CosPlot := proc(f) local A, B,G,start, endpt, speed, period, lift, amp, M,m : M := maximize(f(x), x = 0..10); m := minimize(f(x), x = 0..10); lift := (M + m)/2 ; G := f(x) - lift; if (nops(G) = 2) then amp := op(1,G); if (amp > 0) then start := solve(G = M - lift, x); else start := solve(G = m - lift, x); fi; speed := subs( x = 1, op(1, op(1, op(2,G)))); period := 2*Pi/speed; amp := evalf(subs(x = start, G)); else amp := 1; start := evalf(solve(G = 1, x)); speed := subs( x= 1, op(1,op(1,G))); period := evalf(2*Pi/speed); fi; endpt := start + period; plots[display]( SolidPlot( x->cos(x), 0, 2*Pi), plot( f(x), x = start..endpt, color = blue, thickness = 2), plot( { [[start,lift],[endpt,lift]],[[start,m],[endpt,m]], [[start,M],[endpt,M]] ,[[start,m],[start,M]] ,[[endpt,m],[endpt,M]]} ,color = red, thickness = 1, linestyle = 2), plot( 0, x = 0..2*Pi) ); end: |
| > |
| > | SinCosTable := proc(n) local i, A; A := array( [seq( [ 2*i*Pi/n, evalf(sin(2*i*Pi/n)),` `, 2*i*Pi/n - Pi/2, evalf(cos(2*i*Pi/n - Pi/2)) ], i = 0..n ) ]): A[1,1] := theta: A[1,2] := sin(theta): A[1,4] := theta- Pi/2: A[1,5] := cos(theta): print(A); end: |
1. The Basic Cosine Graph
Much like the sin(x), y = cos(x) is also a function of x and can be plotted. The values are different than those of the sine, of course.
| > | cos( 3*Pi/7): % = evalf(%); |
| > | n := 12; array( [seq( [ 2*i*Pi/n, evalf(cos(2*i*Pi/n)) ], i = 1..n ) ]); |
This is the basic shape of the cosine graph
| > | plot( cos(x), x = 0..2*Pi); |
| > | SolidPlot( x-> cos(x) , 0, 2*Pi); |
| > | display( [seq( SolidPlotCol( x-> (k/16)*cos(x),0,2*Pi, COLOR(RGB, .35 - k/32, .35 - k/32, 1 - k/28 )),k = 1..16) ]); |
2. Connection with Sine Graph
The sine and cosine graphs are closely related.
| > | plot( {sin(x), cos(x)},x = 0..2*Pi, color = [red, blue], thickness = 2); `Red is sine, Blue is cosine`; |
| > | plot( {sin(x), cos(x)},x = 0..4*Pi, color = [red, blue], thickness = 2); |
They actually have the same shape - with a horizontal shift. You can think of the cosine graph following the sine graph in a sense. Notice that sine and cosine take the same values - at x values
apart.
| > | sin(Pi/2); cos(0); |
This is not only true for these two values, but for any two values of x.
| > | SinCosTable(12); |
This explains the similarity in the graphs. Note that both the sine and cosine have the same period
and same amplitude (1). In a sense they are the same graph, starting from different values : sin starts at 0 while cosine starts at 1. If we think of it this way, then all of the factors which influence the sine graph will work the same way on the cosine.
3. Amplitude
The amplitude of the cosine function is the height of its hill (and depth of its valley). For cos(x), the amplitude is 1.
| > | display( plot(cos(x), x = 0..2*Pi, thickness = 2), plot( {[[0,0],[0,1]],[[2*Pi,0],[2*Pi,1]]} , color = blue, linestyle = 2, thickness = 3), plot( [[Pi,0],[Pi,-1]], color = yellow, linestyle = 2, thickness = 3)); |
A constant in front of the cos(x) function alters the amplitude just as the sine is altered.
| > | f := x -> 1.5*cos(x); |
| > | CosPlot( f ); |
If the constant is positive but less than 1, the graph contracts toward the x axis.
| > | f := x -> (3/4)*cos(x); |
| > | CosPlot( f ); |
If the constant is negative, the stretching factor is the same, but the cosine is flipped upside down.
| > | f := x -> -3*cos(x); |
| > | CosPlot( f ); |
4. Period & Frequency
The cosine graph is periodic - it repeats. Each section that repeats is called a "period." The fundamental "piece" that repeats has length of
- this is the period of the cosine.
The frequency is
- that is, the cos(x) function completes 1 cycle every "time" interval of
- or, another way to think of it is that the function completes
of a period every one unit of time.
| > | display( plot( cos(x), x=0..6*Pi, color = blue), plot( cos(x), x=0..2*Pi, color = red, thickness = 5), plot( cos(x), x=2*Pi..4*Pi, color = green, thickness = 5), plot( cos(x), x=4*Pi..6*Pi, color = violet, thickness = 5) ); |
If there is a constant times x inside of the cos(x) function, this affects the period and frequency. For example, cos(2x) will complete its cycles twice as fast - each one taking half as long. So the period of cos(2x) is
, and the frequency is 1 over that, or
.
| > | f := x -> cos(2*x); CosPlot( f ); |
Note that the horizonatal shifting is affected, but the amplitude remains 1. If the constant is less than one, the graph has a smaller frequency and a longer period.
| > | f := x -> cos((1/2)*x); CosPlot( f ); |
If the constant is negative, the stretching factor is the same, but the cosine is flipped upside down.
| > | f := x -> -.3*cos(x); |
| > | CosPlot( f ); |
5. Amplitude & Period Changes
The changes to period and amplitude can both operate indepently on a single cosine function. The period is a feature of the x coordiate and the amplitude is a feature of the y coordinate, so neither has any impact on the other.
| > | f := x -> 5*cos(2*x); `Half the period, but 5 times the amplitude`; CosPlot(f); |
| > | f := x -> (1/4)*cos(.5*x); `Twice the period, and 1/4 of the amplitude`; CosPlot(f); |
| > | f := x -> 3*cos((1/2)*x); `Twice the period, and 3 times the amplitude`; CosPlot(f); |
6. Shifting & Lifting
In algebra we learn that y = f(x) and (y-b) = f(x-a), or y = f(x-a) + b, have the same graphs except the latter is shifted a units right, and b units up. The same concept applies to all other functions, including the cosine function.
| > | plot( {x^2, (x-3)^2 + 4} , x = -3..6, y = 0..9); |
| > | f := x -> cos(x - Pi/6) + 1 ; CosPlot(f); |
| > | f := x -> cos(x - Pi/2) - 2 ; CosPlot(f); |
7. Shifting/Lifting/Amplitude/Period
Here are some examples where all four transformation take place in the same function.
| > | f := x -> 3*cos( 2*(x - Pi/12)) + 1; `Amplitude = 3, speed = 2, period = Pi, vertical lift = 1, horizontal shift (phase shift) = Pi/12`; CosPlot( f ); |
| > | plot( f(x), x = 0.. 8*Pi); |
Another exmaple
| > | f := x -> 5*cos( (1/2)*x + Pi) + 5; CosPlot( f ); |
| > | plot( f(x), x = 0..20*Pi ); |
8. Composite Functions of Cosine
| > | f := x -> abs(cos(x)); display(SolidPlot( x->cos(x), 0, 2*Pi), plot(f(x), x = 0..2*Pi, thickness = 2, color = red, thickness=3)); |
| > | f := x -> cos(x)^2; display(SolidPlot( x->cos(x), 0, 2*Pi),plot(f(x), x = 0..2*Pi, color = red, thickness=3)); |
| > | f := x -> cos(x)^3; display(SolidPlot( x->cos(x), 0, 2*Pi),plot(f(x), x = 0..2*Pi, color = red, thickness=3)); |
We can look at families of similar cosine functions. Here's
where k goes from 1 to 10.
| > | k := 'k': plot( { (k/10)*cos(x) $ k = 1..10}, x = 0..2*Pi); |
And
for k=1..10
| > | plot( { cos(x)^k $ k = 1..10}, x = 0..2*Pi); |
| > | display( [ seq( SolidPlotCol( x-> sqrt(k)*cos(x)^(2*k),0,2*Pi, COLOR(RGB, .1 + k/25, .2 + k/25, .4 + k/25 )),k = 1..12), plot( [sqrt(k)*cos(x)^(2*k) $ k = 1..12], x = 0..2*Pi, color = gray, axes = none)]); |
for k = 1..10
| > | plot( { k + (k/10)*cos(k*x) $ k = 1..10}, x = 0..2*Pi); |
And
for k = 1..10
| > | display( [ seq( SolidPlotCol( x-> sum( cos((2*j+1)*x)/(2*j+1), j= 1..k),0,2*Pi, COLOR(RGB, .2 + k/25, .4 + k/25, .1 + k/25 )),k = 1..10), plot( {sum( cos((2*j+1)*x)/(2*j+1), j= 1..k) $ k = 1..10}, x = 0..2*Pi, color = wheat, axes = none)]); |
9. Graphs of Sums of Sines and Cosines
The last example above was not merely a nice drawing. If we add up sines and cosines with differing amplitudes and periods, we get some extremely useful periodic functions. Physicists and engineers often use sums of sines and cosines to model periodic electrical impulses, such as those seen on a heart monitor. These sums are called
Fourier series
, which you will learn about if you study mathematics in university.
| > | restart; |
Here's perhaps the simplest kind of example:
| > | plot( sum( cos(k*x) , k = 1..15 ), x = 0..4*Pi); |
| > | plot( sum( cos(k*x)/k, k = 1..20), x = 0..4*Pi); |
| > | plot( sum( sin(x*k)/k, k = 1..20), x = 0..4*Pi); |
| > | plot( sum( sin(x*k)/k - cos(x*k)/k, k = 1..20), x = 0..4*Pi); |
| > | plot( sum( sin(x*k)/k + ((-1)^k)*cos(x*k)/k, k = 1..20), x = 0..4*Pi); |
| > | plot( sum( sin(x*k)/k^2 + cos(x*k)/k^2, k = 1..10), x = 0..4*Pi); |
| > | plot( sum( sin(x*k^2)/k^2 + ((-1)^k)*cos(x*k)/k^4, k = 1..10), x = 0..4*Pi); |
| > | plot( sum( sin(x*(2*k))/k - cos(x*(2*k+1))/k, k = 1..50), x = 0..4*Pi); |
| > | plot( sum( sin(x*(3*k+1))/(2*k+1)^2 - cos(x*(3*k))/(2*k)^2, k = 1..40), x = 0..4*Pi); |
| > | plot( sum( sin(x*(3*k))/k + cos(x*(3*k))/k, k = 1..40), x = 0..4*Pi); |
© 2002 Waterloo Maple Inc