Discontinuous antiderivatives

alec's picture

Maple, Mathematica, and many other CAS define indefinite integral up to piecewise constants. That means, in particular, that the integral of a continuous function can be discontinuous.

In many cases that can be easily fixed, such as for integrals involving floor(x) and frac(x). However, it has not been done neither in Maple nor in Mathematica. Here is another example, suggested by David W. Cantrell

int(1/(2+cos(x)),x);

               2/3*3^(1/2)*arctan(1/3*tan(1/2*x)*3^(1/2))

Mathematica gives the same answer. This answer can be used for evaluating of definite integrals only on intervals without discontinuities, in all other cases it is useless, because the main application of indefinite integration is in finding definite integrals through the Fundamental Theorem of Calculus. If indefinite integral is discontinuous, that can not be done.

David W. Cantrell suggested another form of the indefinite integral in this example (given by Derive), continuous

(x - 2*arctan(sin(x)/(2 + sqrt(3) + cos(x))))/sqrt(3);

               Maple Equation

It is much nicer and can be used for evaluating of definite integrals.

In some examples obtaining a continuous indefinite integral is not that easy. Here is an example suggested by Robert Israel,

int(abs(exp(x)+cos(x)),x);

               Maple Equation

Nice looking answer but practically useless, because of discontinuities,

int(abs(exp(x)+cos(x)),x=-2..0);

               Maple Equation

Again, the answer with a continuous antiderivative can be given. Something like

signum(exp(x)+cos(x))*(exp(x)+sin(x)) 
-2*sum(abs(exp(k)+sin(k)),k=RootOf(exp(_Z)+cos(_Z),_Z,x..0));

That doesn't work in Maple though. However, the following works (at least for x not too far from 0),

f:=x->signum(exp(x)+cos(x))*(exp(x)+sin(x))-
2*piecewise(x<0,add(abs(exp(k)+sin(k)),
k=map2(fsolve,t->exp(t)+cos(t),
fdiscont(signum(exp(_Z)+cos(_Z)),_Z=x..0))));

It can be used for finding definite integrals and it can be plotted,

plot(f,-20..2);
       Maple Plot

Alec Mihailovs
http://mihailovs.com/Alec/

Comments

Will's picture

Updated

Thanks for your great blog entry. I have promoted this to the front page.

Also, I just replaced your text with a version created from a worksheet. This made it easy to change your Text versions of 2-D math into attractive math.

____
William Spaetzel
Marketing Engineer, Maplesoft

alec's picture

Thank you

Will,

Thank you. It looks much nicer.

I planned to change the output to 2d, because, as you said, it looks much more attractive. I did that few times earlier in other posts. Recently I started to post more with plain copying and pasting (and started to make more typos) just because I was slightly pressured by time.

Also, I planned to include 2 or 3 plots in the middle of the text. I'll do that later.

Thanks again,

Alec

Reasonable expectations

For the first example

int(1/(1+2*cos(x)),x=2..5);

the value >is< undefined if we understand the integral to be the Riemann integral. So Maple's answer is correct.

One only attempts to define a Riemann integral for bounded functions on [a,b].

If we want to consider some sort of "Cauchy principal value" then we should first look at

int(1/(1+2*cos(x)),x=2..2*Pi/3);

which is infinite, as correctly returned by Maple.

For the second example:

int(abs(exp(x)+cos(x)),x=-2..0);

we are just not playing fair if we expect Maple to give a value. The answer is just one of those uncountably many irrational numbers that have not been baptized with a name, other than int(abs(exp(x)+cos(x)),x=-2..0). Popular numbers like e, pi, gamma, sqrt(2) have been baptized. But we only have countably many words in our vocabulary. We could define a number "pu" by saying that pu is equal to int(abs(exp(x)+cos(x)),x=-2..0), point out that it is about 1.846479131, and then train Maple to return "pu" whenever we asked it to evaluate int(abs(exp(x)+cos(x)),x=-2..0) but it would probably not catch on in the community.

alec's picture

Corrected

It was a typo in the first example. It should be

int(1/(2+cos(x)),x)

I just corrected it.

The int in Maple is not Riemann and not Lebesgue, it's "Maple". Look at the following,

int(Dirac(x),x=-infinity..0);
                                 1/2

In the second example, the answer that I would like to see would be (for the integral from -2 to 0)

1+exp(-2)+sin(-2)-2*(exp(RootOf(exp(_Z)+cos(_Z),-2..0))+
sin(RootOf(exp(_Z)+cos(_Z),-2..0)));

         1+exp(-2)+sin(-2)-2*(exp(RootOf(exp(_Z)+cos(_Z),-2..0))+
sin(RootOf(exp(_Z)+cos(_Z),-2..0)));

or, maybe,

1+exp(-2)+sin(-2)-2*(exp(RootOf(exp(_Z)+cos(_Z),-1.746139530))+
sin(RootOf(exp(_Z)+cos(_Z),-1.746139530)));

         1+exp(-2)+sin(-2)-2*(exp(RootOf(exp(_Z)+cos(_Z),-1.746139530))+
sin(RootOf(exp(_Z)+cos(_Z),-1.746139530)));

__________
Alec Mihailovs
http://mihailovs.com/Alec/

Is the proposed form for the antiderivative really superior?

I do see your point, now that I see the integrand was intended to be 1/(2+cos(x)) instead of 1/(1+2*cos(x)) .

The fact that Maple's indefinite integral for 1/(2+cos(x)) is not continuous, at least for real values of x, does kind of stink.

But nevertheless, Maple does seem to give the correct definite integral, so it is not altogether clear to me that the proposed form of the antiderivative, which has the virtue that it is continuous for real values of x, is vastly superior.

Yes, it might be less confusing if we shift the discontinuities of the antiderivative to live off the x-axis, but this might be presumptuous. If one is looking at the family integrate(1/(a+cos(z)),z), then one might actually find virtue to Maple's form of the antiderivative.

Much work is done on R, but much work is also done on C, and poor Maple can't read minds as well as humans can, and so it gets caught in the middle.

Maple Equation

integrate(1/(2+cos(x)),x=2..5);evalf(%);

Maple Equation

Maple Equation

F:=x->(x - 2*arctan(sin(x)/(2 + sqrt(3) + cos(x))))/sqrt(3);

F is the proposed nice antideriative, which is continous-at least for real values of x.

Maple Equation

F(5)-F(2);evalf(%);

Maple Equation

Maple Equation

Maple Equation

The antiderivatives lead to definite integrals that are numerically the same. It is not clear that we need to rock the boat. But it would probably be harmless enough.
alec's picture

A better place for inappropriate comments

Alex,

While your way of expressing yourself seems inappropriate to me, I received one letter that found it intelligent.

From my point of view, a better place for your posts would be in your blog and not in mine.

Would that be possible for you to ask the site administrator to move your comments to your blog?

__________
Alec Mihailovs
http://mihailovs.com/Alec/

JacquesC's picture

Missing theory

The most fundamental issue is that there is very little that has been done on the theoretical side for this problem. There are several papers by David Jeffrey on this from a few years back, but no one continued this research.

In other words, no one really knows how to fix this problem; what really saddens me is that the researchers who should be attacking this problem don't seem to care. In fact, looking at ISSAC for recent years, integration seems to have almost disappeared as a topic of research!

alec's picture

David Jeffrey and Maple

Yes, David W. Cantrell pointed out to me the 11th article from the bottom, joint with A.D. Rich. The 10th article from the bottom (without A.D. Rich) is very close to that. It seems that they described a working solution for trigonometric integrals. I wonder why it was not implemented in Maple. As we know, A.D. Rich implemented it in Derive.

__________
Alec Mihailovs
http://mihailovs.com/Alec/

Axel Vogt's picture

a question

while i would not mind the example with the absolute function
i would be interested in the others, they are periodic functions
and live on the circle S^1, so there is a natural factorization
IR^1 -> S^1 -> IR. Does that mean, that the antiderivative lives
on S^1 as well and one is seeking a lift to IR^1 ?
alec's picture

Bundles

Axel,

If I recall correctly, manifolds and differential geometry are a part of your specialty.

Certainly, you are right, an orientation of the circle gives an isomorphism between the tangent bundle TS1 and the trivial bundle S1×R1 (that can be visualized as a rotation of tangent vectors on 90 degrees in the vertical direction), so one can look at the derivatives and antiderivatives from that point of view. It is not very productive though, because even, say, non-zero constants don't have a global continuous antiderivative on the circle (it would look like one of the pictures of impossible objects - with stairs going always up around the circle). That may explain the discontinuous antiderivatives given by Maple for (some) trigonometric integrals.

__________
Alec Mihailovs
http://mihailovs.com/Alec/

Axel Vogt's picture

thx

Alec,

Thanks (so my earlier crimes where against commutative algebra in some of its geometric appearances ...)

JacquesC's picture

For silly reasons, AFAIK

The main issue is that David Jeffrey's solution is not so easy to implement, but the silly answer is that, at the time this was suggested, it would have been quite difficult to integrate into the existing architecture for Maple's int. Now, int has since been seriously revamped, so I don't know why this has not been done.

I know some people prefer the close-to-right answers because they look more elegant, while the fully correct answers can be somewhat unwieldly (I could repeat my previous comment about users and the truth).

Stepping back, I spent a very long time combing through a lot of bugs in integration, to classify them. This classification allowed us to fix quite a lot of them. But one conclusion came through loud and clear: the Fundamental Theorem of Calculus (FTOC) is a wonderful theoretical tool, but seems to be much less useful in practice. In other words, it is frequently the case the computing an anti-derivative, then finding all the singularities, then computing all the necessary limits, is a huge amount of work, much more so than seems necessary to compute the original definite integral! Other techniques (like the ones based on MeijerG functions for example) can be much more effective; of course, they have their own defects as well (too much built-in analytic continuation for many people's taste), but seem to point in an more interesting direction. Other techniques, like contour integration, are likewise quite promising; Maple's own implementation of this technique used to be quite flawed and thus was thought to be inferior by developers, but that was an artifact of the bad implementation rather than inherent in the technique.

Anyways, the original issue still stands: research in definite integration seems to have stopped, yet it is an area with lots and lots of interesting open problems.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}