# How can I evaluate surface integral in Mathematica?

$$\iint_{S^+}x^3dydz$$where $S$ 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)dydz = \iint_{S}P\cos\alpha dS,\ \; normal : \vec{n}=(cos\alpha, cos\beta, cos\gamma)$$

• I'm not sure what you mean with your domain definition. What do you mean by "$S$ [is the] bottom part" of that ellipsoid? And do you mean by $S^+$ the surface of $S$ for positive $z$? May 18, 2015 at 2:01
• @MarcoB My take is that it's the flux integral of the vector field {x^3, 0, 0} over the portion of the oriented surface where z <= 0, with the standard positive orientiation away from the interior of the (whole) ellipsoid. I don't see how it could be anything else. It's not a particularly hard integral, but my Mathematica is busy right now. I'm not sure whether the OP wants to know how to set up the surface integral or one can use the divergence theorem. May 18, 2015 at 2:16
• @MichaelE2 That makes sense, thank you. My vector calculus is awfully rusty, but at least now I understand the problem, and I can play with it for a bit of fun. May 18, 2015 at 3:05
• Does this seem like what you're after?: 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} -> {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 May 18, 2015 at 12:49
• No, I defined a generic surface integral of a vector field and applied it to your problem. The main code is the Integrate. For your example, S is the parametrization of the half-ellipsoid and F is the field being integrated. Does it not work if you copy/paste/execute it in Mathematica? Sorry if it's too complicate. I thought a general function would be useful to others, too, instead of just focusing on a single problem. May 18, 2015 at 14:11

Perhaps this?

Clear[DoubleContourIntegral];
DoubleContourIntegral[field_?VectorQ,
surface : {changeOfVars : ({x_, y_, z_} -> param : {xuv_, yuv_, zuv_}),
{u_, u1_, u2_}, {v_, v1_, v2_}}] :=
Integrate[
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 π  *)


The symbol \[DoubleContourIntegral] is interpreted as DoubleContourIntegral, which is itself undefined. So I defined it to perform a surface integral of a vector field (flux), where the surface is defined by a parametrization surface. The parametrization consists of a rule that defines {x, y, z} in terms of parametric functions and domains for the two parameters. The integrand is the dot product of the vector field with the cross product of the two partial derivatives of the parametrization, which is the standard definition. This definition can be applied to other parametrized surfaces and other vector fields. Note that care should be taken to make sure that the parametrization has the desired orientation.

(The OP's notation is not the same as the notation in standard US textbooks but it is equivalent to $\iint (P, 0, 0) \dot \;d{\bf S}$.)

• Michael, thank you for taking the time to turn your comment into a full answer. I was hoping you would when I asked to have the question reopened! I wonder if I could press you into including the alternative approach using the divergence theorem as well. (+1) May 18, 2015 at 23:42
• @MarcoB Thanks. See math.stackexchange.com/a/1288004 - Let me know if that is sufficient. May 19, 2015 at 0:49
• That will do nicely, thank you! May 19, 2015 at 3:14
• Excellent, thank you) May 19, 2015 at 11:43
• @Ordinaryusers68 That's a problem with Integrate. In this case, it helps to include the assumptions about the parameters you have in mind. Try Assuming[a > 0 && b > 0 && c > 0,\[DoubleContourIntegral]F \[DifferentialD]S]. In general, it's better to use the Assumptions option to Integrate, but the \[DoubleContourIntegral] input notation doesn't allow for passing options. One could add options to DoubleContourIntegral[] or do it this way: Block[{Integrate = Inactive[Integrate]}, \[DoubleContourIntegral]F \[DifferentialD]S] // Append[Assumptions -> a > 0 && b > 0] // Activate Jul 30, 2020 at 12:34

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

reg =
ParametricRegion[{a Sin[u] Cos[v], b Sin[u] Sin[v], c Cos[u]},
{{u, Pi/2, Pi}, {v, 0, 2 Pi}}];

SurfaceIntegrate[{x^3, 0, 0}, {x, y, z} ∈ reg]
(* 2/5 a^3 b c π *)


Sadly the following still returns the input for the moment:

SurfaceIntegrate[{x^3, 0, 0}, {x, y, z} ∈
ImplicitRegion[x^2/a^2 + y^2/b^2 + z^2/c^2 == 1 && z < 0, {x, y, z}]]
(* Input returned *)