I’m working on an exercise in Mathematica to verify Stokes’ theorem for the 2D vector field
$$ \mathbf{A}(x,y) = A_0 (y^2, -x^2) $$
over a rectangular region defined by $ x \in [a, 2a] $ and $ y \in [0, c] $. I calculate the circulation along the boundary using LineIntegrate
and get
$$ -A_0\, a\, c\,(3a+c) $$
However, when I compute the curl with
Curl[A, {x, y}]
(which returns $-2A_0\,x - 2A_0\,y$) and integrate it over the rectangle using SurfaceIntegrate
, I obtain
$$ -2 A_0 (a+c)(3a+c) $$
which differs by an extra factor.
Below is the code snippet that reproduces the issue:
Clear[A0, x, y, a, c, ℛ]
(* Define the vector field *)
A = A0 { y^2, -x^2 }
(* Out: {A0 y^2, -A0 x^2} *)
(* Compute line integrals along each segment of the rectangle *)
path1 = LineIntegrate[A, {x, y} ∈ Line[{{a, 0}, {2 a, 0}}]]
(* Out: 0 *)
path2 = LineIntegrate[A, {x, y} ∈ Line[{{2 a, 0}, {2 a, c}}]]
(* Out: -4 a^2 A0 c *)
path3 = LineIntegrate[A, {x, y} ∈ Line[{{2 a, c}, {a, c}}]]
(* Out: -a A0 c^2 *)
path4 = LineIntegrate[A, {x, y} ∈ Line[{{a, c}, {a, 0}}]]
(* Out: a^2 A0 c *)
(* Sum of the line integrals *)
totalLine = Simplify[path1 + path2 + path3 + path4]
(* Out: -a A0 c (3a + c) *)
(* Compute the curl *)
curlA = Curl[A, {x, y}]
(* Out: -2 A0 x - 2 A0 y *)
(* Define the rectangular region *)
ℛ = Rectangle[{a, 0}, {2 a, c}];
(* Integrate the curl over the rectangle *)
totalSurface = SurfaceIntegrate[curlA, {x, y} ∈ ℛ] //
Simplify[#, Assumptions -> {a > 0, c > 0}] &
(* Out: -2 A0 (a + c) (3 a + c) *)
I would expect both methods to yield the same result according to Stokes’ theorem. Has anyone seen a similar discrepancy or can explain why the surface integral gives an extra factor? Could there be a nuance with how Curl
or SurfaceIntegrate
handles 2D regions in Mathematica?
Any insights or suggestions would be greatly appreciated.
Here’s the geometric region for reference:
