1
$\begingroup$

the following question is from this website Example 2.

Evaluate $\iint\limits_{S}{{z\ dS}}$ where $S$ is the upper half of a sphere of radius 2.

My code here is basically from How can I evaluate surface integral in Mathematica?. I am using 12.0 version of mathematica

Clear[DoubleContourIntegral];
DoubleContourIntegral[field_?VectorQ, 
   surface : {changeOfVars : ({x_, y_, z_} -> 
        param : {xuv_, yuv_, zuv_}), {u_, u1_, u2_}, {v_, v1_, 
      v2_}}] := 
  Integrate[
   Dot[field /. Thread[changeOfVars], 
    Cross[D[param, u], D[param, v]]], {u, u1, u2}, {v, v1, v2}];

Clear[a, b, c];
S = {{x, y, z} -> {2 Sin[u] Cos[v], 2 Sin[u] Sin[v], 2 Cos[u]}, {u, 
    0, \[Pi]/2}, {v, 0, 2 \[Pi]}};
F = {0, 0, z};
\[DoubleContourIntegral]F \[DifferentialD]S

The results will be different from the one the aurhor provided. What's wrong?

$\endgroup$

2 Answers 2

2
$\begingroup$
$Version (*12.2.0 for Microsoft Windows (64-bit) (December 12,2020)*)

Here an alternative way using the given coordinate system spherical coordinates (which confirms @user64494's result )

vec  = {2 Sin[u] Cos[v], 2 Sin[u] Sin[v], 2 Cos[u]}
{gu, gv} = {D[vec, u], D[vec, v]}
dS = Sqrt[# . #] &[Cross[gu, gv]] // Simplify (* surface area element*)

Integrate[vec[[3]] dS, {u, 0, Pi/2}, {v, -Pi, Pi}]  (* 8Pi *)

addendum

Here I present QP's corrected code, which gives correct result 8Pi

Try

Clear[DoubleContourIntegral];
DoubleContourIntegral[field_?VectorQ, 
   surface : {changeOfVars : ({x_, y_, z_} -> 
        param : {xuv_, yuv_, zuv_}), {u_, u1_, u2_}, {v_, v1_, 
      v2_}}] := 
  Integrate[( field[[3]] /. Thread[changeOfVars]) Norm[
     Cross[D[param, u], D[param, v]]] , {u, u1, u2}, {v, v1, v2}];

Clear[a, b, c];
S = {{x, y, z} -> {2 Sin[u] Cos[v], 2 Sin[u] Sin[v], 2 Cos[u]}, {u, 
    0, \[Pi]/2}, {v, 0, 2 \[Pi]}};
F = {0, 0, z};
\[DoubleContourIntegral]F \[DifferentialD]S
(* 8Pi *)

Hope it helps!

$\endgroup$
2
  • $\begingroup$ Why did the original code has field[[3]]? What does this mean? $\endgroup$
    – kile
    Commented Sep 14 at 20:25
  • $\begingroup$ That is the z-component of integrand field. $\endgroup$ Commented Sep 15 at 8:04
4
$\begingroup$

Since 13.3 SurfaceIntegrate is implemented. Unfortunately, there is no UpperSemisphere in Mathematica. To overcome it, Max[z,0] is integrated over the whole sphere:

SurfaceIntegrate[Max[z, 0], {x, y, z} \[Element] Sphere[{0, 0, 0}, 2]]

8 \[Pi]

That integral can also be calculated by the definition, Upper semi-sphere is described by its equation

z[x_,y_]:=Sqrt[4-x^2-y^2]

. Then

Integrate[z[x, y]*Sqrt[1 + D[z[x, y], x]^2 + D[z[x, y], y]^2], {x, y} \[Element] Disk[{0, 0}, 2]]

8*Pi

$\endgroup$
2
  • $\begingroup$ Can you try 12,0 version when there is no SurfaceIntegrate? $\endgroup$
    – kile
    Commented Sep 13 at 11:06
  • 1
    $\begingroup$ @kile: Did you read "That integral can also be calculated by the definition, ..." in my answer before having commented? I think the second way works in 12.0. $\endgroup$
    – user64494
    Commented Sep 13 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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