In Jackson's book Classical Electrodynamics, 3rd ed., 1999, page 182 there is an integral (I'm editing the original here to keep it short) $$I = \int_0^{2\pi} \dfrac{\cos(\phi') d\phi'}{\sqrt{a^2 + r^2 - 2ar \sin(\theta) \cos(\phi')}} $$
$$ I = \dfrac{1}{\sqrt{a^2 + r^2}} \int_0^{2\pi} \dfrac{\cos(\phi') d\phi'}{\sqrt{1 - A \cos(\phi')}} $$
So, $$A = \dfrac{2ar \sin(\theta) }{a^2 + r^2} $$
Jackson says the integral can be expressed in terms of complete elliptic integrals K and E $$I = \dfrac{4((2 - k^2) K(k) - 2 E(k))}{k^2 \sqrt{a^2 + r^2 + 2ar \sin(\theta) }} $$
where
$$k^2 = \dfrac{4 a r \sin(\theta)}{a^2 + r^2 + 2ar \sin(\theta) } $$
However, when I use Mathematica to evaluate the integral it provides $$I_M = \dfrac{1}{\sqrt{a^2 + r^2}} \dfrac{4((A - 1) E(\dfrac{2A}{A-1}) + K(\dfrac{2A}{A-1}))}{A \sqrt{1 - A}} $$
Using the definition of A above, I have $$\dfrac{2A}{A-1} = \dfrac{-4 a r \sin(\theta)}{a^2 + r^2 - 2 a r \sin(\theta)} \equiv k_M^2$$
and
$$I_M = \dfrac{4((2 - k_M^2) K(k_M^2) + 2 E(k_M^2))}{k_M^2 \sqrt{a^2 + r^2 - 2ar \sin(\theta) }} $$
As you can see
$$I_M \ne I $$
with the power of "k" as argument to K() and E() not the same and some signs are different.
So, are Jackson's results wrong, or have typos? Or are the results from Mathematica wrong?
Can someone help show how Jackson's results are obtained, or verify that they are or are not in error? Thanks.
Additional material:
I guess the question comes down to what Mathematica is doing compared to some reference books.
For example, in Table of Integrals, Series, and Products, 7th edition by Gradshteyn and Ryzhik,
available online, there is, p. 180,
$$\int \dfrac{\cos(x) dx}{\sqrt{a - b \cos(x)}} = \dfrac{2}{b\sqrt{a + b}}\{(b-a)\Pi(\delta,r^2,r) + a F(\delta, r) \} $$
with (p. 179)
$$ r = \sqrt{\dfrac{2 b}{a + b}} $$
They define, p. 860
$$F(\phi, k) = \int_0^\phi \dfrac{d\alpha}{\sqrt{1 - k^2 \sin^2(\alpha)}} $$
so I can writes $$ k^2 = r^2 = \dfrac{2 b}{a + b} $$
Mathematica writes this integration result in terms of (I am just showing F() here)
$$F(\dfrac{x}{2}|\dfrac{-2b}{a-b}) $$
where the notation is
$$F(x|m) \text{with } m = k^2$$
Notice the "a - b" in the Mathematica result in the denominator. How to reconcile this with the "a + b" in the reference given above?
The Mathematica documentation for EllipticF[phi, m] gives
$$F(\phi | m) = \int_0^\phi \dfrac{d\theta}{\sqrt{1 - m \sin^2(\theta)}} $$
so these are essentually the same function, just slightly different notation.
Except the reference book for the integral I need gives a "a + b" and Mathematica gives "a - b".
What is the reason for this difference?