︠17c7689b-85fe-4eb2-9b98-41f92a13e039i︠ %html

Calculate the surface integral of flux type  $\iint_{S^+} P(x,y,z)\, dydz+Q(x,y,z) \,dxdz+R(x,y,z) \,dxdy $ where $S^+$ is a surface with given orientation.

This is equivalent to the problem: Find the flux of the vector field $\vec F(x,y,z)=\,\lt P,Q,R \gt\,$   over $S^+$.

We will solve the (relatively) simple problem of $\iint_S x dydz+y \,dxdz+z \,dxdy $ where S is top side of the triangle x+y+z=1, $x, \,y, \,z \ge 0$. Other examples follow.


Formula Sheet From the formula sheet, we see:  $\iint_S^+ P dydz+Q \,dxdz+R \,dxdy = \iint_S \vec F \cdot d \vec S$, where $\vec F= \lt P,Q,R \gt$

Surface element is the vector product:  $ d \vec S= \vec n \cdot dS = \pm \,\, d \vec S_u \times d \vec S_v \,\,\, du \, dv$

Remember that the $\pm $ depends on whether or not the parametrization is orientation preserving. We will find this by finding the sign of the dot product of the vector: $\vec n$ and the vector: $d \vec S_u \times d \vec S_v$.

Integrand is the mixed product: $\vec F \,d \vec S = \pm \,\, \vec F \cdot d \vec S_u \times d \vec S_v \,\,\, du\, dv$

Preparation for SOLVER: We must parameterize the surface S with 2 parameters, find the intervals and find any vector $\vec n$ normal to S and in the positive direction of the given orientation.

Work particular to the given problem: 

== We have an explicit function $z=f(x,y)$ for the surface. Namely $z=1-x-y$ So we just let $x=u$, $y=v$ and $z=f(u,v)=1-u-v$. Other parametrizations will not be so easy.

== So: $\left\{ \begin{array}{l}x = u \\y = v\\z =1-u-v \end{array} \right.\,\,\,\,\,u \in [0,1 ] \,\,\,\,v \in [0,-u+1]$
   (To get the intervals, we look at the vertices of the triangle in the u0v plane. They are V1(u=1,v=0), V2(u=0,v=1) and V3(u=0,v=0). We draw this region. It is a triangle where v goes from 0 to the line joining V1 and V2, namely v=-u+1 and then u goes from 0 to 1.)

== By examination, we see: $\vec n= <1,1,1>$   (That is, the vector pointing up from the triangle.)


SOLVER: Our program follows the hand solution method. Everything in red requires something particular to your problem!

  1. Parameterize S and input as vector function. Requires parametrization - done above.
  2. Find $\vec n$ and input as vector function. Requires normal - done above.
  3. Input F.
  4. Find the partials of S. 
  5. Determine $\pm$ by checking orientation preserving (+1 if orientation-preserving, else -1). Requires checking that you get $\pm 1$.
  6. Substitute parameterization in F.
  7. Find the mixed product  $\vec F \,d \vec S = \pm \,\,\,\vec F \cdot d \vec S_u \times d \vec S_v \,\,\, du\, dv$
  8. Find intervals of integration and integrate. Requires intervals of parametrization - done above.

Step 0: The program declares our variables. We are given variables (x,y,z). We need (u,v) as parameters.

︡12d5b2c7-acb8-421e-82f8-2fc91435f490︡{"html": "

Calculate the surface integral of flux type  $\\iint_{S^+} P(x,y,z)\\, dydz+Q(x,y,z) \\,dxdz+R(x,y,z) \\,dxdy $ where $S^+$ is a surface with given orientation.

\n

This is equivalent to the problem: Find the flux of the vector field $\\vec F(x,y,z)=\\,\\lt P,Q,R \\gt\\,$   over $S^+$.

\n

We will solve the (relatively) simple problem of $\\iint_S x dydz+y \\,dxdz+z \\,dxdy $ where S is top side of the triangle x+y+z=1, $x, \\,y, \\,z \\ge 0$. Other examples follow.

\n
\n

Formula Sheet From the formula sheet, we see:  $\\iint_S^+ P dydz+Q \\,dxdz+R \\,dxdy = \\iint_S \\vec F \\cdot d \\vec S$, where $\\vec F= \\lt P,Q,R \\gt$

\n
\n

Surface element is the vector product:  $ d \\vec S= \\vec n \\cdot dS = \\pm \\,\\, d \\vec S_u \\times d \\vec S_v \\,\\,\\, du \\, dv$

\n

Remember that the $\\pm $ depends on whether or not the parametrization is orientation preserving. We will find this by finding the sign of the dot product of the vector: $\\vec n$ and the vector: $d \\vec S_u \\times d \\vec S_v$.

\n

Integrand is the mixed product: $\\vec F \\,d \\vec S = \\pm \\,\\, \\vec F \\cdot d \\vec S_u \\times d \\vec S_v \\,\\,\\, du\\, dv$

\n
\n

Preparation for SOLVER: We must parameterize the surface S with 2 parameters, find the intervals and find any vector $\\vec n$ normal to S and in the positive direction of the given orientation.

\n
\n

Work particular to the given problem: 

\n
\n

== We have an explicit function $z=f(x,y)$ for the surface. Namely $z=1-x-y$ So we just let $x=u$, $y=v$ and $z=f(u,v)=1-u-v$. Other parametrizations will not be so easy.

\n

== So: $\\left\\{ \\begin{array}{l}x = u \\\\y = v\\\\z =1-u-v \\end{array} \\right.\\,\\,\\,\\,\\,u \\in [0,1 ] \\,\\,\\,\\,v \\in [0,-u+1]$
   (To get the intervals, we look at the vertices of the triangle in the u0v plane. They are V1(u=1,v=0), V2(u=0,v=1) and V3(u=0,v=0). We draw this region. It is a triangle where v goes from 0 to the line joining V1 and V2, namely v=-u+1 and then u goes from 0 to 1.)

\n

== By examination, we see: $\\vec n= <1,1,1>$   (That is, the vector pointing up from the triangle.)

\n
\n
\n
\n

SOLVER: Our program follows the hand solution method. Everything in red requires something particular to your problem!

\n
    \n
  1. Parameterize S and input as vector function. Requires parametrization - done above.
  2. \n
  3. Find $\\vec n$ and input as vector function. Requires normal - done above.
  4. \n
  5. Input F.
  6. \n
  7. Find the partials of S. 
  8. \n
  9. Determine $\\pm$ by checking orientation preserving (+1 if orientation-preserving, else -1). Requires checking that you get $\\pm 1$.
  10. \n
  11. Substitute parameterization in F.
  12. \n
  13. Find the mixed product  $\\vec F \\,d \\vec S = \\pm \\,\\,\\,\\vec F \\cdot d \\vec S_u \\times d \\vec S_v \\,\\,\\, du\\, dv$
  14. \n
  15. Find intervals of integration and integrate. Requires intervals of parametrization - done above.
  16. \n

\n

Step 0: The program declares our variables. We are given variables (x,y,z). We need (u,v) as parameters.

"}︡ ︠1ad7ae57-5c0a-464e-a567-840aaf3afe8e︠ var ('u v'); var('x y z') ︡ef86290e-4ffa-49e9-8f79-bbdeba15b835︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(u, v\\right)"}︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(x, y, z\\right)"}︡ ︠04bca469-e484-48eb-a541-b696f0abcc33i︠ %html

Step 1: We define $\vec S$, $\vec n$ and $\vec F$. Changes with problem; you must input your parametrization in Sf and your vector in n.

︡786e9cea-9a28-4ba9-b3ed-719f1d420850︡{"html": "
\r\n

Step 1: We define $\\vec S$, $\\vec n$ and $\\vec F$. Changes with problem; you must input your parametrization in Sf and your vector in n.

"}︡ ︠d34b828e-8084-4206-8788-c734fa2521df︠ Sf=vector((u,v,1-u-v)) n=vector((1,1,1)) F=vector((x,y,z)) ︡2b4efe73-aad9-463f-abc6-b5415259f908︡︡ ︠87e1ac39-2cad-40d2-b5fd-34f8947a522di︠ %html

Step 2: The program finds the partial derivatives.

︡0e0f06f3-738a-4691-b483-77e42cffe6d1︡{"html": "
\r\n

Step 2: The program finds the partial derivatives.

"}︡ ︠b76e9e86-abdf-47a7-bae6-37db16abed9b︠ Sprime_u=diff(Sf,u) view(Sprime_u) ︡788a88d5-68f7-4988-9b4f-1eed207f3f04︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(1,\\,0,\\,-1\\right)"}︡ ︠4510faa5-9380-4adb-b4b4-4765d1aca0c8︠ Sprime_v=diff(Sf,v) view(Sprime_v) ︡5de3c02d-cbca-4bce-a803-643997490e68︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,1,\\,-1\\right)"}︡ ︠20f8a1e0-b5bc-4a93-a79a-83a8137ae9ffi︠ %html

Step 3: The program checks whether our parameterization is "orientation-preserving" or not. Check that we get 1 or -1.

If we get 0 here, we need to change the point, e.g. (u=2.0,v=2.0). Use "real" values with decimal points. (If we get something other than +1, -1 or 0, we have made an error in step 1.)

︡fa68ccce-b1b1-4185-87a1-19a7d3700741︡{"html": "
\r\n

Step 3: The program checks whether our parameterization is \"orientation-preserving\" or not. Check that we get 1 or -1.

\r\n

If we get 0 here, we need to change the point, e.g. (u=2.0,v=2.0). Use \"real\" values with decimal points. (If we get something other than +1, -1 or 0, we have made an error in step 1.)

"}︡ ︠76ec963c-b4ea-43ec-8780-235462e3626b︠ npar=Sprime_u.cross_product(Sprime_v) np=sign((n.dot_product(npar))(u=1.0,v=1.0)) view(np) ︡b1c6c57c-0217-4ca8-b002-c094de707f72︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}1"}︡ ︠59b812d8-b779-49cd-a234-8dcc64dc3041i︠ %html

Step 4: The program defines a standard sage function for "change of variables" for a 2-variable parametrization (surface).

The program changes the variables of $\vec F$.

︡c67c6d2c-cdc3-49c5-8976-12d6e770d03a︡{"html": "
\r\n

Step 4: The program defines a standard sage function for \"change of variables\" for a 2-variable parametrization (surface).

\r\n

The program changes the variables of $\\vec F$.

"}︡ ︠b7f23e35-a7c9-4593-901a-07bd9253faba︠ def changevar(f, eqn, newvar1,newvar2): return f.substitute(eqn) ︡4ad98158-36e1-4729-86aa-6e7798a7ae58︡︡ ︠2915ab9c-371e-43ee-8f3b-023926ed3f9f︠ F=changevar(F,x==Sf[0],u,v) F=changevar(F,y==Sf[1],u,v) F=changevar(F,z==Sf[2],u,v) view(F) ︡169ef8fb-c43f-40bc-8e40-4585b977869c︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(u,\\,v,\\,-u - v + 1\\right)"}︡ ︠c95d5f99-0eec-472b-94f4-f528f074b93bi︠ %html

Step 5: Then program finds the mixed product and multiplies it by the orientation from step 3.

︡3a1f8c21-eba4-4a3f-950b-2f73cbe09c96︡{"html": "
\r\n

Step 5: Then program finds the mixed product and multiplies it by the orientation from step 3.

"}︡ ︠f4a41ae1-5fae-41d2-bd3d-a2673daacb7d︠ M=matrix(([F[0],F[1],F[2]],[Sprime_u[0],Sprime_u[1],Sprime_u[2]],[Sprime_v[0],Sprime_v[1],Sprime_v[2]])) Int=np*M.determinant() view(Int) ︡31d2e3d4-c9d1-425a-8126-f7ee4ee8db24︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}1"}︡ ︠e2aa4d23-37a2-4453-ad21-1ab5db88ed60i︠ %html

Step 6: The program computes the integral (flux). Changes with problem - we must put in our intervals of integration.

︡fe99bc73-28dd-4f88-b6b1-c54a6c8b0825︡{"html": "
\r\n

Step 6: The program computes the integral (flux). Changes with problem - we must put in our intervals of integration.

"}︡ ︠4efc610a-c5bb-477d-8ac7-db095ac4c3c5︠ integral(integral(Int,(v,0,-u+1)),(u,0,1)) ︡17a22e16-b00e-48ac-b022-329c99524f55︡{"html": "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{1}{2}"}︡ ︠50f9d98d-e902-4a2a-9b77-e4db56d7fa54i︠ %html

So our flux is: $\iint_S x dydz+y \,dxdz+z \,dxdy = \frac{1}{2}=0.5$  

Notice that this last "makes sense" in our particular problem since the integrand is 1 and the area of the projected triangle is 1/2.



Scroll down to the bottom graph 2. It is a visualization of calculating the flux!

Graph 1: We must usually use the parameterization of S that we get to graph the surface. We can do this easily if the intervals for u and v are numbers.  

Here: $v \in [0,-u+1] $ and $u \in [0,1] $ so not numbers. I don't know if one can graph with intervals with variables, so I just "drew" the triangle a couple of different ways.

︡985188c5-6d38-46c1-a4ae-d2048be62fae︡{"html": "
\r\n
\r\n

So our flux is: $\\iint_S x dydz+y \\,dxdz+z \\,dxdy = \\frac{1}{2}=0.5$  

\r\n

Notice that this last \"makes sense\" in our particular problem since the integrand is 1 and the area of the projected triangle is 1/2.

\r\n
\r\n
\r\n

Scroll down to the bottom graph 2. It is a visualization of calculating the flux!

\r\n

Graph 1: We must usually use the parameterization of S that we get to graph the surface. We can do this easily if the intervals for u and v are numbers.  

\r\n

Here: $v \\in [0,-u+1] $ and $u \\in [0,1] $ so not numbers. I don't know if one can graph with intervals with variables, so I just \"drew\" the triangle a couple of different ways.

"}︡ ︠3b842590-43c6-4cf6-9a17-4e32110218ae︠ S=polygon([(1,0,0),(0,1,0),(0,0,1)]) show(S,figsize=3) ︡5ac8c7c1-a272-4208-a92d-eec9f65860ca︡︡ ︠8c447a61-ff61-4b04-b28b-57ac497e0c25︠ T=sum([line3d([(0,0,1),(c,1-c,0)], color=hue((c+8)/8), width=0.8) for c in [0..1,step=0.01]]) show(T,figsize=3) ︡217516e2-bf23-4def-b79a-a111cfcf9e91︡︡ ︠88c92784-2213-4308-89ee-12a9fd5d5c3ei︠ %html

Graph 2: Now we want a visual interpretation of what we have done. Remember that with the change of variables from the parametrization, we have:

So the vectors that describe the normalized flux volume (and scaled by vector-scale=$vs$) are: 

Remember that our surface with respect to u and v has $u \in [0,1]$ and $v \in [0,-u+1].

To do our programming interation, we substitute "c" for u and "d" for v and run d from [0,-c+1] and c from [0,1].  (Usually start tries with big steps and see how it goes and then reduce step size.)

The FLUX is the VOLUME between the surface S and the surface 'formed' by the endpoints of the arrows (multiplied by the orientation and divided by $\left\| {\vec n} \right\|$ )!

Here I have added a "blank" triangle so that the box is nice. Probably and easier way to do this...

︡57ca90f6-8617-4e9b-a61e-f565b5fbd49a︡{"html": "
\r\n

Graph 2: Now we want a visual interpretation of what we have done. Remember that with the change of variables from the parametrization, we have:

\r\n\r\n

So the vectors that describe the normalized flux volume (and scaled by vector-scale=$vs$) are: 

\r\n\r\n

Remember that our surface with respect to u and v has $u \\in [0,1]$ and $v \\in [0,-u+1].

\r\n

To do our programming interation, we substitute \"c\" for u and \"d\" for v and run d from [0,-c+1] and c from [0,1].  (Usually start tries with big steps and see how it goes and then reduce step size.)

\r\n

The FLUX is the VOLUME between the surface S and the surface 'formed' by the endpoints of the arrows (multiplied by the orientation and divided by $\\left\\| {\\vec n} \\right\\|$ )!

\r\n

Here I have added a \"blank\" triangle so that the box is nice. Probably and easier way to do this...

"}︡ ︠fb2655af-d57f-472a-ad2d-d02659df1a54︠ vs=.5 vf=sum([sum([arrow3d((c,d,1-c-d),(c+1*vs,d+1*vs,1-c-d+1*vs), color=hue((c+8)/8), width=0.8) for d in [0..(-c+1),step=0.2]]) for c in [0..1,step=0.2]]) T_blank=polygon([(2,0,0),(0,2,0),(0,0,2)], color='white', opacity=0) show(T+vf+T_blank,figsize=3) ︡2a173a76-32f2-40f5-8674-32e6f9cee93b︡︡