I've searched MMA SE and read all of the posts on surface integrals, and several people have helped on various pieces of code to evaluate them.

I seem to have found a simple and correct code from users here.

For example, in the following problem:

enter image description here

region = ImplicitRegion[x^2 + y^2 + z^2 == 1 && x^2 - x + y^2 <= 0 && z >= 0, {x, y, z}];

Integrate[#, {x, y, z} \[Element] region] & /@ ({x^2, y^2, z^2}.{x, y,z})

This code works because the very last part of this code, the curly bracketed {x,y,z} is the normal vector of the sphere. So, knowing that, you can just enter it.

But I'm interested in making this code more generalizable by having code that will determine the normal vector of any surface and then, in that last line, just automatically refer back to that calculation. Any sense of how I could do that?

Thanks in advance for your patience and help.


Thanks for the code below. Very helpful. Sometimes MMA seems to have trouble calculating the integral, or it takes a long time. But often the question I'm asked is to just set up the integral. So following the example of @cvgmt's code, I have the following step by step, but I'm not sure how to complete it.

x[u_, v_] := 2 u v; 
y[u_, v_] := u^2 - v^2; 
z[u_, v_] := u^2 + v^2; r := {x[u, v], y[u, v], z[u, v]};

(*The following code takes cross product of the partial derivatives
of r and calculates magnitude*)
a = Cross[D[r, u], D[r, v]];
b = Norm[a];
c = FullSimplify[b] (*This simplifies the normal*)

(*Enter the parametrized integrand as f*)
f := (2 u v)^2 + (u^2 - v^2)^2

(*Fully simplify the dot product of the normal and the surface 
integrand, which will give you the final integrand for calculation*)


One thing here that is confusing is that this result gives me a couple "Abs(u)" or "Abs(v)" in it. I don't know how to get rid of those and it keeps the equation from fully simplifying.

  • $\begingroup$ BTW, those are my notes in the "problem" up above. $\endgroup$
    – JDVC
    Commented Dec 30, 2020 at 3:37
  • $\begingroup$ If you are asking about calculating the unit normal of the surface, you should consider using Normalize and Grad. $\endgroup$
    – LouisB
    Commented Dec 30, 2020 at 4:51
  • $\begingroup$ Thanks. I struggle in setting up the normalizerd grad - the unit normal - as some kind of variable and then how I can automatically incorporate that variable into the last line of code. $\endgroup$
    – JDVC
    Commented Dec 30, 2020 at 4:56
  • 1
    $\begingroup$ Maybe something like Integrate[ vfield.unorm, {x, y, z} \[Element] region] $\endgroup$
    – LouisB
    Commented Dec 30, 2020 at 4:58
  • $\begingroup$ use Norm[a,Sqrt[#.#]&] instead of Norm[a] as in my code. Or simplely use Sqrt[a.a] Since Abs is a complex function,It need to use ComplexExpand to simplify. $\endgroup$
    – cvgmt
    Commented Dec 31, 2020 at 5:46

1 Answer 1


The implicit method some times take long time to integrate.

region = ImplicitRegion[
   x^2 + y^2 + z^2 == 1 && x^2 - x + y^2 <= 0 && z >= 0, {x, y, z}];
Integrate[{x^2, y^2, z^2} . 
  Normalize[Grad[x^2 + y^2 + z^2 - 1, {x, y, z}], Sqrt[# . #] &], {x, 
   y, z} ∈ region]

38/105 + (5 π)/32

We can use other two ways. (relate to my updated answer Right code for solving Stoke's Theorem problem)

F[x_, y_, z_] := {x^2, y^2, z^2};
f[x_, y_] := {x, y, z} /. z -> Sqrt[1 - x^2 - y^2];
Integrate[(F[x, y, z] /. z -> Sqrt[1 - x^2 - y^2]) . 
  Cross[D[f[x, y], x], D[f[x, y], y]], {x, y} ∈ 
  ImplicitRegion[x^2 - x + y^2 <= 0, {x, y}]]

38/105 + (5 π)/32

We can also use the parametric method. Here we set x=r*Cos[θ]; y=r*Sin[θ]; Then the region

ImplicitRegion[x^2 - x + y^2 <= 0 ,{x,y}]


ParametricRegion[{r*Cos[θ], r*Sin[θ]},{{θ, -π/2, π/2}, {r, 0,Cos[θ]}}]

The surface and its projection to x-y plane is

enter image description here

F[x_, y_, z_] := {x^2, y^2, z^2};
f[r_, θ_] := {r*Cos[θ], r*Sin[θ], Sqrt[1 - r^2]};
 F[Sequence @@ f[r, θ]] . 
  Cross[D[f[r, θ], r], 
   D[f[r, θ], θ]], {θ, -π/2, π/2}, {r, 0,

38/105 + (5 π)/32

  • $\begingroup$ ParametricPlot3D[{{r*Cos[θ], r*Sin[θ], Sqrt[1 - r^2]}, ScalingTransform[{1, 1, 0}]@{r*Cos[θ], r*Sin[θ], Sqrt[1 - r^2]}}, {θ, -π/2, π/2}, {r, 0, Cos[θ]},MeshFunctions -> {#4 &}, Mesh -> 25, MeshStyle -> Red, PlotRange -> All, PlotPoints -> 50,ViewPoint -> {0.72, -3.04, 1.28}] $\endgroup$
    – cvgmt
    Commented Dec 30, 2020 at 10:03
  • $\begingroup$ Thank you so much. Wow. I am grateful for your generous attention to helping me on this. $\endgroup$
    – JDVC
    Commented Dec 30, 2020 at 15:26
  • $\begingroup$ I added up update above. At your convenience, could you look at it. Your facility in MMA is to be envied. $\endgroup$
    – JDVC
    Commented Dec 30, 2020 at 17:25

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.