Re: Integrate (discontinuous antiderivatives by Mathematica)

*To*: mathgroup at smc.vnet.net*Subject*: [mg74503] Re: Integrate (discontinuous antiderivatives by Mathematica)*From*: "dimitris" <dimmechan at yahoo.com>*Date*: Fri, 23 Mar 2007 19:09:52 -0500 (EST)*References*: <etikok$j7r$1@smc.vnet.net><etnkbj$gmr$1@smc.vnet.net>

Hello again. Copy/Paste the following in an notebook as a whole cell Print["a function"] f[x_]=1/(5 + Cos[x]) Print["its plot in [0,4Pi]"] Plot[f[x],{x,0,4Pi}] Print["its definite integral in the same interval"] Integrate[1/(5 + Cos[x]), {x, 0, 4*Pi}] Print["check"] {N[%%], NIntegrate[1/(5 + Cos[x]), {x, 0, 4*Pi}]} Print["antiderivative by Mathematica"] F[x_] = Integrate[1/(5 + Cos[x]), x] Print["check the antiderivative"] D[F[x],x]//Simplify Print["incorrect application of Newton-Leibniz formula"] (F[x] /. x -> 4*Pi) - (F[x] /. x -> 0) Print["the incosistency is due to the jump discontinuities at Pi and 3Pi of the antiderivative"] Plot[F[x], {x, 0, 4*Pi}, Ticks -> {Range[0, 4*Pi, Pi], Automatic}] Print["correct application of Newton-Leibniz formula"] FullSimplify[(F[x]/. x -> 4*Pi) - Limit[F[x], x -> 3*Pi, Direction -> -1] + Limit[F[x], x -> 3*Pi, Direction -> 1] - Limit[F[x], x -> Pi, Direction -> -1] + Limit[F[x], x -> Pi, Direction -> 1] - (F[x]/. x -> 0)] Print["define an atiderivative continuous in the whole integration range"] FF[x_]=Piecewise[{{F[x],x < Pi},{Pi/2/Sqrt[6],x==Pi},{F[x] + Pi/ Sqrt[6],x<3Pi},{3Pi/2/Sqrt[6],x == 3Pi},{F[x] + 2 Pi/Sqrt[6],x<5Pi}}] Print["its plot"] Plot[FF[x], {x, 0, 4*Pi}, Ticks -> {Range[0, 4*Pi, Pi], Automatic}] Print["application of Newton-Leibniz formula"] FF[4Pi]-FF[0] As you see Mathematica returns again a discontinuous function in the integration range as an antidrivative. In fact usually this will be the case. BUT Nothing is bad with it! You must convinced yourself! In another CAS I got: int(1/(5+cos(x)),x); 1/6*6^(1/2)*arctan(1/3*tan(1/2*x)*6^(1/2)) plot(%,x=0..4*Pi); which again has jump discontinuities at Pi and 3Pi. BTW, the vertical lines appeared in the plots connected the jumps are due to buggy behavior of the CASs and should be there. A quick way to remove them in Mathematica e.g. for the obtained antiderivative above Show[Block[{$DisplayFunction = Identity}, (Plot[F[x], {x, #1[[1]], #1[[2]]}] & ) /@ Partition[Range[0, 4*Pi, Pi], 2, 1]]] And note that the situation can be "worse" (note the quotes!) Even for everywhere smooth function the indefinite integral returned by Mathematica might be discontinuous and complex! Print["another function"] f[x_] = (Exp[x] - 1)/x Print["its plot in [-Pi,Pi]"] Plot[f[x], {x, -Pi, Pi}, Axes -> False, Frame -> True] Print["its definite integral in the same interval"] Integrate[f[x], {x, -Pi, Pi}] Print["check"] {N[%%], NIntegrate[f[x], {x, -Pi, 0, Pi}]} Print["antiderivative by Mathematica"] F[x_] = Integrate[f[x], x] Print["check the antiderivative"] Simplify[D[F[x], x]] Print["the antiderivative has real and imaginary part"] (Plot[#1[F[x]], {x, -Pi, Pi}, FrameTicks -> {Range[-Pi, Pi, Pi/2], Automatic}, Axes -> False, Frame -> {True, True, False, False}] & ) /@ {Re, Im} Print["incorrect application of Newton-Leibniz formula"] Limit[F[x], x -> Pi, Direction -> 1] - Limit[F[x], x -> -Pi, Direction -> -1] N[%] Print["correct application of Newton-Leibniz formula must consider the jump discontinuity at x=0"] Limit[F[x], x -> Pi, Direction -> 1] - Limit[F[x], x -> 0, Direction - > -1] + Limit[F[x], x -> 0, Direction -> 1] - Limit[F[x], x -> -Pi, Direction -> -1] But again nothing is bad with it! Best Regards Dimitris =CF/=C7 Michael Weyrauch =DD=E3=F1=E1=F8=E5: > Hello , > > sorry for not writing earlier in response to your comments... > > 1) These are really interesting examples of odd behaviour of our beloved > CAS (related to Integration) you have been digging up. You even found= undocumented features...! > > 2) Unfortunately, we cannot know in more detail why all this happens, bec= ause > we do not know how it really operates internally. And the devellopers= who know, obviously do not > want to answer??? > > 3) For now I am glad that I have your workaround for my problem. > > I would like to mention that I also sent in a service call to Wolfram= research > thanks to a Premier Service contract my company pays for. But never g= ot an answer. > > I perfectly understand that such a huge and difficult program as Math= ematica has problems > in some odd corners. And sometimes I really got great support and hel= p in surmounting my problems > by the support engineers or the devellopers, but here .... zero ...= I wonder, if anybody else had similar experience > recently ?? > > Regards Michael Weyrauch

**Re: Definite Integration in Mathematica**

**Re: a suprising result from Integrate (Null appeared in the result!)**

**Re: Which Mathematica product should I get?**

**Re: Integrate (a difficult integral)**