# Integrate over a region

I am trying to calculate a integral over a region defined by

But I dont really know how to do it, I dont know if I have to work in cartesian coordinates or polar coordinates.

The function that I want to integrate is

$$\qquad f(x,y) = x^2+y^2-2ax+ \frac{2b^2ax}{x^2+y^2}-b^2$$.

Mathematica makes this fairly simple. We can define a region

region = RegionDifference[Disk[{a, 0}, a], Disk[{0, 0}, b]]
(* BooleanRegion[#1 && ! #2 &, {Disk[{a, 0}, a],
Disk[{0, 0}, b]}] *)

You can visualise this quite simply, for specific values of a and b with the following line

Block[{a = 3, b = 1}, Region[region]]

and an integrand

integrand = x^2 + y^2 - 2 a x + 2 b^2 a x/(x^2 + y^2) - b^2;

and simply apply Integrate. I hope you find the result informative!

Assuming[0 < b < a,
Integrate[integrand, {x, y} ∈ region]]
(* 1/24 (-6 a^2 b Sqrt[4 a^2 - b^2] -
21 b^3 Sqrt[4 a^2 - b^2] - 12 a^4 π + 8 b^4 π -
48 a^2 b^2 ArcCos[Sqrt[b/a]/Sqrt[2]] +
48 b^4 ArcCot[b/Sqrt[4 a^2 - b^2]] - 20 a^4 ArcCsc[(2 a)/b] -
4 b^4 ArcSec[(2 a)/b] + 44 a^4 ArcSin[b/(2 a)] +
48 a^2 b^2 ArcSin[b/(2 a)] -
48 a^2 b^2 ArcSin[Sqrt[b/a]/Sqrt[2]] +
96 a^2 b^2 ArcTan[Sqrt[-1 + (4 a^2)/b^2]] -
48 b^4 ArcTan[Sqrt[-1 + (4 a^2)/b^2]] -
16 b^4 ArcTan[b/Sqrt[4 a^2 - b^2]]) *)
• Assuming[0 < b < a, Integrate[integrand, {x, y} \[Element] region] // FullSimplify] will provide a much simpler form. – Bob Hanlon Dec 7 '19 at 21:41
• @BobHanlon shorter, certainly and worth looking at. But I'm not sure it it would seem simpler and more meaningful to the author (it introduces logs of complex numbers for one thing) – mikado Dec 7 '19 at 21:47
• My version (12) returns 1/24 (-4 (6 a^4 + 12 a^2 b^2 + b^4) ArcSec[(2 a)/b] + b (-6 a^2 Sqrt[4 a^2 - b^2] - 21 b^2 Sqrt[4 a^2 - b^2] + 32 b^3 \[Pi] - 48 b (-2 a^2 + b^2) ArcTan[Sqrt[-1 + (4 a^2)/b^2]] - 64 b^3 ArcTan[b/Sqrt[4 a^2 - b^2]])) which I have verified is equivalent to your shown result for 0 < b < a – Bob Hanlon Dec 7 '19 at 21:50
• @BobHanlon interesting. I'm using V12 too. I guess that it's an example of one of the reasons why I'm a little reluctant to recommend FullSimplify too blindly. – mikado Dec 7 '19 at 22:04
• I guess we do not need to learn multivariable calculus any more because Mathematica makes this easy to do :) – Nasser Dec 7 '19 at 23:59