logabs, logarc: How to make integrate() return what you expect

logarc

In the back of my calculus book there is a table of famous integrals.  Here’s integral number 21 in that table:

20171004_113109

From Maxima integrate(), I get

integral21Maxima

 

What’s going on?

Both forms give a workable antiderivative for the original integrand:

integral21Maxima2

Furthermore, we believe that both forms are correct because of this helpful identity for hyperbolic sine:

 {\rm asinh}(z)=\ln(z+\sqrt{1+z^2}).  

Turns out (thanks to a Barton Willis for pointing me in the right direction) there’s a variable logarc that we can set to make Maxima return the logarithmic form instead of hyperbolic sine:

integral21Maxima3

I haven’t yet encountered cases where this would be a bad idea in general, but I’ll update this if I do.

logabs

In the first week of my differential equations course, we study methods of direct integration and separation of variables.  I like to emphasize that the absolute values can lend an extra degree of generality to solutions with antiderivatives of the form

\int \frac{1}{u}\;du = \ln |u|+ C.   

As an example, for the initial value problem

 y' = \frac{x}{1-x^2}    ,  y(0)=1    ,

it is convenient for treating all possible initial conditions (x \ne \pm 1) in one step to use the antiderivative

y = -\frac{1}{2} \ln | 1-x^2 | + C.   

However, Maxima omits the absolute values.

logabs1.PNG

For this case, we could consider only the needed interval -1<x<1, but still…

Turns out we can set the Maxima variable logabs to make integrate() include absolute values in cases like this:

logabs2.PNG

But then later in the course, I saw that logabs also impacts the Ordinary Differential Equation solver ode2().  I encountered an example for which Maxima, in particular solve() applied to expressions involving absolute value,  didn’t do what I wanted with logabs:true

For the logistic equation

\frac{dP}{dt} = kP\left ( 1-\frac{P}{P_c} \right )    ,  P(0)=P_0   

we expect that by separating variables we can obtain the solution

P(t) = \frac{P_0 P_c}{(P_c-P_0)e^{-kt}+ P_0}.   

Here’s what happens when we use ode2() with and without logabs:true:

logistice2

logistic3

 

 

Advertisements

4 thoughts on “logabs, logarc: How to make integrate() return what you expect”

  1. Hi,
    Thanks for your logistic equation explanations. My Question is: Starting from your result Po=(Po*Pc*e^(k*t)/(Po*e^(k*t)+Pc-Po), what is the best way in Maxima if I want to simplify logistic equation as P=Pc/(1+Q*e^(-k*t)), substituting Q=Pc-P0.

    Like

    1. Cemil, I think your solution should instead have Q=(Pc-P0)/P0.

      I’m not sure how to make Maxima return the solution in the form you want, but we can use Maxima to convince ourselves that the two forms are equivalent:

      (P0*Pc*%e^(k*t))/(P0*%e^(k*t)+Pc-P0) – Pc/(1+(Pc-P0)/P0*exp(-k*t))
      factor(%)

      The result is 0.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s