How to calculate the following surface integral using MichaelE2's DoubleContourIntegral (How can I evaluate surface integral in Mathematica?),

$$\iint_{\Sigma} x^{2} \mathrm{~d} y \mathrm{~d} z+y^{2} \mathrm{~d} z \mathrm{~d} x+z^{2} \mathrm{~d} x \mathrm{~d} y$$

Where $\Sigma$ is the outside of the entire surface of the cuboid $\Omega$:

$\{(x, y, z) \mid 0 \leqslant x \leqslant a, 0 \leqslant y \leqslant b, 0 \leqslant z\leqslant c\}$

Result: $(a+b+c) a b c$

PS. MichaelE2's DoubleContourIntegral, e.g. $\iint_{S^{+}} x^{3} d y d z$

where $S$ is the bottom part of $\frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}+\frac{z^{2}}{c^{2}}=1\;$ $S_+$ - outer side of $S$

$\iint_{S^{+}} P(x, y, z) d y d z=\iint_{S} P \cos \alpha d S$, normal $: \vec{n}=(\cos \alpha, \cos \beta, \cos \gamma)$

   surface : {changeOfVars : ({x_, y_, z_} -> 
        param : {xuv_, yuv_, zuv_}), {u_, u1_, u2_}, {v_, v1_, 
      v2_}}] := 
   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} -> {a Sin[u] Cos[v], b Sin[u] Sin[v], c Cos[u]}, {u, 
    Pi/2, Pi}, {v, 0, 2 Pi}};
F = {x^3, 0, 0};
\[DoubleContourIntegral]F \[DifferentialD]S
2/5 a^3 b c Pi


Thanks for Artes's answer.

F[x_, y_, z_] := {x^2, y^2, z^2};
reg = ImplicitRegion[
   0 <= x <= a && 0 <= y <= b && 0 <= z <= c, {x, y, z}];
Integrate[Div[F[x, y, z], {x, y, z}], {x, y, z} \[Element] reg, 
  Assumptions -> a > 0 && b > 0 && c > 0] // Simplify
a b c (a + b + c)

In my textbook, it is called Gauss formula. $\iiint_{\Omega}\left(\frac{\partial P}{\partial x}+\frac{\partial Q}{\partial y}+\frac{\partial R}{\partial z}\right) \mathrm{d} v=\iint_{\Sigma} P \mathrm{~d} y \mathrm{~d} z+Q \mathrm{~d} z \mathrm{~d} x+R \mathrm{~d} x \mathrm{~d} y$

Can there be a general code for finding the unit vector of the normal outside the surface? So we can integrate directly. Especially for non closed surfaces.

  • $\begingroup$ There are surface integrals of the first and second kind. See Encyclopedia of Mathematics for info. $\endgroup$
    – user64494
    Commented Mar 10, 2022 at 10:45
  • $\begingroup$ Thanks. The surface integral in my question is second kind. I just want to find a way to integrate directly. Such as MichaelE2's method. @user64494 $\endgroup$
    – lotus2019
    Commented Mar 10, 2022 at 11:36

2 Answers 2


Using Stokes' theorem ($\;\int_{\partial \Omega} \omega = \int_\Omega d\omega \;$) this surface integral can be recast as an integral of exterior derivative of the given differential form over the given volume, here $\Omega$ is the cuboid, $\partial \Omega$ is its surface (boundary), $\omega=x^2 dy \wedge dz+y^2 dz \wedge dx+ z^2 dx \wedge dy\;$ and $$d\omega = d(x^2 dy \wedge dz+y^2 dz \wedge dx+ z^2 dx \wedge dy)= 2(x+y+z)\; dx \wedge dy \wedge dz$$ Now this could be calculated in mind, however if there must be a powerful technology let there be

Integrate[2 (x + y + z), {z, 0, c}, {y, 0, b}, {x, 0, a}]
 a b c (a + b + c)

There is (in Mathematica) a convention that in multiple integrals the outermost integral (here $\int_0^a f\; d x\;$)is calculated first. This is the simplest approach and it shouldn't be replaced by other more involved methods.

  • $\begingroup$ Nothing wrong with what you say, but I have a different view of the convention, namely, that in Integrate[f[x, y, z], {z, 0, c}, {y, 0, b}, {x, 0, a}], the iterators proceed from outer to inner, so that $\int_0^a f \; dx$ is the innermost integral. One might view it as applying integration operators in the order $(\int_0^c dz)\left[(\int_0^b dy)\left[(\int_0^a dx)\left[f(x,y,z)\right]\right]\right]$, even the Integrate code is typeset as $\int _0^c\int _0^b\int _0^a f(x,y,z)\;dx\,dy\,dz$ $\endgroup$
    – Michael E2
    Commented Mar 9, 2022 at 15:37
  • $\begingroup$ In my post the outermost term regarded the last one in Integrate[f, {z, 0, c}, {y, 0, b}, {x, 0, a}] i.e. {x, 0, a} and this is compatibile with your comment. $\endgroup$
    – Artes
    Commented Mar 9, 2022 at 16:57
  • $\begingroup$ Thanks! I have updated my question. @Artes $\endgroup$
    – lotus2019
    Commented Mar 10, 2022 at 11:32

In v13.3 SurfaceIntegrate is introduced, so the problem can be solved as follows:

SurfaceIntegrate[{x^2, y^2, z^2}, {x, y, z} ∈ Cuboid[{0, 0, 0}, {a, b, c}]] // Simplify
(* a b c (a + b + c) *)

enter image description here


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.