# Find area under real part of complex curve without numerically integrating

I have a function defined within the domain 0<=x<=2*Pi.

f = Cos[x] * (a - 1 - r*Cos[x])^1.5 on the domain: ArcCos[(a-1)/r] < x < 2*Pi-ArcCos[(a-1)/r]

f = 0 elsewhere

'a' and 'r' are constants. I need to find the area under this curve from 0 to 2 Pi. Mathematically this is the same as saying:

Integrate[Cos[x] * (a - 1 - r*Cos[x])^1.5, {x, ArcCos[(a-1)/r], 2*Pi-ArcCos[(a-1)/r]}]


Sadly Mathematica struggles to evaluate this correctly. So I tried investigating by plotting the first part of the function f (using a=0.1, r=4) and plotting its indefinite integral (call it g). The function g looks incorrect because it has a discontinuity at Pi. Since it's the area under the curve f you'd expect g(x) < 0 and continuous within this domain.

I'm no expert at Matheamtica so I don't want to claim it's a bug, but if someone can help me find out what I'm doing wrong or help me find the area under the curve then I would be very appreciative!  • Please, post always all code in copyable form (and not as images - although images of the plots are very welcome). That makes it easier for other users to help you. Feb 24 '19 at 17:58

Making use of the natural assumptions on a and r, one obtains a correct result by

j = Integrate[Cos[x]*(a - 1 - r*Cos[x])^3/2, {x, ArcCos[(a - 1)/r],
2*Pi - ArcCos[(a - 1)/r]}, Assumptions -> -1 < (a - 1)/r < 1]


A long output is omitted. One verifies it by

j /. {a -> 0.1, r -> 4}


-15.806-4.44089*10^-16 I

and

a=0.1;r=4;NIntegrate[Cos[x]*(a-1-r*Cos[x])^3/2, {x,ArcCos[(a - 1)/r],2*Pi-ArcCos[(a-1)/r]}]


-15.806

• You get a simpler form using j = Assuming[-1<(a-1)/r<1, Integrate[Cos[x]*(a-1-r*Cos[x])^3/2, {x, ArcCos[(a-1)/r], 2*Pi-ArcCos[(a-1)/r]}] // ComplexExpand[#, TargetFunctions -> {Re, Im}]& // Simplify]. Then, j /. {a->1/10, r->4} // FullSimplify and % // N Feb 24 '19 at 19:29
• @Bob Hanlon: Thank you for your valuable simplification. Feb 24 '19 at 19:49
• Matthew: user64494 and Bob Hanlon didn't mention this explicitly, but note that one of the changes they made was to replace 1.5 with 3/2. This is because, as a general rule, one gets better results with symbolic integrations in Mathematica by replacing all approximate (decimal) numbers with "exact" numbers. Feb 25 '19 at 8:11