# Visualizing Line Integrals

I have a plane curve $C$ described by parametric equations $x(t)$ and $y(t)$ and a function $f: \mathbb{R}^2 \rightarrow \mathbb{R}$. The line integral of $f$ along $C$ is the area of the "fence" whose path is governed by $C$ and height is governed by $f$.

How can I generate a picture of the "fence" in Mathematica?

For the sake of a concrete example, let's borrow from Stewart (since I already borrowed his picture). For $0 \leq t \leq \pi$, define \begin{align*} x(t) &= \cos t\\ y(t) &= \sin t\\ f(x,y) &= 2 + x^2y \end{align*} so that \begin{align*} f(x(t),y(t)) &= 2 + \cos^2 t \sin t. \end{align*}

• Check out ParametricPlot3D. – user484 Nov 10 '14 at 4:18

 ListPointPlot3D[
Table[{Cos[t], Sin[t], 2 + Sin[t] Cos[t]^2} ,{t, 0, π, 0.01}] ,
Filling -> 0]


• Simple code and beautiful output. Thank you. – Austin Mohr Nov 10 '14 at 5:03

This is just a small tweak of Belisarius' answer, using MeshFunctions to get the vertical lines and BoundaryStyle to get the "fence".

ParametricPlot3D[{Cos[t], Sin[t], z (2 + Sin[t] Cos[t]^2)}, {t,
0, \[Pi]/2}, {z, 0, 1}, MeshFunctions -> {#2 &}, MeshStyle -> {Red},
BoundaryStyle -> Directive[Thick, Blue], BoxRatios -> {1, 1, 1/2},
PlotStyle -> Opacity[.5]]


An alternative that gives more "even" vertical lines is to specify the mesh in terms of t and z.

ParametricPlot3D[{Cos[t], Sin[t], z (2 + Sin[t] Cos[t]^2)}, {t,
0, \[Pi]/2}, {z, 0, 1},
Mesh -> {Range[0, 1, 0.1], Range[0, 2, 0.5], Range[0, 1, 0.1]},
MeshStyle -> {Directive[Red, Thick], Directive[Green, Thick]},
BoundaryStyle -> Directive[Blue, Thick], BoxRatios -> {1, 1, 1/2},
PlotStyle -> Opacity[.5]]


And as Belisarius points out in comments (I'm going to have to CW this one!), MeshFunctions -> {#4 &} is even evener :)

ParametricPlot3D[{Cos[t], Sin[t], z (2 + Sin[t] Cos[t]^2)}, {t,
0, \[Pi]/2}, {z, 0, 1}, MeshFunctions -> {#4 &}, MeshStyle -> {Red},
BoundaryStyle -> Directive[Thick, Blue], BoxRatios -> {1, 1, 1/2},
PlotStyle -> Opacity[.5]]


• @ubpdqn - I've added the other example. I probably should have included it in the first iteration (I'd already thought of it) but focused on BoundaryStyle as the value I was adding. – Verbeia Nov 10 '14 at 6:39
• MeshFunctions -> {#4 &}? – Dr. belisarius Nov 10 '14 at 6:40
• I thought the mesh should be able to do it, but it exceeded my skill. Thanks to you and belisaurius for getting this out of ParametricPlot3D. – Austin Mohr Nov 10 '14 at 16:16
opts = {MeshFunctions -> (#4 &),
MeshShading ->   {{Opacity[#2], #1}, {Opacity[#2/2], #1}},
BoxRatios ->     {1, 1, 1/2},
BoundaryStyle -> Directive[Thin, Blue]} &;
Show[
ParametricPlot3D[{Cos[t], Sin[t], z (2 + Sin[t] Cos[t]^2)}, {t, 0, π/2}, {z, 0, 1},
Evaluate@opts[Green, .4]],
ParametricPlot3D[{Cos[t], z Sin[t], 0 }, {t, 0, π/2}, {z, 0, 1},
Evaluate@opts[Blue, .2]],
ParametricPlot3D[{z Cos[t], Sin[t], 0 }, {t, 0, π/2}, {z, 0, 1},
Evaluate@opts[Blue, .2]]]


I have not done the labeling but this is a start:

axes[n_] :=
With[{uv = n IdentityMatrix[3]},
Graphics3D[{Arrow[{{0, 0, 0}, #}] & /@ uv,