1
$\begingroup$

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

I am requesting a code in Wolfram Mathematica so as to write the non negativity restrictions of $a$ and $b$ and to find an answer for the above integral in terms of Hypergeometric functions or other functions.

Sorry, I am new to Wolfram Mathematica.

Any help would be appreciated.

$\endgroup$
7
  • 1
    $\begingroup$ Did you try the Integrate command? V 13.2 can do it. Here is the command ClearAll[a, b, x]; Integrate[Cos[x]^a*Sin[b*x], {x, 0, Pi/2}, Assumptions -> {a >= 0, b >= 0}] It gives !Mathematica graphics $\endgroup$
    – Nasser
    Mar 11, 2023 at 13:03
  • $\begingroup$ FullSimplify gives same thing. Hypergeometric2F1[1, (1/2)*(2 + a - b), (1/2)*(2 - a - b), -1]/(a + b) + Hypergeometric2F1[1, (1/2)*(2 + a + b), (1/2)*(2 - a + b), -1]/(-a + b) + (2^(-1 - a)*Pi*Gamma[1 + a]*Sin[b*Pi])/((-Cos[a*Pi] + Cos[b*Pi])*Gamma[(1/2)*(2 + a - b)]*Gamma[(1/2)*(2 + a + b)]) screen shot !Mathematica graphics $\endgroup$
    – Nasser
    Mar 11, 2023 at 13:15
  • $\begingroup$ @Nasser Thank you so much. But then when $a=0$ and $b=0$, we have by direct computation by hand, $I(a,b)=\pi/2$ but in the answer given by mathematica it has $(a+b)$ and $(a-b)$ in the denominator, which makes $I(a,b)$ not defined for $a=0,b=0$. Please see if I am missing something trivial. $\endgroup$
    – Max
    Mar 11, 2023 at 13:19
  • 2
    $\begingroup$ Re ÷ 0: Have you heard of Limit? -- "Please do 'full simplify'": Sheesh! Look it up. $\endgroup$
    – Michael E2
    Mar 11, 2023 at 13:24
  • $\begingroup$ @MichaelE2 Sorry, but what do you mean by "Re" in Re÷0? $\endgroup$
    – Max
    Mar 11, 2023 at 13:33

3 Answers 3

4
$\begingroup$

For $0\le x \le {\pi\over2}$, $a\ge0$, $b\ge0$, we have $0 \le \cos x \le 1$ and $0 \le \sin bx \le bx$, and therefore the integrand is bounded by $0 \le \cos^a x \sin bx \le bx$ and the integral by $0 \le I(a,b) \le {\pi ^2 \over 8}\,b$, which is also the asymptotic value as $a\rightarrow0, b\rightarrow0$.

$\endgroup$
1
  • $\begingroup$ Thanks a lot for your valuable inputs. $\endgroup$
    – Max
    Mar 11, 2023 at 15:53
3
$\begingroup$

This is getting too long to keep using comments. You need to use Limits for the special cases, then it works

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

Mathematica graphics

Limit[sol, {a -> 0, b -> 0}]

Mathematica graphics

i.e. do not do

 sol /. {a -> 0, b -> 0}

Mathematica graphics

Tried Maple 2023 and it can't solve it. Maxima 5.46 can't do it, giac can't do it. Sympy can't do it. Tried Fricas 1.3.8 and it also can't solve it, it says:

(1) -> integrate(cos(x)^a*sin(b*x),x=0..%pi/2)    
   (1)  "potentialPole"

So far only Mathematica can integrate it and says the answer is zero when a->0,b->0. Rubi is not meant to be used on definite integration.

see if we can get the answer of that limit as π/2

I do not know why you think the limit should be Pi/2 as a->0,b->0

Just plotting the integrand as a->0,b->0 shows clearly that area under the curve is shrinking more and more to zero. Since integration is the area under the curve, then zero seems like the correct result.

enter image description here

Manipulate[
 Plot[Cos[x]^a*Sin[b*x], {x, 0, Pi/2}, 
  PlotRange -> {Automatic, {0, 1}}],
 {{a, 2, "a"}, 2, 0.01, -0.01, Appearance -> "Labeled", 
  ContinuousAction -> False},
 {{b, 2, "b"}, 2, 0.01, -0.01, Appearance -> "Labeled", 
  ContinuousAction -> False},
 TrackedSymbols :> {a, b}
 
 ]
$\endgroup$
5
  • $\begingroup$ See(wolframalpha.com/…) I am getting limit does not exists $\endgroup$
    – Max
    Mar 11, 2023 at 13:40
  • $\begingroup$ @Max I can't answer why Mathematica does not give $\frac{\pi}{2}$ and if its answer is correct or not. I assume that zero is correct answer since that is what it gives. If you think this is the wrong answer, it could be a bug. I do not know myself now. I tried Maple to compare, but Maple can not solve it. $\endgroup$
    – Nasser
    Mar 11, 2023 at 13:47
  • $\begingroup$ So the limit of I(a,b) as a→0,b→0 is indeterminate? No. The limit is zero. It is when you plugin in $a=0,b=0$ that you get indeterminate. You need to use the Limit command instead. $\endgroup$
    – Nasser
    Mar 11, 2023 at 13:52
  • $\begingroup$ Ok then please see if we can get the answer of that limit as $\pi/2$. $\endgroup$
    – Max
    Mar 11, 2023 at 14:14
  • $\begingroup$ Ok. My bad. I got it now. Thanks a lot.:) $\endgroup$
    – Max
    Mar 11, 2023 at 15:36
2
$\begingroup$
Clear["Global`*"]

When b == a the integral simplifies to

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

(* -2^(-1 - a) (E^(I a π) Beta[-1, -a, 1 + a] + π Cot[a π]) *)

Plot[int[a], {a, 0, 20}]

enter image description here

Near a == 0

Plot[int[a], {a, 0, 1/100}, WorkingPrecision -> 25]

enter image description here

This is consistent with the other answers that show the limit is zero.

EDIT: To find the maximum

argMax = FindRoot[int'[a] == 0, {a, 3/2}, WorkingPrecision -> 20] // N

(* {a -> 1.4304} *)

max = int[a] /. argMax // Chop

(* 0.522152 *)
$\endgroup$
10
  • $\begingroup$ Thank you. Your answer is awesome. I have a question. In the answer we have complex numbers involved, but the integral was real. How to get a real answer? Do we have to take the real part of the answer? $\endgroup$
    – Max
    Mar 11, 2023 at 17:50
  • $\begingroup$ The presence of the complex constant I does not mean that the expression is complex. If it were complex, the plot would not show. However, when evaluating--for the cancellation of the imaginary parts to occur precisely enough--precision control is generally required. In the second plot, a WorkingPrecision was specified to switch from machine precision to arbitrary-precision. If instead you use Plot[int[a], {a, 0, 1/100}] there are gaps in the plot were the lack of precision results in complex artifacts. In that case, Re could be used to remove the artifacts. $\endgroup$
    – Bob Hanlon
    Mar 11, 2023 at 18:30
  • $\begingroup$ Thanks. Then how do we get a real answer from the result? Do we have to take real parts? $\endgroup$
    – Max
    Mar 11, 2023 at 18:54
  • $\begingroup$ int[a] is real for a >= 0; it merely appears complex. You can, for example, use int[0.1] // Real or int[0.1] // Chop to remove the negligible artifacts. $\endgroup$
    – Bob Hanlon
    Mar 11, 2023 at 19:14
  • $\begingroup$ Please help me to get a real answer. I will with utmost respect accept your answer. $\endgroup$
    – Max
    Mar 12, 2023 at 4:50

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