- 1. Plotting slope fields and solution curves.
- 2. Solving differential equations with initial conditions:
- 3. Solving separable differential equations.
- 4. Newton's Law of Cooling.

**1. **
**Plotting slope fields and solution curves.**

If we consider a differential equation of the form , this information tells you a slope at each point in the -plane, so one way to visualize solutions to the differential equation is to plot a small line segment at various points in the plane, whose slope is equal to . A solution to the differential equation will have the property that the line segments will be tangent to the curves. While this procedure could, in principle, be carried out by hand, we can draw hundreds of such tiny line segments quickly with the computer, and they guide our eye in visualizing what solution curves look like. For example, consider the following differential equation.

`> `
**deq:=D(y)(x)=x*y+2*x;**

Let us plot the slope fields to this curve over a region given by , . For simplicity let us give these ranges names.

`> `
**xrange:=-3..3;yrange:=-3..3;**

We need to load the package
**DEtools**
. Then we can use the
**dfieldplot**
command to plot solutions to the differential equation.

`> `
**with(DEtools):**

`> `
**dfieldplot(deq,y(x),x=xrange,y=yrange);**

Warning, y is present as both a dependent variable and a name. Inconsistent specification of the dependent variable is deprecated, and will be removed in the next release.

It is very easy to get an impression of what the solution curves look like from the picture. We can also plot solution curves corresponding to certain
*initial conditions*
on the same plot. For example, suppose we want to specify curves satisfying the following initial conditions.

`> `
**initcond:=[[y(1)=1],[y(1)=2],[y(1)=-1],[y(1)=-2],[y(1)=-2.2]];**

We have specified 4 different choices of initial conditions, and given the list of these choices a name. We can use this name to plot the solutions satisfying these conditions on the same plot. We use the
**DEplot**
command to do this.

`> `
**DEplot(deq,y(x),x=xrange,y=yrange,initcond,linecolor=blue);**

Warning, y is present as both a dependent variable and a name. Inconsistent specification of the dependent variable is deprecated, and will be removed in the next release.

**Submission:**

For each of the differential equations below, plot the slope fields and some representative solution curves on the same plot. Determine whether the differential equation is separable.

1) .

2) .

3) .

**2. Solving differential equations with initial conditions:**
** **

Although this section is mainly about separable differential equations, these are not the only kind of differential equations that can be solved. For example, consider the first order differential equation
. In order to write this differential equation in a form in which Maple can solve it, it is necessary to express
*y*
as a function
on the right hand side of the equation. Thus we ask Maple to solve the following.

`> `
**deq:=D(y)(x) = 1-y(x)/x;**

`> `
**dsolve(deq,y(x));**

Maple has found the general solution to this differential equation in terms of the unknown constant . (Recall that Maple names the constants it introduces beginning with the underscore symbol, as this is unlikely to interfere with variables that you have named in your problem.) What if we wanted to solve this differential equation subject to the initial condition ? Then we would type in

`> `
**dsolve({deq,y(2)=3/2},y(x));**

Of course, given the general solution, we could have solved for the unknown constant directly as follows.

`> `
**solve(subs(x=2,y(2)=3/2,y(x) = 1/2*x+_C1/x));**

Consider the differential equation .

1) From the form of the differential equation, there is a natural restriction on the
*y*
values. State and explain this restriction.

2) Use Maple to solve this differential equation in general.

3) Explain how the general solution to this differential equation is consistent with your restriction in 1).

4) Find the solution to the differential equation which satisfies .

**3. Solving separable differential equations.**
** **

Consider the differential equation
** **
of activity 3. This differential equation is separable, and we can rewrite it in the form
. We can then integrate the left and right hand sides of this equation.

`> `
**int(1/sqrt(1-y^2),y);**

`> `
**int(x^2,x);**

Thus we obtain the solution
. This solution is implicit, but we can solve for
*y*
explicitly to obtain the solution
. This example was very simple, because we could easily have done both integrals without the help of Maple.

Consider the differential equation .

1) Rewrite the differential equation by separating the variables.

2) Solve the separated differential equation by integrating the left and right hand sides. Then solve for
*y.*

3) Solve the differential equation directly in Maple, using the
**dsolve **
command.

**Submission worksheet:**

Let us state the differential equation for Newton's Law of cooling. Let
*H*
represent the temperature of an object at time
*t*
, and
*Hs*
represent the ambient temperature. (We assume that the effect of the cooling or heating of the object on the temperature of the surroundings is negligible.) Then the temperature is governed by the differential equation

,

where
*k*
is a constant (which is usually determined by experiment). Let us solve the differential equation subject to the initial condition
.

`> `
**dsolve({D(H)(t) = -k*(H(t)-Hs),H(0)=Ho},H(t));**

We have the following data.
,
,
. If we substitute this information into the equation, we can solve for
*k. Note that in making the substitutions, the order of substitution is left to right, so you must make the substitution t=30 before the substitution H(30)=140.)*

`> `
**subs(Ho=210,Hs=70,t=30,H(30)=140,H(t) = Hs+exp(-k*t)*(-Hs+Ho));**

`> `
**fsolve(%,k);**

Then we can substitute this value of
*k*
into the original equation to obtain the correct formula.

`> `
**subs(Ho=210,Hs=70,k=.2310490602e-1,H(t) = Hs+exp(-k*t)*(-Hs+Ho));**

Then we can substitute
in this equation to solve for
*t*
.

`> `
**subs(H(t)=90,%);**

`> `
**fsolve(%,t);**

Therefore, we have determined that it will take about 84 minutes before the cake has cooled to 84 degrees.

**Submission:**

Suppose that a cup of soup cooled from 90 degrees C to 60 degrees C after 10 minutes in a room whose temperature was 20 degrees C. Use Newton's Law of Cooling to answer the following questions.

1) How much longer would it take the soup to cool to 35 degrees C?