Line Integrals

Code

lineSegmentLength[t_]:=(
t1=t-deltaT*tPoint;
t2=t1+deltaT;
Sqrt[(x[t2]-x[t1])^2+(y[t2]-y[t1])^2]
)

generateRectangle[t_]:=(
t1=t-deltaT*tPoint;
t2=t1+deltaT;
x1=x[t1];
x2=x[t2];
y1=y[t1];
y2=y[t2];
zValue=f[x[t],y[t]];
Polygon[{{x1,y1,0},{x1,y1,zValue},{x2,y2,zValue},{x2,y2,0}}]
)

generateYZRectangle[t_]:=(
t1=t-deltaT*tPoint;
t2=t1+deltaT;
y1=y[t1];
y2=y[t2];
zValue=f[x[t],y[t]];
Polygon[{{xBack,y1,0},{xBack,y1,zValue},{xBack,y2,zValue},{xBack,y2,0}}]
)

generateXZRectangle[t_]:=(
t1=t-deltaT*tPoint;
t2=t1+deltaT;
x1=x[t1];
x2=x[t2];
zValue=f[x[t],y[t]];
Polygon[{{x1,yBack,0},{x1,yBack,zValue},{x2,yBack,zValue},{x2,yBack,0}}]
)

graphicsFinal[tSubdivisions_]:=(
deltaT=(tMax-tMin)/tSubdivisions;

riemannSum=Total[Table[f[x[t],y[t]]*lineSegmentLength[t],{t,tMin+deltaT*tPoint,tMax,deltaT}]];
xRiemannSum=Total[Table[f[x[t],y[t]]*(x[t+deltaT*(1-tPoint)]-x[t-deltaT*tPoint]),{t,tMin+deltaT*tPoint,tMax,deltaT}]];
yRiemannSum=Total[Table[f[x[t],y[t]]*(y[t+deltaT*(1-tPoint)]-y[t-deltaT*tPoint]),{t,tMin+deltaT*tPoint,tMax,deltaT}]];

riemannSumRectangles=If[showRiemannSum,Graphics3D[{Blue,Opacity[0.5],Table[generateRectangle[t],{t,tMin+deltaT*tPoint,tMax,deltaT}]}],{}];
xRiemannSumRectangles=If[showXRiemannSum,Graphics3D[{DarkGreen,Opacity[0.5],Table[generateYZRectangle[t],{t,tMin+deltaT*tPoint,tMax,deltaT}]}],{}];
yRiemannSumRectangles=If[showYRiemannSum,Graphics3D[{Purple,Opacity[0.5],Table[generateXZRectangle[t],{t,tMin+deltaT*tPoint,tMax,deltaT}]}],{}];

text2 = If[showRiemannSum,Style["Riemann sum:  "<>ToString[riemannSum],FontColor->Blue],""];
text4 = If[showXRiemannSum,Style["Riemann sum:  "<>ToString[xRiemannSum],FontColor->DarkGreen],""];text6 = If[showYRiemannSum,Style["Riemann sum:  "<>ToString[yRiemannSum],FontColor->Purple],""];

Show[curve,riemannSumRectangles,xRiemannSumRectangles,yRiemannSumRectangles,curtain,yzCurtain,xzCurtain,curveOnYZPlane,curveOnXZPlane,surface,curveOnSurface,Axes->Automatic,AxesLabel->{x,y,z},BoxRatios->{2,2,3},ViewPoint->{8,4,4},PlotRange->{{xBack,xRight},{yBack,yRight},{0,Automatic}},PlotLabel->Row[Select[{text1,text2,text3,text4,text5,text6},ToString@#!=""&],"\n"],Lighting->{{"Ambient",White}},ImageSize->Medium]
)

graphicsInitial:=(

xLeft=NMinimize[{x[t],tMin≤t≤tMax},t][[1]];
xRight=NMaximize[{x[t],tMin≤t≤tMax},t][[1]];
xBack = xLeft-(xRight-xLeft)/4;

yLeft=NMinimize[{y[t],tMin≤t≤tMax},t][[1]];
yRight=NMaximize[{y[t],tMin≤t≤tMax},t][[1]];
yBack = yLeft-(yRight-yLeft)/4;

integral=NIntegrate[f[x[t],y[t]]Sqrt[x'[t]^2+y'[t]^2],{t,tMin,tMax}];
xIntegral=NIntegrate[f[x[t],y[t]]x'[t],{t,tMin,tMax}];
yIntegral=NIntegrate[f[x[t],y[t]]y'[t],{t,tMin,tMax}];

DarkGreen=RGBColor[0,.75,0];

surface=If[showSurface,Plot3D[f[x,y],{x,xLeft,xRight},{y,yLeft,yRight},MeshStyle->Red,PlotStyle->Opacity[0],BoundaryStyle->{{Red,Opacity[0.5]}}],{}];


curve=If[showCurve,ParametricPlot3D[{x[t],y[t],0},{t,tMin,tMax},PlotStyle->{Blue,Thickness[0.008]}],{}];
curveOnSurface=If[showCurveOnSurface,ParametricPlot3D[{x[t],y[t],f[x[t],y[t]]},{t,tMin,tMax},PlotStyle->{Blue,Thickness[0.008]}],{}];
curveOnYZPlane=If[showCurveOnYZPlane,ParametricPlot3D[{xBack,y[t],f[x[t],y[t]]},{t,tMin,tMax},PlotStyle->{DarkGreen,Thickness[0.008]}],{}];
curveOnXZPlane=If[showCurveOnXZPlane,ParametricPlot3D[{x[t],yBack,f[x[t],y[t]]},{t,tMin,tMax},PlotStyle->{Purple,Thickness[0.008]}],{}];

curtain=If[showCurtain,ParametricPlot3D[{x[t],y[t],s},{t,tMin,tMax},{s,0,f[x[t],y[t]]},PlotStyle->{LightBlue,Thickness[0.008]},Mesh->None],{}];
yzCurtain=If[showYZCurtain,ParametricPlot3D[{xBack,y[t],s},{t,tMin,tMax},{s,0,f[x[t],y[t]]},PlotStyle->{LightGreen,Thickness[0.008]},Mesh->None],{}];
xzCurtain=If[showXZCurtain,ParametricPlot3D[{x[t],yBack,s},{t,tMin,tMax},{s,0,f[x[t],y[t]]},PlotStyle->{LightPurple,Thickness[0.008]},Mesh->None],{}];


text1 = If[showCurtain||showRiemannSum,Style[TraditionalForm[HoldForm[Integrate[f[x,y],{s,C,""}]]==integral],FontColor->Blue],""];
text3 = If[showYZCurtain||showXRiemannSum,Style[TraditionalForm[HoldForm[Integrate[f[x,y],{x,C,""}]]==xIntegral],FontColor->DarkGreen],""];
text5 = If[showXZCurtain||showYRiemannSum,Style[TraditionalForm[HoldForm[Integrate[f[x,y],{y,C,""}]]==yIntegral],FontColor->Purple],""];
)

graphics[tSubdivisions_]:=(
graphicsInitial;
graphicsFinal[tSubdivisions]
)

animation:=(
graphicsInitial;
Table[Image[graphicsFinal[subdivisions]],{subdivisions,startingSubdivisions,endingSubdivisions,1}]
)

Graphics

f[x_,y_]:=(x^2+2y^2+1)/25;
x[t_]:=3t+0.3(t+Cos[5t]);
y[t_]:=t^2+0.3Sin[4t];

tMin=1;
tMax=2;

showSurface=True;

showCurve=True;
showCurveOnSurface=True;
showCurveOnYZPlane=True;
showCurveOnXZPlane=True;

showCurtain=False;
showYZCurtain=False;
showXZCurtain=False;

showRiemannSum=True;
showXRiemannSum=True;
showYRiemannSum=True;

tSubdivisions=6;
tPoint=0.5;

graphics[tSubdivisions]

Animation

All options except tSubdivisions and the curtain and Riemann sum options are taken from the Graphics section above.
It may take some time to run this command, as all frames of the animation are precomputed so that it can run smoothly.

startingSubdivisions=1;
endingSubdivisions=24;

showCurtain=False;
showYZCurtain=False;
showXZCurtain=False;

showRiemannSum=True;
showXRiemannSum=True;
showYRiemannSum=True;

duration=3;

ListAnimate[animation,DefaultDuration->duration]