Homework 2: SOLUTIONS: Drexel University Office of The Dean of The College of Engineering
Homework 2: SOLUTIONS: Drexel University Office of The Dean of The College of Engineering
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)
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.
)+ ,-* .
(4 − 𝑦 2 ) 𝑑𝑦 = (4 + 𝑥 2 ) 𝑑𝑥
*6 +6
54𝑦 − 7
8 = 54𝑥 − 7
8+𝑐
1
Drexel University, College of Engineering 2017-2018 Academic Year
1
𝑑𝑦 = 2𝑥 𝑑𝑥
𝑦
ln|𝑦| = 𝑥 2 + 𝑐
.
𝑦 = 𝑘 ∙ 𝑒+
2
Drexel University, College of Engineering 2017-2018 Academic Year
)*
c. = −2𝑥𝑦
)+
1
𝑑𝑦 = −2𝑥 𝑑𝑥
𝑦
ln|𝑦| = −𝑥 2 + 𝑐
.
𝑦 = 𝑘 ∙ 𝑒 -+
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
𝑦 = ±H(𝑥 + 1)2 + 𝑘
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
1 1
∫ 𝑦 -2 𝑑𝑦 = G N + O 𝑑𝑡
4𝑡 4
F F
−𝑦 -F = 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
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
𝒚X + 𝒑(𝒕)𝒚 = 𝒒(𝒕)
𝑦(𝑡) = 𝑐 𝑒 -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
𝜇(𝑡) = 𝑒 ∫ 2)T = 𝒆𝟐𝒕 , It's the same as for the previous problem.
𝑦(𝑡) = 𝑒 -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
.
𝟏
𝜇 (𝑡) = 𝑒 ∫ -g )T = 𝑒 -2 PQ|T| = 𝒕𝟐 where t ≠ 0.
𝑑 -2
(𝑡 𝑦) = 0
𝑑𝑡
𝑦 = 𝑐 𝑡 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.
or:
1 1
2
𝑦(𝑡) = G 2 ∙ 𝑡 2 𝑑𝑡 + 𝑐
𝑡 𝑡
𝑦(𝑡) = 𝑡 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
𝜇(𝑡)𝑦(𝑡) = G 𝜇(𝑡)𝑞(𝑡) 𝑑𝑡 + 𝑐
This gives:
𝑒 -T 𝑦(𝑡) = G 𝑒 -T sin(π𝑡)𝑑𝑡 + 𝑐
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
)*
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𝑥 = 𝑔(𝑥)
𝑑𝑥
Integrating factor:
𝜇(𝑥) = 𝑒 ∫ W(+).)+ = 𝑒 ∫ 2)+ = 𝒆𝟐𝒙
𝜇(𝑥)𝑦(𝑥) = ∫ 𝜇(𝑥)𝑞(𝑥) 𝑑𝑥 + 𝑐
𝑒 2+ 𝑦 = ∫ 𝑒 2+ ∙ (1 + 2𝑥) 𝑑𝑥 + 𝑐
F
𝑒 2+ 𝑦 = 𝑒 2+ + ∫ 2𝑥 ∙ 𝑒 2+ 𝑑𝑥 + 𝑐
2
G 𝑢X 𝑣 𝑑𝑥 = 𝑢𝑣 − G 𝑣 X 𝑢 𝑑𝑥
F
𝑒 2+ 𝑦 = 𝑒 2+ + 𝑐 + ∫ 𝑥 ∙ (𝑒 2+ )′ 𝑑𝑥
2
F
𝑒 2+ 𝑦 = 2 𝑒 2+ + 𝑐 + 𝑥 ∙ (𝑒 2+ ) − ∫(𝑒 2+ ) 𝑑𝑥 = 𝑐 + 𝑥 ∙ (𝑒 2+ )
11
Drexel University, College of Engineering 2017-2018 Academic Year
)*
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
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.
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.
12
Drexel University, College of Engineering 2017-2018 Academic Year
-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
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𝑛
14
Drexel University, College of Engineering 2017-2018 Academic Year
𝑦 2 (𝑦 2 − 96) = 𝑥 2 (𝑥 2 − 100)
See: http://mathworld.wolfram.com/DevilsCurve.html
𝑑𝑦 𝑥 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?
The DE is:
𝑑𝑦 𝑥 7 − 50𝑥
=
𝑑𝑥 𝑦 7 − 48𝑦
15
Drexel University, College of Engineering 2017-2018 Academic Year
(𝑦 7 − 48𝑦)𝑑𝑦 = (𝑥 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
-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