1

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.

Max
  • 145
  • 7
  • 1
    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 – Nasser Mar 11 '23 at 13:03
  • 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 – Nasser Mar 11 '23 at 13:15
  • @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. – Max Mar 11 '23 at 13:19
  • 2
    Re ÷ 0: Have you heard of Limit? -- "Please do 'full simplify'": Sheesh! Look it up. – Michael E2 Mar 11 '23 at 13:24
  • @MichaelE2 Sorry, but what do you mean by "Re" in Re÷0? – Max Mar 11 '23 at 13:33
  • Isn't division by zero the problem you're referring to, when you say $I(a,b)$ is not defined for $a=0,b=0$? Or did I misunderstand? Or overlooked some other problem, because I didn't investigate very far? – Michael E2 Mar 11 '23 at 13:48
  • Pi/2??!! If b is 0 then the integrand is 0 so the definite integral is 0. – Daniel Lichtblau Mar 11 '23 at 20:34

3 Answers3

4

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$.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
3

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}

]

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • See(https://www.wolframalpha.com/input?i=limit+Hypergeometric2F1%281%2C%282%2Ba-b%29%2F2%2C%282-a-b%29%2F2%2C-1%29%2F%28a%2Bb%29+as+a-%3E0%2C+b-%3E0) I am getting limit does not exists – Max Mar 11 '23 at 13:40
  • @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. – Nasser Mar 11 '23 at 13:47
  • 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. – Nasser Mar 11 '23 at 13:52
  • Ok then please see if we can get the answer of that limit as $\pi/2$. – Max Mar 11 '23 at 14:14
  • Ok. My bad. I got it now. Thanks a lot.:) – Max Mar 11 '23 at 15:36
2
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 *)

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • 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? – Max Mar 11 '23 at 17:50
  • 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. – Bob Hanlon Mar 11 '23 at 18:30
  • Thanks. Then how do we get a real answer from the result? Do we have to take real parts? – Max Mar 11 '23 at 18:54
  • 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. – Bob Hanlon Mar 11 '23 at 19:14
  • Please help me to get a real answer. I will with utmost respect accept your answer. – Max Mar 12 '23 at 04:50
  • Again, int[a] is real. What is the actual problem? What are you trying to do that you cannot do? – Bob Hanlon Mar 12 '23 at 06:15
  • How is int[a] real? It contains $e^(i \pi a)$ which I think makes it imaginary. – Max Mar 12 '23 at 06:18
  • Real numbers and real functions can contain complex elements. When evaluated, the imaginary components all cancel out to produce real values. For example, see casus irreducibilis – Bob Hanlon Mar 12 '23 at 06:32
  • Thanks a lot for the link. It was useful – Max Mar 12 '23 at 06:43
  • @Max This link is even more useful: https://mathematica.stackexchange.com/a/282220/82985 please note my comments in the answer. In fact it may still be almost Real, but in some cases you can get antiderivative that is just -I Pi/2 difference as part of the whole +C business. That is not going to plot. – Валерий Заподовников Jul 01 '23 at 04:32