Calculus Lab #6:  Differential Equations

Goals:	1.  Review the importance of modeling
	2.  Introduction to differential equations
	3.  Introduction to slope fields 
	4.  Introduction to Euler's Method.

1.  Modeling

Throughout the course, we've discussed mathematical modeling -- translating physical situations into equations.  The goal of modeling is not to produce an exact copy of the "real" object, but rather to give a representation of some aspect of the real thing.
	As you may have noticed, calculus deals with changes in variables.  Many real-world variables we're interested in modeling change with respect to both time and other variables.  For example, the population of rabbits in a given area changes with respect to:
1.  Changes in time
2.  Changes in food supplies
3.  Changes in the number of foxes
4.  Disease, temperature, etc.

To simplify this model, we could make a few assumptions:
1.  If no foxes are present, rabbits reproduce at an exponential rate (and they are not affected by overcrowding).
2.  Foxes eat rabbits, and the rate at which the rabbits are eaten is proportional to the rate at which the foxes and rabbits interact.
3.  Without rabbits to eat, the fox population declines at an exponential rate.
4.  The rate at which foxes are born is proportional to the number of rabbits eaten by the foxes.

Our dependent variables of interest in this situation are:
	R = number of rabbits
	F = number of foxes

The independent variable of interest in this situation is:
	t = time

We also have the following parameters:
	α = growth rate coefficient of rabbits
	β = constant of proportionality measuring rabbit-fox interactions (rabbits eaten)
	γ = death-rate coefficient for foxes
	δ = constant of proportionality measuring benefit to foxes of an eaten rabbit.

We're interested in the rate of change of the rabbit and fox populations, so our model is:

(dR/dt) =  αR  -  βRF

(dF/dt) =  -γF  + δRF

We will need to solve a set of two differential equations in order to evaluate our model at any given time.  This type of problem is well beyond our level of understanding right now (although you will learn how to solve these problems in Differential Equations or Engineering Math).

For now, I'm just going to show you a slopefield of the general solution to this model.  The x-axis represents the population of rabbits.  The y-axis represents the population of foxes.  Try to interpret the slopefield.

<<Graphics`PlotField`

\(PlotVectorField[{\((2 - 1.22  y)\) x, \((\(-1\) +  .9  x)\) 
          y}, \ 
\ \ \ \ \ \ \ \ \ \ \ \ \ {x, \ 0, \ 10}, \ {y, \ 0, \ 10}, 
      Axes -> True]\)

1.  Suppose we start with 8 rabbits and 8 foxes.  What happens to their populations over time?
2.  Suppose we start with 8 rabbits and 2 foxes.  What happens?
3.  Suppose we start with 2 rabbits and 8 foxes.  What happens?
4.  Suppose we start with 2 rabbits and 2 foxes.  What happens?

2.  Linear Approximation

We have been finding derivatives like mad throughout this entire semester.  Even though the derivative is the slope of the tangent line, it took us awhile to appreciate why that could be even a remotely useful thing to know.  In time, we learned that derivatives describe rates of change and can be used to optimize functions.

Let's add something new to the list about how mind-numbingly useful derivatives are.  Take a look at the graph of the function f(x) and its tangent line at the point (c, f(c)):

Plot[{3  (x^4) - (x^2) + 50,  37.5  x + 6.6875}, {x, -1, 3}, 
      PlotRange -> {0, 
          100},   PlotStyle -> {{RGBColor[0, 0, 0]}, {RGBColor[1, 0, 
              0]}}]

Notice how the graph of the function and the tangent line graph get very close to each other in the space right around X = C.  If we were to plug in a value of X really close to C into both functions, we'd almost get the same output.  Why is this important?  Well, the derivative of a function is often simpler to deal with than the original function (consider a simple polynomial).

The whole idea of using a derivative to approximate the original function value may not impress you too much at this point.  That's probably because you've done much more impressive things before now.  However, we're going to upgrade this whole process in just a few minutes when we discuss Euler's Method.  You'll be wowed all over again, I promise.

Because the equation of a tangent line to a function has values that usually come very close to the function around the point of tangency, that tangent equation is a good linear approximation for the function.  No matter how simple a function may be to evaluate, not many functions are simpler than a line.  Furthermore, there are some functions that are far from easy to evaluate without a calculator, and linear approximations are very handy in evaluating such functions.

Question #1:  Estimate the value of the natural log of 1.1 using the linear approximation to f(x) = ln(x) centered at X = 1.

Solution #1:  We need to find the equation of the tangent line at x = 1.  The slope of that tangent line is the derivative of the function

f[x_] = Log[x]
f[1]
fprime[x_] = (∂_x) Log[x]
fprime[1]

Y = X - 1.  Plugging in X = 1.1, we get an answer of 0.1 (close to 0.09531, the real answer)

Question #2:  Estimate the value of arctan(1.9) using the linear approximation to f(x) = ln(x) centered at X = 2.

Solution #1:  We need to find the equation of the tangent line at x = 2.  The slope of that tangent line is the derivative of the function

g[x_] = ArcTan[x]
N[g[2]]
gprime[x_] = (∂_x) ArcTan[x]
gprime[2]

So y - 1.10715 = (1/5)(x - 2).  Solving this, we get:

Y = 0.2x + 0.70715

Evaluating this at X=2, we get:  ArcTan[2] = 1.10715 (close to 1.107148718)

2.  Differential Equations

In the past two classes, we've been introduced to differential equations modeling exponential growth/decay as well as a method of solving simple differential equations -- variable separation.  We'll learn two additional approaches to solving differential equations:
	1.  Slope fields
	2.  Euler's method

To simplify this model, we could make a few assumptions:
1.  If no foxes are present, rabbits reproduce at an exponential rate (and they are not affected by overcrowding).
2.  Foxes eat rabbits, and the rate at which the rabbits are eaten is proportional to the rate at which the foxes and rabbits interact.
3.  Without rabbits to eat, the fox population declines at an exponential rate.
4.  The rate at which foxes are born is proportional to the number of rabbits eaten by the foxes.

Our dependent variables of interest in this situation are:
	R = number of rabbits
	F = number of foxes

The independent variable of interest in this situation is:
	t = time

We also have the following parameters:
	α = growth rate coefficient of rabbits
	β = constant of proportionality measuring rabbit-fox interactions (rabbits eaten)
	γ = death-rate coefficient for foxes
	δ = constant of proportionality measuring benefit to foxes of an eaten rabbit.

We're interested in the rate of change of the rabbit and fox populations, so our model is:

(dR/dt) =  αR  -  βRF

    
(dF/dt) =  -γF  + δRF

We will need to solve a set of two differential equations in order to evaluate our model at any given time.  This type of problem is well beyond our level of understanding right now (although you will learn how to solve these problems in Differential Equations or Engineering Math).

For now, I'm just going to show you a slopefield of the general solution to this model.  The x-axis represents the population of rabbits.  The y-axis represents the population of foxes.  Try to interpret the slopefield.

<< Graphics`PlotField`

\(PlotVectorField[{\((2 - 1.22  y)\) x, \((\(-1\) +  .9  x)\) 
          y}, 
\ \ \ \ \ \ \ \ \ \ \ \ \ {x, \ 0, \ 10}, \ {y, \ 0, \ 10}, 
      Axes -> True]\)

1.  Suppose we start with 8 rabbits and 8 foxes.  What happens to their populations over time?
2.  Suppose we start with 8 rabbits and 2 foxes.  What happens?
3.  Suppose we start with 2 rabbits and 8 foxes.  What happens?
4.  Suppose we start with 2 rabbits and 2 foxes.  What happens?

5.  Questions to turn in

1.  Turn in your answers to the practice questions in section #3

6.  Reflection

At the end of each Mathematica session, I want you to write a sentence or two describing what you learned (or just list important concepts from this lab).  You can later use these reflections as a reference for other Mathematica Labs.

Print out your answers to the lab questions and turn them in for credit.

<< Graphics`PlotField`

\(PlotVectorField[{x\^3 + 2  x\^2 - 4, \ 
        y\^3 + 3}, 
\ \ \ \ \ \ \ \ \ \ \ \ \ {x, \ \(-5\), \ 
        5}, \ {y, \ \(-5\), \ 5}, Axes -> True]\)