2
$\begingroup$

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.

$\endgroup$
2

2 Answers 2

5
$\begingroup$

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.

$\endgroup$
9
  • $\begingroup$ +1 for your answer $\endgroup$
    – Max
    Mar 12, 2023 at 6:06
  • $\begingroup$ What is the limit of the answer as $a\to 0$? $\endgroup$
    – Max
    Mar 12, 2023 at 6:11
  • $\begingroup$ @Max Mathematica can not evaluate the limit as a->0. But it can for any value greater than zero. Limit[Beta[-1, -a, 1 + a], a -> 0] returns unevaluated. It could be due to branch cut at this value. $\endgroup$
    – Nasser
    Mar 12, 2023 at 6:13
  • $\begingroup$ Thanks you a lot. $\endgroup$
    – Max
    Mar 12, 2023 at 6:19
  • $\begingroup$ I suspect the Limit limitation arises from Series balking at having the variable of interest appear in more than one argument of Beta. $\endgroup$ Mar 12, 2023 at 15:25
1
$\begingroup$

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"}]
$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Max
    Mar 13, 2023 at 12:03
  • $\begingroup$ 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 $\endgroup$
    – Max
    Mar 19, 2023 at 17:14
  • $\begingroup$ @Max .This is not the right forum for math and proofs. Maybe you’ll have better luck at the math StackExchange. $\endgroup$ Mar 21, 2023 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.