%auto
## This worksheet interactively computes and displays the line integral of a 3D vector field
## over a given smooth curve C
##
## John Travis
## Mississippi College
## 06/16/11
##
var('x,y,z,t,s')
@interact(layout=dict(top=[['M','u'],['N','v'],['P','w'],['tt']],
bottom=[['in_3d','spinning'],['xx'],['yy'],['zz']]))
def _(M=input_box(default=x*y*z,label="$M(x,y,z)$",width=30),
N=input_box(default=-y*z,label="$N(x,y,z)$",width=30),
P=input_box(default=z*y,label="$P(x,y,z)$",width=30),
u=input_box(default=cos(t),label="$x=u(t)$",width=30),
v=input_box(default=2*sin(t),label="$y=v(t)$",width=30),
w=input_box(default=t*(t-2*pi)/pi,label="$z=w(t)$",width=30),
tt = range_slider(-4*pi, 4*pi, pi/6, default=(0,2*pi), label='t Range'),
xx = range_slider(-5, 5, 1, default=(-1,1), label='x Range'),
yy = range_slider(-5, 5, 1, default=(-2,2), label='y Range'),
zz = range_slider(-5, 5, 1, default=(-3,1), label='z Range'),
in_3d=checkbox(true,label='3D'),
spinning=checkbox(true,label='Spin On')):
# setup the parts and then compute the line integral
dr = [derivative(u,t),derivative(v,t),derivative(w,t)]
A = (M(x=u,y=v,z=w)*dr[0]
+N(x=u,y=v,z=w)*dr[1]
+P(x=u,y=v,z=w)*dr[2])
global line_integral
line_integral = integral(A(t=t),t,tt[0],tt[1])
pretty_print(html('$ \int_{C} < %s'%str(latex(M))+',%s'%str(latex(N))+',%s'%str(latex(P))+' > dr ='))
print
pretty_print(html('$ \int_{%s}'%str(latex(tt[0]))+'^{%s}'%str(latex(tt[1]))+' [%s'%str(latex(A))+']dt = %s $'%latex(line_integral)))
G = plot_vector_field3d((M,N,P),(x,xx[0],xx[1]),(y,yy[0],yy[1]),(z,zz[0],zz[1]),plot_points=6)
G += parametric_plot3d([u,v,w],(t,tt[0],tt[1]),thickness='5',color='yellow')
if spinning:
do_spin=true
else:
do_spin=false
if in_3d:
show(G,stereo='redcyan',spin=do_spin)
else:
show(G,perspective_depth=true,spin=do_spin)
|
Click to the left again to hide and once more to show the dynamic interactive window
|