You are on page 1of 16

Drexel University, College of Engineering 2017-2018 Academic Year

Drexel University
Office of the Dean of the College of Engineering
ENGR 232 – Dynamic Engineering Systems

Homework 2: SOLUTIONS
These problems target separation of variables and integrating factors, as well as the use of MATLAB.

Both separation of variables and the method of integrating factors will likely appear on Quiz 1. (in week 3)

Problem 1: Separation of Variables


i. Solve each of the following differential equations by separation of variables:

ii. Each equation has at least one solution which is a line of the form: 𝑦 = 𝑎𝑥 + 𝑏. Find it!
iii. A direction field with selected solutions has been given for each DE. Plot a few additional solutions.

)* ,-+ .
Just separate and integrate. Don't forget
a. = the constant of integration.
)+ ,-* .

First separate the variables, then integrate to get:

(4 − 𝑦 2 ) 𝑑𝑦 = (4 + 𝑥 2 ) 𝑑𝑥

*6 +6
54𝑦 − 7
8 = 54𝑥 − 7
8+𝑐

This gives the solution in implicit form. A solution can


be obtained in explicit form using Cardano’s formula
for the roots of a cubic, but this is not required here.

For this DE, find the solution satisfying 𝑦(0) = 0.


Just set both x and y to 0 in the implicit solution above.
This shows the solution with 𝑦(0) = 0 is given when
𝑐 = 0. See the green line.
This linear solution has the equation: 𝑦 = 𝑥

1
Drexel University, College of Engineering 2017-2018 Academic Year

Just separate and integrate. Don't forget


)* the constant of integration.
b. )+
= 2𝑥𝑦
Is this DE linear? YES!
Is it autonomous? NO!
First separate the variables, then integrate to get: IS this DE

1
𝑑𝑦 = 2𝑥 𝑑𝑥
𝑦

ln|𝑦| = 𝑥 2 + 𝑐

Don't forget the absolute value sign.


The value of y can certainly be negative.
See all the red curves.

Now exponentiate both sides to get rid of the log term.


. AB .
|𝑦 | = 𝑒 + = 𝑒B ∙ 𝑒 +

The absolute value can be removed using ±.


.
𝑦 = ±𝑒 B ∙ 𝑒 +
So, defining a new constant 𝑘 = ±𝑒 B ,
the general solution in explicit form is:

.
𝑦 = 𝑘 ∙ 𝑒+

The only linear solution occurs when 𝑘 = 0 which


gives the line 𝑦 = 0 shown in black on the graph.

2
Drexel University, College of Engineering 2017-2018 Academic Year

Just a sign change.

)*
c. = −2𝑥𝑦
)+

First separate the variables, then integrate to get:

1
𝑑𝑦 = −2𝑥 𝑑𝑥
𝑦

ln|𝑦| = −𝑥 2 + 𝑐

Don't forget the absolute value sign.


The value of y can certainly be negative.
See all the red curves.

Now exponentiate both sides to get rid of the log term.


. AB .
|𝑦| = 𝑒 -+ = 𝑒 B ∙ 𝑒 -+

The absolute value can be removed using ±.


Because of the negative sign, the solutions
.
𝑦 = ±𝑒 B ∙ 𝑒 -+ now appear as bell-shaped curves.
So, defining a new constant 𝑘 = ±𝑒 B ,
the general solution in explicit form is:

.
𝑦 = 𝑘 ∙ 𝑒 -+

What is the equation of the one solution that is a line?


The only linear solution occurs when 𝑘 = 0 which
gives the line 𝑦 = 0 shown in black on the graph.

3
Drexel University, College of Engineering 2017-2018 Academic Year

)* FA+
d. )+ = * Just separate and integrate. Don't forget
the constant of integration.
Is this DE linear? NO!
Notice the DE is undefined when y = 0. See dotted line.
The slope becomes infinite all along the x-axis. Is it autonomous? NO!
First separate the variables, then integrate to get:

IS this DE
𝑦 𝑑𝑦 = (1 + 𝑥) 𝑑𝑥

G 𝑦 𝑑𝑦 = G(1 + 𝑥) 𝑑𝑥 + 𝑐

𝑦2 𝑥2
=𝑥+ +𝑐
2 2

Rearranging gives:

𝑦 2 = (𝑥 2 + 2𝑥 + 1) + 2𝑐 − 1

The above is just an implicit relation for the solution.


Define a new constant 𝑘 = 2𝑐 − 1.

We can easily take square root of both sides to


find the solution in explicit form:

𝑦 = ±H(𝑥 + 1)2 + 𝑘

Above, there are two linear features.


Find their equations.
We recognize these solutions as hyperbolas.

The linear solutions correspond to the asympototes of the hyperbolas. They are found by setting 𝑘 = 0.

After cancelling the root and the square, the two lines are:

𝑦 = 𝑥 + 1 𝑎𝑛𝑑 𝑦 = −𝑥 − 1

4
Drexel University, College of Engineering 2017-2018 Academic Year

𝐞. 4𝑡 𝑑𝑦 = (𝑦 2 + 𝑡𝑦 2 ) 𝑑𝑡 , 𝑦(1) = 1 Just separate and integrate.


Don't forget the constant of integration.
Is this DE linear? NO!
First factor out the 𝑦 2 term on the right.
Is it autonomous? NO!
4𝑡 𝑑𝑦 = 𝑦 2 (1 + 𝑡)𝑑𝑡
Or: No picture provided.
𝑑𝑦 (1 + 𝑡)
= 𝑦2
𝑑𝑡 4𝑡

OK - separate the variables and integrate!


1 (1 + 𝑡)
2
𝑑𝑦 = 𝑑𝑡
𝑦 4𝑡

1 1
∫ 𝑦 -2 𝑑𝑦 = G N + O 𝑑𝑡
4𝑡 4

F F
−𝑦 -F = ln|𝑡| + 𝑡 + 𝑐
, ,

Don't forget the absolute value sign.

Since 𝑐 is just a constant, we can simplify a tad by defining a new constant 𝑘 = 4𝑐


Rewriting the equation in a convenient form:
4
𝑦=− Solution in explicit form.
ln|𝑡| + 𝑡 + 𝑘

To solve for the constant 𝑘 we make use of the initial conditions: 𝑦(1) = 1
This gives:
,
1 = − PQ(F)AFAR à 𝑘 = −5

Therefore, the solution to the initial value problem is: Below are two different views of the solutions.
,
𝑦(𝑡) = − PQ|T|AT-U

5
Drexel University, College of Engineering 2017-2018 Academic Year

Problem 2: Integrating Factors

Find the general solution for the following differential equations. Also solve the IVP for each.
Use MATLAB’s dfield8 command to show the general solutions, then show the specific solution in red.

First place each in standard form. Then find the integrating factor using your ESP: 𝜇 = 𝑒 ∫ W )T

a. 𝑦 X = −2𝑦, y(0) = 2 Linear, constant coefficients, homogeneous.

First rearrange the DE into standard from.


General form of first-order linear differential equation as seen in Schaum’s 6th chapter.

𝒚X + 𝒑(𝒕)𝒚 = 𝒒(𝒕)

The standard form is:


𝑦 X + 2𝑦 = 0

Thus we can identify: 𝑝(𝑡) = 2 and 𝑞(𝑡) = 0, so it is homogeneous and autonomous.


The integrating factor can be found using our ESP! 𝜇 = 𝑒 ∫ W )T

𝜇(𝑡) = 𝑒 ∫ W(T).)T = 𝑒 ∫ 2)T = 𝒆𝟐𝒕


The general solution can be found from:
𝜇(𝑡)𝑦(𝑡) = G 𝜇(𝑡)𝑞(𝑡) 𝑑𝑡 + 𝑐
This gives:
𝑒 2T 𝑦(𝑡) = G 0 𝑑𝑡 + 𝑐

𝑦(𝑡) = 𝑐 𝑒 -2T

Note this can be solved also by separation of variables. Check and see that you get the same solution.
The specific solution satisfying y(0) = 2 is: 𝑦(𝑡) = 2 𝑒 -2T See red curve below.

6
Drexel University, College of Engineering 2017-2018 Academic Year

b. 𝑦 X + 2𝑦 − 2 𝑒 T = 0 y(0) = 2, Now it is non-homogeneous, and no longer autonomous.

First, rearrange into standard form: 𝑦 X + 2𝑦 = 2 𝑒 T

Comparing this to the general form, we see: 𝑝(𝑡) = 2 and 𝑞(𝑡) = 2 𝑒 T

The integrating factor can be found using our ESP! 𝜇 = 𝑒 ∫ W )T

𝜇(𝑡) = 𝑒 ∫ 2)T = 𝒆𝟐𝒕 , It's the same as for the previous problem.

The general solution can be found from:


𝜇(𝑡)𝑦(𝑡) = G 𝜇(𝑡)𝑞(𝑡) 𝑑𝑡 + 𝑐
This gives:
𝑒 2T 𝑦(𝑡) = G 𝑒 2T ∙ 2𝑒 T 𝑑𝑡 + 𝑐

𝑦(𝑡) = 𝑒 -2T aG 2 𝑒 7T 𝑑𝑡 + 𝑐b

2 2 𝑡
𝑦(𝑡) = 𝑒−2𝑡 c ∙ 𝑒3𝑡 + 𝑐e = ∙ 𝑒 + 𝑐 𝑒−2𝑡
3 3

2 ,
The specific solution satisfying y(0) = 2 is: 𝑦(𝑡) = 7 ∙ 𝑒 T + 7 ∙ 𝑒 -2T See red curve below.

MATLAB Solution
syms y(t)
DE = diff(y,t) + 2*y == 2* exp(t);
sol = dsolve( DE)
sol = dsolve( DE, y(0)==2)

7
Drexel University, College of Engineering 2017-2018 Academic Year

2*
c. 𝑦X = T
, 𝑦(1) = 4, Even though it is separable, apply the integrating factor method.

2*
First, rearrange into standard form! 𝑦X − =0
T

Next find the integrating factor using your ESP! 𝜇 = 𝑒 ∫ W )T

.
𝟏
𝜇 (𝑡) = 𝑒 ∫ -g )T = 𝑒 -2 PQ|T| = 𝒕𝟐 where t ≠ 0.

The ± sign is squared and drops out.

Multiplying the DE by the integrating factor gives:

𝑑 -2
(𝑡 𝑦) = 0
𝑑𝑡

Integrating now shows the general solution is this family of parabolas:

𝑦 = 𝑐 𝑡 2

The specific solution satisfying y(1) = 4 is: 𝑦 = 4 𝑡 2 See red parabola below.

8
Drexel University, College of Engineering 2017-2018 Academic Year

2*
d. 𝑦X − T
= 𝑡 2 , 𝑦(1) = 3 Similar to above, but no longer homogeneous.

2*
First, rearrange into standard form! 𝑦X − = 𝑡2
T

Next find the integrating factor using your ESP! It's the same as in part c! 𝜇 = 𝑒 ∫ W )T

.
𝟏
𝜇 (𝑡) = 𝑒 ∫ -g )T = 𝑒 -2 PQ|T| = 𝒕𝟐 where t ≠ 0.

Multiplying the DE by the integrating factor gives:

The general solution can be found from:


𝜇(𝑡)𝑦(𝑡) = G 𝜇(𝑡)𝑞(𝑡) 𝑑𝑡 + 𝑐

or:

1 1
2
𝑦(𝑡) = G 2 ∙ 𝑡 2 𝑑𝑡 + 𝑐
𝑡 𝑡

Nice! The squares cancel!


Integrating and rearranging now shows the general solution is:

𝑦(𝑡) = 𝑡 7 + 𝑐 ∙ 𝑡 2

The specific solution satisfying y(1) = 3 is: 𝑦 = 𝑡 7 + 2 𝑡 2 See red curve below.
5

0
y

-1

-2

-3

-4

-5
-3 -2 -1 0 1 2 3
t

9
Drexel University, College of Engineering 2017-2018 Academic Year

e. 𝑦 X = y + sin(π𝑡) , y(0) = 0

First, rearrange into standard form! 𝑦 X − y = sin(π𝑡)


Comparing this equation to the general form we see: 𝑝(𝑡) = −1 and 𝑞(𝑡) = sin(π𝑡).
Integrating factor:
𝜇(𝑡) = 𝑒 ∫ W(T).)T = 𝑒 ∫ -F)T = 𝒆-𝒕
The general solution can be found from:

𝜇(𝑡)𝑦(𝑡) = G 𝜇(𝑡)𝑞(𝑡) 𝑑𝑡 + 𝑐

This gives:

𝑒 -T 𝑦(𝑡) = G 𝑒 -T sin(π𝑡)𝑑𝑡 + 𝑐

Integration by parts twice, will lead to the integral on the RHS.


𝑒 -T
G 𝑒 -T sin(π𝑡)𝑑𝑡 = − ∙ (sin 𝜋𝑡 + 𝜋 cos 𝜋𝑡)
1 + 𝜋2
so,
𝑒 -T
𝑒 -T 𝑦(𝑡) = − (sin 𝜋𝑡 + 𝜋 cos 𝜋𝑡 ) + 𝑐
1 + 𝜋2
Thus the general solution is:
1
𝑦(𝑡) = − (sin 𝜋𝑡 + 𝜋 cos 𝜋𝑡 ) + 𝑐 𝑒 T
1 + 𝜋2
The particular solution satisfying 𝑦(0) = 0 is found using: (See curve in red.)
𝜋
𝑦(0) = 0 = − + 𝑐
1 + 𝜋2 5
so we must choose,
𝜋 4
𝑐=
1 + 𝜋2 3

0
y

-1

-2

-3

-4

-5
-3 -2 -1 0 1 2 3
t

10
Drexel University, College of Engineering 2017-2018 Academic Year

Problem 3: Designing a differential equation to have a known solution

)*
In standard form, the general 1st-order linear DE can be written: )+
+ 𝑝(𝑥)𝑦 = 𝑔(𝑥)

This next problem has a twist. In the following linear differential equation, the driving function 𝑔(𝑥) on the right is not
known. However, it is known that the function 𝑦 = 𝑥 is a solution.

𝑑𝑦
+ 2𝑦 = 𝑔(𝑥)
𝑑𝑥

Unknown

a. Find the driving function 𝑔(𝑥) using the fact that 𝑦 = 𝑥 is a solution. See red line in the figure

)*
Plugging the known solution 𝑦 = 𝑥 into the DE and using )+ = 1 we find:

𝑑𝑦
+ 2𝑦 = 1 + 2𝑥 = 𝑔(𝑥)
𝑑𝑥

b. Now use the integrating factor method


to find all the solutions.

Integrating factor:
𝜇(𝑥) = 𝑒 ∫ W(+).)+ = 𝑒 ∫ 2)+ = 𝒆𝟐𝒙

The general solution can be found from:

𝜇(𝑥)𝑦(𝑥) = ∫ 𝜇(𝑥)𝑞(𝑥) 𝑑𝑥 + 𝑐

𝑒 2+ 𝑦 = ∫ 𝑒 2+ ∙ (1 + 2𝑥) 𝑑𝑥 + 𝑐

F
𝑒 2+ 𝑦 = 𝑒 2+ + ∫ 2𝑥 ∙ 𝑒 2+ 𝑑𝑥 + 𝑐
2

Use integration by parts:

G 𝑢X 𝑣 𝑑𝑥 = 𝑢𝑣 − G 𝑣 X 𝑢 𝑑𝑥

F
𝑒 2+ 𝑦 = 𝑒 2+ + 𝑐 + ∫ 𝑥 ∙ (𝑒 2+ )′ 𝑑𝑥
2

F
𝑒 2+ 𝑦 = 2 𝑒 2+ + 𝑐 + 𝑥 ∙ (𝑒 2+ ) − ∫(𝑒 2+ ) 𝑑𝑥 = 𝑐 + 𝑥 ∙ (𝑒 2+ )

Solving for y explicitly, we find the general solution: 𝑦 = 𝑐 ∙ 𝑒 -2+ + 𝑥

11
Drexel University, College of Engineering 2017-2018 Academic Year

c. The solutions shown in blue all have local minima.


Find the equation of the line (shown as a dotted line)
through these minima. Note this line is not itself
a solution.

)*
The minima occur at the local critical points, that is where )+ = 0. Using the DE, we see the minima occur along the line:
0 + 2𝑦 = 1 + 2𝑥
or:

1
𝑦= +𝑥
2

Problem 4 (Using ODE 45)


Consider the following differential equation. Solve using ode45 over the range for t from –4 to 4.
)*
= sin(𝜋𝑡) ∙ sin(𝜋𝑦)
)T

Here, we will find tons of solutions by considering many initial conditions for the DE.
Here is a row vector with all of our initial conditions.
y0 = -4 : 0.1: 4;

a. Create a MATLAB function for this differential equation that can be used by ode45.

Try this using three different methods. Use a function file. Use an anonymous function. Use matlabFunction.
The code below just gives the case for an anonymous function.

% First define the slope function f(t,y) for dy/dt.


f = @(t,y) sin(pi*t).* sin(pi*y);

b. Write a script that will solve the differential equation shown for the given initial conditions using ode45.
Display a plot of the solutions over the interval from -4 to 4. There will be many, many curves.

tStart = -4; tEnd = 4;


% Many different initial conditions!
y0 = -4 : 0.1: 4;

% Solve using ode45


[t,y] = ode45(f, [tStart tEnd], y0);

figure % Now plot the solutions


plot(t,y, 'LineWidth', 3)
grid on
set(gca, 'Fontsize', 20)
axis([-4 4 -4 4])
axis square

12
Drexel University, College of Engineering 2017-2018 Academic Year

The resulting solutions curves.

-1

-2

-3

-4
-4 -2 0 2 4
Exact Solution: We can actually solve this DE exactly using separation of variables. Just separate and integrate!

𝑑𝑦
= sin(𝜋𝑡) ∙ sin(𝜋𝑦)
𝑑𝑡

)*
Separate à uvQ(w*)
= sin(𝜋𝑡) 𝑑𝑡

)*
Prepare to Integrate à ∫ uvQ(w*) = ∫ sin(𝜋𝑡) 𝑑𝑡 + 𝑐

F F
Integrate à w
∙ ln(|tan(𝜋𝑦/2)|) = − w ∙ cos(𝜋𝑡) + 𝑐

13
Drexel University, College of Engineering 2017-2018 Academic Year

Now multiply by π, and redefine 𝑘 = 𝜋𝑐.


ln(|tan(𝜋𝑦/2)|) = 𝑘 − cos(𝜋𝑡)
Exponentiate both sides!

tan(𝜋𝑦/2) = ±𝑒 R 𝑒 - {|u(wT)

Take the arctangent to solve for y explicitly! Define the new variable 𝑏 = ±𝑒 R .

2 2
𝑦 = w ∙ }atan~𝑏 𝑒 - {|u(wT) • + 𝑛𝜋€ à 𝑦 = w ∙ atan~𝑏 𝑒 - {|u(wT) • + 2𝑛

Note atan is a multivalued function since:


tan(𝑥 + 𝑛𝜋) = tan 𝑥

14
Drexel University, College of Engineering 2017-2018 Academic Year

Problem 5: Devils' Curve and the Electric Motor Curve


A special case of the Devil's curve is the electric motor curve, given by the implicit equation:

𝑦 2 (𝑦 2 − 96) = 𝑥 2 (𝑥 2 − 100)

See: http://mathworld.wolfram.com/DevilsCurve.html

The electric motor curve is one solution of the differential equation:

𝑑𝑦 𝑥 7 − 50𝑥
=
𝑑𝑥 𝑦 7 − 48𝑦

i. Plot the electric motor curve using pplane8. Enter the DE as shown is the screenshot below.
3
x ' = y - 48 y
y ' = x 3 - 50 x

15

10

0
y
Print

-5

-10

-15 Quit

-15 -10 -5 0 5 10 15
x
The backward orbit from (10, 0) left the computation window.
Ready.
The forward orbit
Cursor from (-10,(-7.43,
position: 0) left19)
the computation window.
The backward orbit from (-10, 0) left the computation window.
Ready.

To get the four pieces of the electric motor curve, use the keyboard input option to draw the four solutions curves through
these initial points.

𝑥„ 𝑦„
10 0
–10 0
0 sqrt(96)
0 –sqrt(96)

ii. Find all solutions of the above equation by separation of variables. Which value of c, gives the electric motor curve?

To solve the electric motor DE, just separate and integrate.

The DE is:

𝑑𝑦 𝑥 7 − 50𝑥
=
𝑑𝑥 𝑦 7 − 48𝑦

15
Drexel University, College of Engineering 2017-2018 Academic Year

Now separate the variables:

(𝑦 7 − 48𝑦)𝑑𝑦 = (𝑥 7 − 50𝑥) 𝑑𝑥

Next, integrate! Don't forget the constant of integration.

G(𝑦 7 − 48𝑦)𝑑𝑦 = G(𝑥 7 − 50𝑥) 𝑑𝑥 + 𝑘

𝑦, 𝑥,
− 24𝑦 2 = − 25𝑥 2 + 𝑘
4 4
Multiply by 4, and redefine the constant of integration:

𝑦 , − 96𝑦 2 = 𝑥 , − 100𝑥 2 + 𝑐
The electric motor curve corresponds to selecting 𝑐 = 0.

ii. Plot additional solutions using pplane8, and be sure to color the electric motor curve in red! Show all the other solutions
curves in blue, and with a smaller thickness.

3
x ' = y - 48 y
3
y ' = x - 50 x

15

10

0
y

Print

-5

-10

-15 Quit

-15 -10 -5 0 5 10 15
x
The backward orbit from (-12, 0) left the computation window.
Ready.
The forward orbitposition:
Cursor from (-14,(-14.7,
0) left 19.7)
the computation window.
The backward orbit from (-14, 0) left the computation window.
Ready.

16

You might also like