I got an interesting question about integration yesterday. The question was about the integral of the rather innocuous looking function f := sqrt(1+sin(x)). The inside of the square root is always non-negative so the function is continuous (and bounded!) so it must have a continuous integral. The question I was asked, was if the following result was a bug in Maple: Int(sqrt(1+sin(x)),x) = (2*(sin(x)-1))*sqrt(1+sin(x))/cos(x) since the right-hand side is definitely not continuous at x=-Pi/2 + 2*n*Pi! It is not a bug, since the returned expression is an anti-derivative of f everywhere it is defined: simplify(f - diff((2*(sin(x)-1))*sqrt(1+sin(x))/cos(x),x)) = 0 So, in a strictly algebraic sense the answer is right. But as a function it is definitely not continuous. This would be problematic if one was going to try to use the formula for definite integration. For example: using F:=int(f,x) then you can compute Int(f, x=0..2*Pi)=2*sqrt(4) and that is not equal to (eval(F,x=2*Pi))-(eval(F,x=0)) = 0. The Fundamental Theorem of Calculus does not work here since F is discontinuous on the interval [0, 2*Pi]. Fortunately, Maple's definite integrator is smart enough to get this right. Both exact: int(f,x=0..2*Pi) and numerical: evalf(Int(f, x=0..2*Pi)) integration get the right answer. But calculus tells us for any interval, say [0,a], there is continuous function G that is an antiderivative of f on [0,a]. So how do we get our hands on a formula for G? Unfortunately, G := Int(f,x=0..a) doesn't work. It just gives us the formula of the discontinuous anti-derivative. Here's one way. We know that for a constant C, F+C is an anti-derivative of f for x where it is defined. The trick is use different values of the constant C on the different intervals where F is continuous. I start with G(0) = 0, with G1 := F - (eval(F,x=0)). Then I look at the first continuous interval of G1, namely [-Pi/2, 3/2*Pi]. On this interval, G1 = int(sqrt(1+sin(t)),t=0..x). However, for a>3/2*Pi, G1 needs to be shifted up by C:=(limit(G1, x = 3/2*Pi, left))-(limit(G1, x = 3/2*Pi, right)) = 4*sqrt(2). However, another 2*Pi up the road, it is going to need to be shifted up by 2*C and so on. So this is my continuous antiderivative of f: G := G1 + floor( (x + Pi/2) / (2*Pi) ) * C This still is not quite perfect. My formula for G still has removable discontinuities at x=-Pi/2 + 2*n*Pi and so Maple does not give 0 for: simplify(f - diff(G,x); In fact it returns: -4*floor(1, (1/4)*(2*x+Pi)/Pi)*sqrt(2) However, a quick look at the help page for floor, shows that this is essentially 0, since:
For floor, the two-argument case indicates the nth derivative of the function at x. These derivatives are 0 wherever they are defined.
I compute G (but call it H, oops) and put graph the various ways to compute the antiderivative in the attached worksheet. View 5480_intblog1.mw on MapleNet or Download 5480_intblog1.mw
View file details

Please Wait...