Surface Integrals, Triple Integrals, and the Divergence Theorem of Gauss in Maxima

In earlier posts, I describe the Package of Maxima functions MATH214 for use in my multivariable calculus class, with applications to Greens  Theorem and Stokes Theorem.

Here we show how the  surface integral function integrateSurf() and triple integration  function integrate3()  (together with the divergence function div() )work on a Gauss’s Theorem example:

Gauss2

We integrate the parabolic surface and the circular base surface separately, and show their sum is equal to the triple integral of the divergence.

Gauss1

The functions above are included in the MATH214 package, but I list them below as well:

integrateSurf(F,S,uu,aa,bb,vv,cc,dd):=block(
 [F2],
 F2:psubst([x=S[1],y=S[2],z=S[3]],F),
 integrate(integrate(trigsimp(F2.cross(diff(S,uu),diff(S,vv))),uu,aa,bb),vv,cc,dd));

integrate3(F,xx,aa,bb,yy,cc,dd,zz,ee,ff):=block(
 integrate(integrate(integrate(F,xx,aa,bb),yy,cc,dd),zz,ee,ff));

div(f,x,y,z):=diff(f[1],x)+diff(f[2],y)+diff(f[3],z)$

cross(_u,_v):=[_u[2]*_v[3]-_u[3]*_v[2],_u[3]*_v[1]-_u[1]*_v[3],_u[1]*_v[2]-_u[2]*_v[1]]$

 

Advertisements

10 thoughts on “Surface Integrals, Triple Integrals, and the Divergence Theorem of Gauss in Maxima”

  1. I’m attempting to interpret and visualize Gauss’s law for electrostatics.
    The nomenclature is posing some problems , for instance is div(F) equivalent to pho in the
    standard representation or is F(x,y,z) representing a force upon a test charge..

    Here’s my attempt , so far , at visualizing the surface and the distribution of F(x,y,z) .
    /*

    Gauss’s law applied to electrostatics , involves surface and volume integrals.

    */

    load(draw)$
    draw_renderer:’vtk$

    draw3d(
    color = yellow,
    implicit((x^2+x*y+z)=0,x,-2,2,y,-2,2,z,0,4 ),

    enhanced3d = true,
    palette = [[red, 0.71], [orange, 0.71], [cyan, 0.71],
    [navy, 0.7], [brown, 0.6], [black, 0.2]],

    implicit(4 – x^2 – y^2-z=0,x,-2,2,y,-2,2,z,0,4) ,
    parametric_surface(r*cos(t),r*sin(t)
    ,0, r,0,2,t,0,2*%pi)

    ) $

    Like

    1. I think the visualization needs a vector field for F(x,y,z) =

      Using the vectorfield package I describe here:
      https://themaximalist.org/2016/05/19/computing-and-visualizing-path-integrals-of-vector-fields/

      After downloading vectorfield.zip from the link at the blog post above,
      we can visualize the vectors specified by F in my modified version of your draw3d command:

      (%i21) load(“C:/Users/Eric Barth/Documents/Maxima/vectorfield.mac”)$
      (%i23) v:make_vector_field3d([x^2,x*y,z],[x,-2,2],[y,-2,2],[z,0,4])$
      (%i24) draw3d(
      color = black,
      v,
      color=red,
      implicit(4 – x^2 – y^2-z=0,x,-2,2,y,-2,2,z,0,4) ,
      color=blue,
      parametric_surface(r*cos(t),r*sin(t)
      ,0, r,0,2,t,0,2*%pi)
      ) $

      Like

  2. After browsing the web I found a few definitions for the terms used in Gauss’s law for electrostatics , these are based
    around the Wikipedia representation.

    V [ volt ]
    ∇V = i*diff(V,x) + j*diff(V,y) + k*diff(V,z)
    E = –∇V
    D = εE
    –∇ · (ε∇V) = ρ
    –∇ · D = ρ

    integrate(D.da,surface) = integrate(–∇ · D ,dv,volume) ?

    This is my initial attempt of visualizing the vector field , I’m using the Maxima vtk package ; approach is valid when
    we don’t use the vtk render er .

    load(draw)$
    draw_renderer:’vtk$

    /* Define vector field */
    coord: setify(makelist(k,k,1,5))$
    points3d: listify(cartesian_product(coord,coord,coord))$
    vf3d(x,y,z):= vector([x-3.5,y-3.5,z-1.25],[x^2,x*y,z])$

    /*list of vector objects*/
    vect3: makelist(vf3d(k[1],k[2],k[3]),k,points3d)$

    draw3d(
    [head_length = 0.2,
    line_width = 0.01,
    color = black,
    head_angle = 10,
    unit_vectors = true],
    vect3,
    color=red,

    implicit(4 – x^2 – y^2-z=0,x,-2,2,y,-2,2,z,0,4) ,
    color=blue,
    parametric_surface(r*cos(t),r*sin(t),0, r,0,2,t,0,2*%pi)

    )$

    Like

    1. …and yet, as I compare the appearance of the vector field in our two visualization methods, I think that near the yz plane (x=0) the vectors specified by
      F= should be nearly vertical. In your method, I don’t see any vertical vectors

      Like

  3. I noticed some discrepancies too ; I’ve written to the author of maxima-vtk about this and I’m presently
    awaiting a reply . We all may need to exchange a few emails to clarify this .

    I’ve read that the Cavendish experiment used a single voltage measurement to determine the total charge upon an
    object . More recent measurements involve a scanning probe to determine the surface distribution of the voltage ;
    especially when the object is a high voltage insulator .
    Personally I prefer low voltage investigations .

    Like

    1. I believe this merging of code might be effective.

      Draw using vtk provides quite a few options for the style of the arrow .

      /*

      Paraboloid object and 3d vectors .

      */

      kill(all)$
      load(draw)$
      draw_renderer:’vtk$
      load(“C:/Users/Eric Barth/Documents/Maxima/vectorfield.mac”)$

      v:make_vector_field3d([x^2,x*y,z],[x,-2,2],[y,-2,2],[z,0,4])$

      draw3d(
      [head_length = 0.4,
      line_width = 0.02,
      color = black,
      head_angle = 35,
      unit_vectors = false],
      v,
      color=red,

      implicit(4 – x^2 – y^2-z=0,x,-2,2,y,-2,2,z,0,4) ,
      color=blue,
      parametric_surface(r*cos(t),r*sin(t),0, r,0,2,t,0,2*%pi)

      )$

      Like

  4. As every odd index to v provides information about the shape of the arrow
    head and the vtk renderer doesn’t appear to use this , I generate a new list of
    vectors from all of the even values of v .

    The ability to define the arrow head shape for individual vectors might have some
    utility , presently I’m not certain what that might be .

    kill(all)$
    load(draw)$
    draw_renderer:’vtk$
    load(“C:/Users/Eric Barth/Documents/Maxima/vectorfield.mac”)$

    v:make_vector_field3d([x^2,x*y,z],[x,-2,2],[y,-2,2],[z,0,4])$

    lsv:length(v);
    vs:makelist(0,i,lsv/2)$
    k:1$
    for i:2 thru lsv step 2 do(
    vs[k]:v[i],
    k:k+1
    )$

    draw3d(
    [head_length = 0.2,
    line_width = 0.01,
    color = black,
    head_angle = 30,
    unit_vectors = false],
    vs,
    color=red,

    implicit(4 – x^2 – y^2-z=0,x,-2,2,y,-2,2,z,0,4) ,
    color=blue,
    parametric_surface(r*cos(t),r*sin(t),0, r,0,2,t,0,2*%pi)

    )$

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s