MATLAB Tutor
Part 12: Symbolic
solution of differential equations
In this part we explore
MATLAB's ability to solve the logistic equation
dy/dt = y (1
- y)
and to check the
solution. Then we will adapt the solution procedure to an initial value
problem with this same differential equation. In the next part, we will
relate these algebraic calculations to the geometry of direction fields.
- First declare the variable t
as symbolic and give the
differential equation a name by entering:
syms t
DE1 = ' Dy = y*(1 - y) '
Then ask MATLAB to solve the differential equation by
entering:
ysol = dsolve(DE1)
pretty(ysol) % Gives nice format
Note that MATLAB uses C1
to represent an arbitrary constant.
- Differentiate your solution
expression with respect to t to get an explicit expression for dy/dt.
You can can differentiate ysol and simplify the result by using:
dysol = simple( diff(ysol) )
pretty(dysol) % Gives nice format
Then use your solution expression ysol to find an explicit formula in t
for y(1 - y). Is this formula the same as the one for dy/dt?
You may want to simplify the output before you try to answer this.
- Now we add the initial
condition y(0) = 1/10 to determine a single solution of the differential
equation. To tell MATLAB to solve the initial value problem, put both
parts of the problem -- the differential equation and the initial condition
-- into dsolve. Enter:
h = dsolve( DE1, ' y(0) = 1/10 ' )
pretty(h) % Gives nice format
- What do you have to do
to check the answer from the preceding step? Have you done it already?
If not, can you get the checking technique from what you did in Step 2?
To substitute t = 0 into the solution function h, enter:
subs(h, t, 0)
We will use our solution function h for further computations in Part 13,
which follows next.