2

Consider the integral $$I(a)=\int_{0}^{\pi/2} \cos^a (x)\sin(ax) dx$$ where $a\geq 0$

I am trying to evaluate the above integral using Mathematica using the following code :

int[a_] = Assuming[a >= 0,
  Integrate[Cos[x]^a*Sin[a*x], {x, 0, Pi/2}] // FullSimplify]

The answer we get is -2^(-1 - a) (E^(I a π) Beta[-1, -a, 1 + a] + π Cot[a π])

Problem is that the definite integral was real for $a\geq 0$ but the answer contains imaginary number $i=\sqrt{-1}$. How do we get a real answer?

Any help would be appreciated.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Max
  • 145
  • 7

2 Answers2

5

answer contains imaginary number i . How do we get a real answer?

Just because the answer contains $i$ does not necessarily mean the overall value is also complex. it depends on what is inside the expression (what type of special functions are involved, some cancelations that can occur and so on).

You can see that by plotting the antiderivative for some range of $a$, that it does plot OK. It will not have plotted if the result was complex (you would get blank plot if there were complex values anywhere in the result).

 sol = Integrate[Cos[x]^a*Sin[a*x], {x, 0, Pi/2}, Assumptions -> a >= 0]

Mathematica graphics

 Plot[sol, {a, 0, 10}]

Mathematica graphics

In addition, you can evaluate numerically the antiderivative for some $a$ values. They are all real

 Table[Limit[sol, a -> a0], {a0, 0.1, 3, .1}] // Chop

Mathematica graphics

You can see that also from evaluating Beta

  Limit[E^(I a Pi) Beta[-1, -a, 1 + a] , a -> 1.2]

Mathematica graphics

It is real value even though there is E^(I a Pi) in there. This happens in this case because the incomplete beta function can generate complex value and this cancels the complex values coming from E^(I a Pi)

 p1= Limit[Beta[-1, -a, 1 + a], a -> 1.2]

Mathematica graphics

  p2 = Limit[E^(I a Pi), a -> 1.2]

Mathematica graphics

  p1*p2

Mathematica graphics

So the rule of the thumb is: Just because an expression has $i$ this does not always implies the overall expression value will also be complex. It depends.

Nasser
  • 143,286
  • 11
  • 154
  • 359
1

Workaround: using formula:

$$\sum _{j=1}^a \frac{\binom{a}{j} \sin (2 j x)}{2^a}=\cos ^a(x) \sin (a x)$$ We have:

$\int_0^{\frac{\pi }{2}} \cos ^a(x) \sin (a x) \, dx=2^{-1-a} \gamma +2^{-1-a} a \, _3F_2(1,1,1-a;2,2;-1)+2^{-1-a} \psi (1+a)$

The answer not contains imaginary number.

S = Sum[Integrate[Binomial[a, j]*Sin[2 j x ]/2^a, {x, 0, Pi/2}], {j, 1, a}] // Expand

(2^(-1 - a) EulerGamma + 2^(-1 - a) a HypergeometricPFQ[{1, 1, 1 - a}, {2, 2}, -1] + 2^(-1 - a) PolyGamma[0, 1 + a])

Limit[S, a -> 0] (* 0 ) S /. a -> 0 ( 0*)

EDITED: 15.03.2023

My formula works for $a\in \mathbb{R}$ ,see below:

int[a_?NumericQ] := NIntegrate[Cos[x]^a*Sin[a*x], {x, 0, Pi/2}, 
Method -> "LocalAdaptive"] // Quiet;
Plot[{int[a], S}, {a, -1, 3}, PlotLegends -> {"Numeric", "Symbolic"}, PlotStyle -> {Red, {Dashed, Black}}]
Plot[{int[a] - S}, {a, -1, 3}, PlotLegends -> {"Residuals"}]
Mariusz Iwaniuk
  • 13,841
  • 1
  • 25
  • 41
  • Thanks for your answer. +1. But $a$ is a non negative real number, so the sum cannot run from $j=1$ to $a$. Please help me with this. Most humbly I will accept your answer. – Max Mar 13 '23 at 12:03
  • Thanks a lot. Please show using mathematica or otherwise that for $a\geq 0$, $$\int_0^{\frac{\pi }{2}} \cos ^a(x) \sin (a x) , dx=2^{-1-a} \gamma +2^{-1-a} a , _3F_2(1,1,1-a;2,2;-1)+2^{-1-a} \psi (1+a)$$ I will with utmost respect accept your answer – Max Mar 19 '23 at 17:14
  • @Max .This is not the right forum for math and proofs. Maybe you’ll have better luck at the math StackExchange. – Mariusz Iwaniuk Mar 21 '23 at 09:27