Differential Equations - 1
motivated by a discussion on this calculus forum

Here's an interesting problem:
Consider the function
y = x - 1 for x ≤ -2
and y = -2x - 1 for -2 < x < 0
and y = x - 1 for x ≥ 0.

The function looks like Figure 1.

Notice that:

  • y(x) is defined for all x
  • dy/dx = (1+y)/x = 1 for x < -2
  • dy/dx = (1+y)/x = -2 for -2 < x < 0
  • dy/dx = (1+y)/x = 1 for x > 0
  • Finally, we note that y = 1 when x = -1
So, is this function a "solution" to the problem:
dy/dx = (1+y)/x,   y(-1) = 1

Figure 1

>But your function has no derivative at x = -2 or even at x = 0.
Yes, that's true, so it won't be a solution at those two points because it has no derivative there.
In fact, it's not even continuous at x = -2.
But what about all the other values of x? Is it a solution for all x other than x = -2 and x = 0?

>Well ... uh, I guess so. After all, it satisfies the differential equation, right?
Yes, but does that make it a solution to the problem I posed?

>What do you mean by a "solution"!
Hmmm ... good question.
>If you give me a definition of "solution", I'll tell you if that function is a solution.
Yes, but consider ...
>I'd just check to see if your function satisfies the definition and ...
Okay! So give me a definition.
>Hey! I though you were teaching this stuff.

Okay, let's consider the following function ... similar to the last:

y = Ax - 1 for x ≤ -2
and y = -2x - 1 for -2 < x < 0
and y = Bx - 1 for x ≥ 0
A and B are constants.

Notice that:

  • y(x) is defined for all x
  • dy/dx = (1+y)/x = A for x < -2
  • dy/dx = (1+y)/x = -2 for -2 < x < 0
  • dy/dx = (1+y)/x = B for x > 0
  • y = 1 when x = -1
Is this function a solution to the problem I posed, above?

>Yeah, so where's your definition of "solution"?
Okay, suppose we do this:
The problem we posed is an "Initial Value Problem".
Our "solution" must pass through (-1, 1) and, at that "Initial Value" point, must satisfy the Differential Equation.
Next, we move away from x = -1 and see how far we can get while still having our "solution" satisfy the DE.
If, at any x-value, our function fails to satify the DE, we stop. The range of x-values defined in this way provide the domain of the "solution".
How does that sound?

>So, let's see. For that first function we can move from x = -1 back to x = -2 and up to x = 0, right?
So?
>So that first function is y = -2x - 1 in -2 < x < 0, but it's not a solution beyond that interval. Right?
Yes, according to our definition.
>Then I'd say the "solution" is y = -2x - 1 with domain -2 < x < 0. Am I right?
What about y = -2x - 1 for all x < 0?
>Then I'd say it, too, was a "solution" ... according to your definition. Am I right?
So what about the second solution, above?
>But it isn't unique, is it? I mean, you can choose any constants A and B.
So, do you think a "solution" should be unique?
>Sure, why not?
Then how about defining "solution" as a function that passes through the Initial Point and satisfies the DE over as large an interval as possible.
>An interval that contains the initial point, right?
Yes.
>Then y = -2x - 1 is our "solution", wouldn't you say?
For x < 0.
In fact, since (1+y)/x isn't even defined for x = 0, our solution-interval cannot extend from x = -2 to x = 0, so x < 0.
Further, if we attach to our "solution" the largest interval containing x = -1, then we should discard both that first solution and the second solution.
>Unless A = B = -2, right?
Uh ... well, that "B" is attached to our second function for x > 0, so we'd ignore it.
So we'd end up concluding that, for our particular problem:
(1)   y = -2x - 1 for x < 0.
(2)   No solution exists for x ≥ 0.

>So what's our definition of "solution"?
I think we've agreed upon the following:
y(x) is a "solution" to:   dy/dx = f(x,y),   y(a) = b   on an interval I if:
(1) The interval I contains the point x = a.
(2) y(a) = b.
(3) y(x) satisfies the differential equation at every point in the interval I.
(4) The interval I is the largest interval for which (1) - (3) hold true.
So what's the solution to our Initial Value Problem?

>I'd say it's   y = -2x - 1   on the interval x < 0.
I agree.
Have we learned anything?

>I think we've learned we can make a banana the "solution" ... if we provide the appropriate definition of "solution".
Very funny.

   
    Multiple solutions


the Direction Field

For a differential equation like dy/dx = f(x,y), it means that the solution which passes through the point, say (a,b), will have slope f(a,b).
That means we can attach a slope to each point in the x-y plane ... so long as f(x,y) has a value at that point.
That means ...

>Can you get to the point?
Okay. Here's a spreadsheet where you type in f(x,y) and you get a bunch of those slopes:

Just click on the pretty picture to download the spreadsheet.

NOTE:

The numerical calculation uses Runge-Kutta, like so:
' start Runge-Kutta integration, Num1 steps

For i = 10 To 10 + Num1
    Cells(i, 35) = x       ' stick x into column AI, row i
    Cells(i, 36) = y       ' stick x into column AJ, row i

    Range("C7") = x       ' put x into cell C7
    Range("D7") = y       ' put y into cell D7
    k1 = dx * Range("E7")       ' cell E7 calculates f(C7,D7) so k1 = f(x,y)*dx is calculated

    Range("C7") = x + dx / 2
    Range("D7") = y + k1 / 2
    k2 = dx * Range("E7")       ' k2 = f(x+dx/2,y+k1/2)*dx

    Range("C7") = x + dx / 2
    Range("D7") = y + k2 / 2
    k3 = dx * Range("E7")       ' k3 = f(x+dx/2,y+k2/2)*dx

    Range("C7") = x + dx
    Range("D7") = y + k3
    k4 = dx * Range("E7")       ' k4 = f(x+dx,y+k3)*dx

    x = x + dx       ' Take an x-step
    y = y + (k1 + 2 * (k2 + k3) + k4) / 6       ' Take a y-step

Next i