Example 1. A Separable ODE: y`=(1-2x)/y y(1)=

Example 1.
A Separable ODE:
y’=(1-2x)/y
y(1)=-2
y ' = (1 - 2 x)/y
3
2
1
0
-1
-2
-3
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
The Method for Separable ODEs
Put all the y’s on one side and all the x’s on the other and
integrate. Then find the interval on the x-axis where the
solution is defined.
1
y dy = (1-2x) dx
∫ ydy = ∫ (1 − 2x )dx
½y2 = x - x2 + c
y2 = 2x - 2x2 + c’
Use initial condition to find c’. Plug x=1 and get y=-2
Obtain
c’ = 4
and
y2 = - 2x2 + 2x + 4
y = − -2x2 + 2x + 4
We choose the negative sign thanks to the initial condition.
Where does this make sense? Where - 2x2 + 2x + 4 ≥ 0.
This means
- x2 + x + 2 ≥ 0
Note that
x2 - x -2 = (x-2)(x+1) ≤ 0
which happens when
-1 ≤ x ≤ 2
The endpoints are the points x such that to y=0. This
corresponds to vertical direction field.
2
y’ = 3x2/(3y2-4)
Example 2.
y(1)=0
y ' = 3 x 2/(3 y 2 - 4)
4
3
2
1
0
-1
-2
-3
-4
-3
-2
-1
0
1
2
3
Note: Matlab behaved badly and would not copy the exact
numerical approximation. So I tried to reproduce it drawing
the curve by hand. Most non-linear problems cause Matlab
trouble!! This is non linear but still separable.
Put all the y’s on one side and
Obtain
(3y2-4) dy
Integrate and find
y3
y3 - 4y
all the x’s on the other.
=
3x2dx
- 4y = x3 + c
= x3 + c
3
y(1)=0 implies c=-1.
So we end up with an implicit formula for y:
y3 - 4y = x3 -1.
Cubic equations can be solved with an exact formula somewhat
like the quadratic formula but it isn’t pretty.
Lot of roots!!!!
SolveAy3 - 4 y == x3 - 1, yE
In Mathematica
leads to
It is only the first solution which interests us, as the
other 2 involve i=√-1 and this is not a real number.
We want real solutions only !!!!!!
The solution goes bad if -229-54x3+27x6 < 0.
4
To figure out what values of x should be legal to
plug in, without using Mathematica’s exact
solution, look back at the differential equation
and see where the denominator is 0.
y(1)=0
y’ = 3x2/(3y2-4)
happens when y = ±2/√3
3y2=4
Plug this into our y formula and solve for x
y3 - 4y = x3-1.
Use Mathematica or Matlab
a = 2/31/2; b = -a
c = a3-4a+1 ≅ -2.0792
d = b3-4b+1 ≅ 1 + 16/33/2
|c|1/3 ≅ 1.27634
d1/3 ≅ 1.59781
The moral is that the legal x values lie between
-1.276 and 1.598
You can see this in the picture below.
5
red is what Mathematica drew using numerical solution
purple was drawn by hand trying to match vector field
6
Modeling Salty Water in a
Tank
Tank has 100 gallons of water and
50 ounces of salt
water with salt concentration of 1/4 (1+1/2 sin t) oz/gal
flows in at rate 2 gal/min
water flows out at same rate
a) find amount of salt in tank at time t
b) plot solution and consider what happens for large t
c) long term behavior oscillates about a constant salt
level. find constant
Q(t) = amount of salt in ounces at time t minutes
Q’(t) = rate in - rate out
rate in = 2 * (1/4) (1 + 1/2 sin t)
rate out = 2 * Q / 100
oz/min
oz/min
Q’(t) = 1/2 + (1/4) sin t - (1/50) Q(t)
Q(0) = 50
7
Matlab or Mathematica can draw the direction field and
numerically approximate the problem really fast.
y ' = (1/2) + (1/4) sin(t) - y/50
60
50
40
30
20
10
0
0
50
100
150
200
250
300
350
400
450
500
You can see that the solution after a certain length of time
oscillated around a constant value of about 25 oz.
8
We have a linear ODE which can be done by the Leibnitz
integration factor method on page 34 of the text.
Q (t ) = e
−t
50
s
−t
1
1
50
50
e
+
s
ds
+
Ce
(
sin
)
∫ 2 4
You need a table of integrals here
e au
∫ e sin (bu )du = a 2 + b 2 (a sin(bu ) − b cos(bu )) + C
au
The final result looks like
Q(t) = k + a exp(-t/50) + b sint t - c cost
where
a,b,c,k are constants.
Next we we plot the exact solution and the direction field
using Mathematica. The oscillations are small around the
constant value of k.
9
After the homework is turned in, I will add the last page of this
lecture.
10