This week in my calculus class, we were studying examples of separable differential equations: exponential growth and decay, Newton’s Law of Heating and Cooling, and the logistic model, respectively \[ \frac{dy}{dt} = ky, \qquad \frac{dy}{dt} = k(M-y), \qquad\text{and}\qquad \frac{dy}{dt} = ky\left(1-\frac{y}{L}\right). \]

I had several goals for this course of study:

- to show the versatility of differential equations in modeling physical situations;
- to show the usefulness of integration techniques for solving real-world problems;
- to practice understanding the behavior of solutions to differential equations by examining the equations themselves;
- to get students more familiar with Wolfram Alpha and Desmos as computational tools.

In the age of widely-accessible computer algebra systems, we are finally freed from spending a month in calculus class mastering techniques of integration. Substitution and integration by parts are indispensable, but as far as I’m concerned, the rest of the methods are used infrequently enough that students should be made aware that other techniques exist and they can learn them when needed. In particular, solving the logistic equation is about the only reason I can conjure to justify learning partial fractions in introductory calculus. So we learned how to compute partial fractions for a rational function with two linear factors in the denominator. Here’s how it gets used.

First, rearrange the logistic equation a bit and separate variables to get \[ \frac{dy}{y(y-L)} = -\frac{k}{L}dt. \] The right side clearly integrates to $-\frac{k}{L}t$. Using partial fractions, the integral of the left side is \[ \int\frac{dy}{y(y-L)} = \int \frac{1}{L} \frac{dy}{y - L} - \int\frac{1}{L} \frac{dy}{y} = \frac{1}{L} \big( \ln|y - L| - \ln|y| \big) = \frac{1}{L} \ln \left|\frac{y - L}{y}\right|. \] Tossing in the ever-present arbitrary constant of integration $+C$ (which really matters very little until one starts solving differential equations, as here), we have \[ \frac{1}{L} \ln \left|\frac{y - L}{y}\right| = -\frac{k}{L}t + C. \] Multiply both sides by $L$ and exponentiate both sides to get \[ \left|\frac{y - L}{y}\right| = e^{-kt + LC} = e^{LC} e^{-kt}. \] Now, $e^{LC}$ is always positive, but when we drop the absolute value signs, we get \[ \frac{y - L}{y} = Be^{-kt}, \] where $B$ can be either positive or negative. Finally, solve for $y$: \[ y = \frac{L}{1 + Ae^{-kt}} \] (where $A = -B$). Technically, throughout this process we had to assume that $y \ne 0$ and $y \ne L$. That’s okay, though, because $y = 0$ and $y = L$ are evident as equilibrium (constant) solutions from the equation itself.

There are three qualitatively different behaviors that solutions to the logistic equation can have, depending on their initial values.

- The solutions $y = 0$ and $y = L$, as mentioned above, are constant.
- A solution that starts out between $0$ and $L$ will increase over time, approaching the value $L$ asymptotically. This behavior corresponds to $A > 0$ in the solution above.
- A solution that starts out above $L$ will decrease over time, again approaching the value $L$ asymptotically. This behavior corresponds to $A < 0$ in the solution above.

So far, so good, and I haven’t said anything that isn’t easily found elsewhere. But before we solved the logistic equation by hand, I wanted my students to explore the solutions graphically, so I had them plug the equation into Wolfram Alpha. Here’s the solution it provides: \[ y(t) = \frac{L e^{c_1 L+k t}}{e^{c_1 L+k t}-1}. \] However, if you plot this solution (link goes to a Desmos graph) and vary the parameters (particularly $c_1$, since $k$ and $L$ are constants given in the equation), you will only see one kind of solution: the third kind. Type 2 solutions, the most interesting ones, don’t even show up in Wolfram Alpha’s formula! What’s going on?

If you sign in to Wolfram Alpha, you can have it produce step-by-step solutions. The results from this query:

This doesn’t look so different from our solution: separate variables, integrate, solve for $y$. In W|A, $\log$ denotes the natural logarithm, so nothing’s amiss there. What’s changed?It’s a small thing, one that could easily be missed, even if you’re looking step-by-step. A hint comes from the placement of the additional parameter that arises from the constant of integration: in our solution, this parameter ended up in front of the exponential function, whereas Wolfram Alpha left it in the exponent. That’s not really the issue though… ah, there it is:

After integrating,*there’s no absolute value inside the logarithm*(gasp!). I know, we try to convince our students time and time again that the standard antiderivative of $\frac{1}{x}$ is $\ln|x|$, and here Wolfram is leaving out the absolute value. And it turns out to make a difference—go back and read the solution we went through, and you’ll see that the moment the absolute value was dropped from the equation is precisely when our formula gained the flexibility to accommodate both type 2 and type 3 solutions. Wolfram Alpha

*missed solutions*by leaving out the absolute value.

This isn’t all that disastrous. I know that Wolfram Alpha generally assumes complex arithmetic, in which case the logarithm requires a branch cut anyway. It also assumes a fair amount of mathematical sophistication on the part of its users. It wasn’t too hard for me to figure out why we didn’t get the answer we expected. [For more on these points, see the addendum, below.] But this example does suggest caution when we try to use W|A for educational purposes. In fact, it reinforces the message that as we’re training our students to use computing tools, we need to make sure they’re doing so intelligently. One doesn’t need to fully anticipate the answer provided, but one should have some idea of what to expect, to check the answer’s reasonableness.

I’m also not arguing that one has to be a stickler about constants of integration or absolute values in logarithms from the moment that they are introduced. Such matters are generally secondary in the early days of learning integration. But when motivation for such secondary matters naturally arises in examples of interest, that should be seized.

** Addendum (2/16):** When I first posted this, I suggested that it was evidence of a bug in Wolfram Alpha. Later I realized that this is not technically the case, because with complex numbers, Euler’s formula shows that we

*can*get all of the solutions; for instance, if we let $c_1 = i\pi + c_2$, then Wolfram Alpha’s answer becomes $L e^{c_2+k t}/(e^{c_2+k t}+1)$. Indeed, if we add the initial condition $y(0) = L/2$, then W|A returns $y(t) = Le^{kt}/(e^{kt}+1)$, as expected. It’s not enough, however, to specify that the equation be solved over the reals; doing so gives the same answer as at first. The pedagogical points I made about using technology still stand. They are perhaps even made stronger, as defaulting to computations over the complex numbers often produces results that can be confusing for students. This doesn’t mean we should avoid using such tools, but we should prepare our students to adapt to unexpected output.

## 3 comments:

Subtle! You have now made a nice project for classes: teach them how to solve, and then ask what goes wrong with Wolfram Alpha. I might steal that from you.

Please do! If I had caught this earlier, I might have made it a project myself, instead of just pointing it out in class.

Post a Comment