## Description

MAT 275 Laboratory 6 Forced Equations And Resonance Solution

In this laboratory we take a deeper look at second-order nonhomogeneous equations. We will concentrate

on equations with a periodic harmonic forcing term. This will lead to a study of the phenomenon known

as resonance. The equation we consider has the form

d2y

dt2 + c

dy

dt

+ !2

0y = cos !t: (L6.1)

This equation models the movement of a mass-spring system similar to the one described in Laboratory

5. The forcing term on the right-hand side of (L6.1) models a vibration, with amplitude 1 and frequency

! (in radians per second = 1

2 rotation per second = 60

2 rotations per minute, or RPM) of the plate

holding the mass-spring system. All physical constants are assumed to be positive.

Let !1 =

√

!2

0

− c2=4. When c < 2!0 the general solution of (L6.1) is

y(t) = e

−1

2 ct(c1 cos(!1t) + c2 sin(!1t)) + C cos (!t − ) (L6.2)

with

C =

1 √

(!2

0

− !2)2 + c2!2

; (L6.3)

=

arctan

(

c!

!2

0

−!2

)

if !0 > !

+ arctan

(

c!

!2

0

−!2

)

if !0 < !

(L6.4)

and c1 and c2 determined by the initial conditions. The first term in (L6.2) represents the complementary

solution, that is, the general solution to the homogeneous equation (independent of !), while the second

term represents a particular solution of the full ODE.

Note that when c > 0 the first term vanishes for large t due to the decreasing exponential factor.

The solution then settles into a (forced) oscillation with amplitude C given by (L6.3). The objectives of

this laboratory are then to understand

1. the effect of the forcing term on the behavior of the solution for different values of !, in particular

on the amplitude of the solution.

2. the phenomena of resonance and beats in the absence of friction.

The Amplitude of Forced Oscillations

We assume here that !0 = 2 and c = 1 are fixed. Initial conditions are set to 0. For each value of !, the

amplitude C can be obtained numerically by taking half the difference between the highs and the lows

of the solution computed with a MATLAB ODE solver after a sufficiently large time, as follows: (note

that in the M-file below we set ! = 1:4).

1 function LAB06ex1

2 omega0 = 2; c = 1; omega = 1.4;

3 param = [omega0,c,omega];

4 t0 = 0; y0 = 0; v0 = 0; Y0 = [y0;v0]; tf = 50;

5 options = odeset(‘AbsTol’,1e-10,’RelTol’,1e-10);

6 [t,Y] = ode45(@f,[t0,tf],Y0,options,param);

7 y = Y(:,1); v = Y(:,2);

8 figure(1)

9 plot(t,y,’b-‘); ylabel(‘y’); grid on;

c⃝

2011 Stefania Tracogna, SoMSS, ASU 1

MATLAB sessions: Laboratory 6

10 t1 = 25; i = find(t>t1);

11 C = (max(Y(i,1))-min(Y(i,1)))/2;

12 disp([‘computed amplitude of forced oscillation = ‘ num2str(C)]);

13 Ctheory = 1/sqrt((omega0^2-omega^2)^2+(c*omega)^2);

14 disp([‘theoretical amplitude = ‘ num2str(Ctheory)]);

15 %—————————————————————-

16 function dYdt = f(t,Y,param)

17 y = Y(1); v = Y(2);

18 omega0 = param(1); c = param(2); omega = param(3);

19 dYdt = [ v ; cos(omega*t)-omega0^2*y-c*v ];

When executing this program we get

computed amplitude of forced oscillation = 0.40417

theoretical amplitude = 0.40417

Lines 10-14 deserve some explanation. Line 10 defines a time t1 after which we think the contribution

of the first term in (L6.2) has become negligible compared to the second term. This depends of course

on the parameter values, in particular c. With c = 1 we obtain e−1

2 ct ≃ 3:7 × 10−6 for t = 25, so this

is certainly small enough compared to the amplitude seen on Figure L6a. The index i of time values

larger than t1 is then determined. The quantity Y(i,1) refers to the values of y associated to times

larger than t1 only. The computed amplitude is simply half the difference between the max and the min

values. This value is compared to the theoretical value (L6.3).

0 10 20 30 40 50

−0.5

−0.4

−0.3

−0.2

−0.1

0

0.1

0.2

0.3

0.4

0.5

y

Figure L6a: Forced oscillation.

1. (a) What is the period of the forced oscillation? What is the numerical value (modulo 2) of the

angle defined by (L6.4)?

(b) In this question you are asked to modify the file LAB06ex1.m in order to plot the complementary

solution of (L6.1), that is, the first term in (L6.2). First define in the file the angle

(alpha) using (L6.4), then evaluate the complementary solution yc by subtracting the quantity

C cos(!t − ) from the numerical solution y. Plot the resulting quantity. Does it look

like an exponentially decreasing oscillation? Why or why not? Include the modified M-file

and the corresponding plot.

2. We now consider C as a function of !. We use again !0 = 2, c = 1 and y(0) = y′(0) = 0. The

previous problem determined C for a specific value of !. Here we consider a range of values for !

c⃝

2011 Stefania Tracogna, SoMSS, ASU 2

MATLAB sessions: Laboratory 6

and determine numerically the corresponding amplitude C. We then plot the result as a function

of !, together with the theoretical amplitude from (L6.3). You may need the following MATLAB

program.

function LAB06ex2

omega0 = 2; c = 1;

OMEGA = 1:0.02:3;

C = zeros(size(OMEGA));

Ctheory = zeros(size(OMEGA));

t0 = 0; y0 = 0; v0 = 0; Y0 = [y0;v0]; tf = 50; t1 = 25;

for k = 1:length(OMEGA)

omega = OMEGA(k);

param = [omega0,c,omega];

[t,Y] = ode45(@f,[t0,tf],Y0,[],param);

i = find(t>t1);

C(k) = (max(Y(i,1))-min(Y(i,1)))/2;

Ctheory(k) = ??; % FILL-IN

end

figure(2)

plot(??); grid on; % FILL-IN

xlabel(‘\omega’); ylabel(‘C’);

%———————————————————

function dYdt = f(t,Y,param)

y = Y(1); v = Y(2);

omega0 = param(1); c = param(2); omega = param(3);

dYdt = [ v ; cos(omega*t)-omega0^2*y-c*v ];

1 1.5 2 2.5 3

0.2

0.25

0.3

0.35

0.4

0.45

0.5

0.55

w

C

Figure L6b: Amplitude as a function of !

(a) Fill in the missing parts in the M-file LAB06ex2.m and execute it. You should get a figure like

Figure L6b. Include the modified M-file in your lab report.

(b) Examine the graph obtained by running LAB06ex2.m and determine for what (approximate)

value of ! the amplitude of the forced oscillation, C, is maximal. This value of ! is called the

practical resonance frequency. Give the corresponding maximum value of C.

c⃝

2011 Stefania Tracogna, SoMSS, ASU 3

MATLAB sessions: Laboratory 6

(c) Determine analytically the value of ! for which the amplitude of the forced oscillation, C, is

maximal by differentiating the expression for C in (L6.3) as a function of !. Compare the

value you find with the value obtained in part (b).

(d) Run LAB06ex1.m with the value of ! found in part (c) (include the graph). What is the

amplitude of the forced oscillation? How does it compare with the amplitude of the forced

oscillation in problem 1.? If you run LAB06ex1.m with any other value of !, how do you

expect the amplitude of the solution to be?

(e) Are the results affected by changes in the initial conditions? Answer this question both numerically

(by modifying the initial conditions in LAB06ex2.m) and theoretically (by analyzing

the expression for C in (L6.3)). Note that the initial conditions for the DE are y0 and v0.

Resonance

We now investigate what happens to the solution (L6.2), and more specifically to the maximal amplitude

C of the forced oscillation, when we let c → 0. The value of ! corresponding to this maximal amplitude is

called pure resonance frequency. When a mechanical system is stimulated by an external force operating

at this frequency the system is said to be resonant.

3. Set c = 0 in LAB06ex2.m.

1 1.5 2 2.5 3

0

2

4

6

8

10

12

14

w

C

computed numerically

theoretical

(a) Explain what happens. What is the maximal amplitude? What is the value of ! yielding the

maximal amplitude in the forced solution? How does this value compare to !0?

(b) Run LAB06ex1.m with c = 0 and ! equal to the value found in part (a). Comment on the

behavior of the solution. Include the graph.

Beats

When c = 0 and ! ̸= !0 , the solution (L6.2) to (L6.1) reduces to

y(t) = c1 cos(!0t) + c2 sin(!0t) + C cos(!t − )

with C = 1

|!2

0

−!2| . If the initial conditions are set to zero, the solution reduces to

y(t) = C(cos(!t) − cos(!0t))

which can be rewritten as

y(t) = 2C sin

(

1

2

(!0 − !)t

)

sin

(

1

2

(!0 + !)t

)

:

c⃝

2011 Stefania Tracogna, SoMSS, ASU 4

MATLAB sessions: Laboratory 6

When ! is close to !0 we have that ! + !0 is large in comparison to |!0 − !|. Then sin

( 1

2 (!0 + !)t

)

is a very rapidly varying function, whereas sin

( 1

2 (!0 − !)t

)

is a slowly varying function. If we define

A(t) = 2C sin

( 1

2 (!0 − !)t

)

, then the solution can be written as

y(t) = A(t) sin

(

1

2

(!0 + !)t

)

and we may interpret it as a rapidly oscillating function with period T = 4

!0+! , but with a slowly varying

amplitude A(t). This is the phenomenon known as beats. Note that A(t) and −A(t) are the so-called

“envelope functions”. The period of A(t) is 4

|!0−!| , thus the length of the beats is 2

|!0−!| .

4. To see the beats phenomenon, set c = 0 and ! = 1:8 in LAB06ex1. Also extend the interval of

simulation to 100.

0 20 40 60 80 100

−3

−2

−1

0

1

2

3

y

(a) In LAB06ex1 define the “envelope” function A = 2C sin

( 1

2 (!0 − !)t

)

with C = 1

|!2

0

−!2| .

Plot A in red and −A in green, together with the solution. You should obtain Figure L6c.

Include the modified M-file.

0 20 40 60 80 100

−3

−2

−1

0

1

2

3

y

Figure L6c: Solution and envelope functions

c⃝

2011 Stefania Tracogna, SoMSS, ASU 5

MATLAB sessions: Laboratory 6

(b) What is the period of the fast oscillation (that is, the period of sin

( 1

2 (!0 + !)t

)

)? Confirm

your answer by zooming in on the graph of the solution. Include a graph to support your

answer.

(c) What is the length of the beats? Determine the length analytically using the envelope functions,

and numerically from the graph.

(d) Change the value of ! in LAB06ex1 to 1:9 (a value closer to !0) and then ! = 1:6 ( a value

farther away from !0). Include the two graphs. For each of these two values of ! find the

period of the fast oscillation and the length of the beats. How do the periods change compared

to parts (b) and (c)?

(e) If you let ! = 0:5, is the beats phenomenon still present? Why or why not?

c⃝

2011 Stefania Tracogna, SoMSS, ASU 6