2
$\begingroup$

I think this is undesirable behavior in a new version.

Integrate[Cos[l*θ]*Sin[lp*θ]*Sin[θ], {θ, 0, π}]

Will return the formula:

1/4 (Sin[(l - lp) π]/(-1 + l - lp) + Sin[(1 + l - lp) π]/(
   1 + l - lp) - (2 Sin[(l + lp) π])/((-1 + l + lp) (1 + l + lp)))

Which is valid when |l-lp| != 1, and is otherwise indeterminate. For example Integrate[ Cos[2 θ] Sin[3 θ] *Sin[θ], {θ, 0, π}] is (correctly) pi/4 Whereas if you simplify the previous answer assuming l,lp are integers you will get zero (which is just wrong)

Does anyone know how to avoid this behavior? I have clear memories of these types of integrals being treated properly in previous versions.

$\endgroup$
6
  • 1
    $\begingroup$ The option GenerateConditions -> True is meant for this purpose but it does not seem to have any effect here, apart from triggering some simplification. 10.4.1 behaves the same as 11.0.1. $\endgroup$
    – bbgodfrey
    Commented Nov 23, 2016 at 14:29
  • 1
    $\begingroup$ This is normal and common behaviour for all computer algebra systems. It's essentially the same as Integrate[Cos[a x], {x, 0, 2 Pi}], where you might ask what about $a=0$. The result may not be valid for certain specific values of the parameters. This does not usually happen when the result is only valid for a range of parameter values: in that case it will usually return a ConditionalExpression. Conditions aren't usually generated for single values. I'll note that the result, as written, is valid in the limit of lp -> l, and also that it is not true that it simplifies to zero. $\endgroup$
    – Szabolcs
    Commented Nov 23, 2016 at 14:34
  • 1
    $\begingroup$ I suppose another reason that a ConditionalExpression is not generated is that the answer is correct even when its denominator vanishes, as can be seen from Limit[%, #] & /@ Solve[Denominator[%] == 0, l], where % here represents the solution of the integral, simplified to have a common denominator. $\endgroup$
    – bbgodfrey
    Commented Nov 23, 2016 at 14:42
  • $\begingroup$ You can run Assuming[{l - lp == 1}, Integrate[ Cos[l*\[Theta]]*Sin[lp*\[Theta]]*Sin[\[Theta]], {\[Theta], 0, \[Pi]}]] and Assuming[{l - lp != 1}, Integrate[ Cos[l*\[Theta]]*Sin[lp*\[Theta]]*Sin[\[Theta]], {\[Theta], 0, \[Pi]}]] to differentiate the two explicitly. $\endgroup$
    – Feyre
    Commented Nov 23, 2016 at 14:42
  • $\begingroup$ @Szabolcs - I believe that he meant "assuming l, lp are integers" rather than "assuming l, lp are reals" $\endgroup$
    – Bob Hanlon
    Commented Nov 23, 2016 at 14:44

1 Answer 1

3
$\begingroup$

At the risk of belaboring my comment above, I would assert that Integrate is producing a correct answer. To see that this is so, obtain the solution in a form that explicitly shows the apparent singularities.

s = Simplify@Together@Integrate[Cos[l*θ]*Sin[lp*θ]*Sin[θ], {θ, 0, π}]
(* (2 l lp Cos[lp π] Sin[l π] - (-1 + l^2 + lp^2) Cos[l π] Sin[lp π])
   /((-1 + l - lp) (1 + l - lp) (-1 + l + lp) (1 + l + lp)) *)

The four singularities are removable in the sense that the numerator and denominator vanish together and have a finite limit.

Limit[s, #] & /@ Solve[Denominator[s] == 0, l]
(* {{(-2 lp (1 + lp) π + Sin[2 lp π])/(8 lp (1 + lp))}, 
    {( 2 (-1 + lp) lp π + Sin[2 lp π])/(8 (-1 + lp) lp)}, 
    {( 2 (-1 + lp) lp π + Sin[2 lp π])/(8 (-1 + lp) lp)}, 
    {(-2 lp (1 + lp) π + Sin[2 lp π])/(8 lp (1 + lp))}} *)

Plotting the solution also shows that it is well-behaved everywhere.

Plot3D[s, {l, -2, 2}, {lp, -2, 2}]

enter image description here

The white curves, indicating where the numerator and denominator together vanish, can be removed with the option Exclusions -> None, if desired. Of course, Limit must be used when performing numerical calculations using s at the locations of the removable singularities.

$\endgroup$
1
  • $\begingroup$ Nice explanation and thanks for belaboring. $\endgroup$ Commented Nov 23, 2016 at 16:11

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