Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to integrate $$ \int_{0}^{2\pi} dt_1 \frac{a + b*\cos(t_1 - t_2)}{c + d*\cos(t_1 - t_2)} $$ where $a, b, c, d, t_2$ are real numbers and $c + d > 0$ & $0 \leq t_2 \leq 2\pi$.
I used a straightforward command in Mathematica (9.0.1.0),

Integrate[(a + b*Cos[t1 - t2])/(c + d*Cos[t1 - t2]), {t1, 0, 2 π}, 
  Assumptions -> {a ∈ Reals, b ∈ Reals, c >= 0, d <= 0, c + d >= 0, 0 <= t2 <= 2π}]

to get an obviously incorrect answer: $$2\pi \frac{b}{d},$$ because clearly the integral should be $\propto c^{-1}$ for $|c| \gg |d|$.

My question is what am I doing wrong here? Is there a general lesson to be learnt here about how Mathematica handles this kind of integrations and the correct way to ask it to perform such integrations?

share|improve this question
    
@Kuba: Sorry. In my code I had the $A, \ldots, D$ in terms of four Greek alphabets. While writing here I mistakenly used $A, \ldots, D$. I corrected the question. Thanks for pointing this out. –  vik May 23 at 23:13
    
@belisarius maybe, I've not checked :) only a note. –  Kuba May 23 at 23:15

3 Answers 3

This question provides another example of a bug in Integrate (see e.g. this post).
Rewriting the integrand, we can get an idea why the result is incorrect:

Apart[(a + b Cos[t1 - t2])/(c + d Cos[t1 - t2])]
 b/d + (-b c + a d)/(d (c + d Cos[t1 - t2]))

the first term contributes to the result while the integral of the second term vanishes (incorrectly!):

Integrate[(-b c + a d)/(d (c + d Cos[t1 - t2])), {t1, 0, 2 π}, 
           Assumptions -> (a | b) ∈ Reals && c >= 0 && d <= 0 && 
                          c + d >= 0 && 0 <= t2 <= 2 π]
0

Putting appropriate values into Integrate instead of symbolic constants we get reliable results, we can compare them with NIntegrate. Assuming another relations between symbolic constants we can conclude that the source of this bug is the assumption on the phase t2. Therefore if we remove the symbolic phase t2 (we can put a numeric value e.g. π/2) we'll find the correct result:

Integrate[(a + b Cos[t1 - π/2])/(c + d Cos[t1 - π/2]), {t1, 0, 2 π}, 
           Assumptions -> (a | b) ∈ Reals && c >= 0 && d <= 0 && c + d >= 0]
ConditionalExpression[
    (2 (a d + b (-c + Sqrt[c^2 - d^2])) π)/(d Sqrt[(c - d) (c + d)]),
     d < 0 && c + d > 0]

We can verify that when $|c| \gg |d|$ this conditional expression behaves well:

Simplify[ Series[ %, {d, 0, 0}], c > 0]
ConditionalExpression[ (2 a π)/c + O[d]^1, d < 0 && c + d > 0]

Moreover the result does not depend on the phase t2 since we calculate the integrad depending on Cos[t1 - t2] over its total period 2 π.

share|improve this answer
    
Thanks for your comment in my (now deleted) answer –  belisarius May 24 at 13:04

This seems related to Bug in mathematica analytic integration?

Using the standard substitution

int = Simplify[(a + b*Cos[t1 - t2])/(c + d*Cos[t1 - t2]) Dt[t1] /. 
     t1 -> t2 + 2 ArcTan[u] // TrigExpand] /. {Dt[t2] -> 0,  Dt[u] -> 1}
(*
  (2 (a + b + a u^2 - b u^2))/((1 + u^2) (c + d + c u^2 - d u^2))
*)

we obtain

Integrate[int, {u, -Infinity, Infinity}, 
 Assumptions -> {c >= 0, d <= 0, c + d > 0}]
(*
  (2 (a d + b (-c + Sqrt[c^2 - d^2])) π)/(d Sqrt[c^2 - d^2])
*)

It seems annoying, imo, that a standard class of integrals is not handled properly.

share|improve this answer

It appears Mathematica is using the fundamental theorem of calculus even though it's not valid in this case. Observe:

Simplify[Subtract @@ (Integrate[(a + b*Cos[t1 - t2])/(c + d*Cos[t1 - t2]), t1] /. 
  {{t1 -> 2 Pi}, {t1 -> 0}})]
(* 2*b*Pi/d *)

It's a tough problem to know when you can use FToC. See here for further explanation with an example similar to yours.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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