Line Integrals 3d Vector Field
Description
This interact allows the user to calculate a line integral through a 3D vector field, both input by the user.
Sage Cell
Code
## 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
##
## An updated version of this worksheet may be available at http://sagenb.mc.edu
##
var('x,y,z,t,s')
@interact
def _(M=input_box(default=x*y*z,label="$M(x,y,z)$"),
N=input_box(default=-y*z,label="$N(x,y,z)$"),
P=input_box(default=z*y,label="$P(x,y,z)$"),
u=input_box(default=cos(t),label="$x=u(t)$"),
v=input_box(default=2*sin(t),label="$y=v(t)$"),
w=input_box(default=t*(t-2*pi)/pi,label="$z=w(t)$"),
tt = range_slider(-2*pi, 2*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)):
# setup the parts and then compute the line integral
u(t) = u
v(t) = v
w(t) = w
dr = [derivative(u(t),t),derivative(v(t),t),derivative(w(t),t)]
A = (M(x=u(t),y=v(t),z=w(t))*dr[0]
+N(x=u(t),y=v(t),z=w(t))*dr[1]
+P(x=u(t),y=v(t),z=w(t))*dr[2])
global line_integral
line_integral = integral(A(t=t),t,tt[0],tt[1])
pretty_print(html(r'<h2 align=center>$ \int_{C} \left \langle M,N,P \right \rangle dr $ = $ %s $ </h2>'%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 in_3d:
show(G,stereo='redcyan',spin=true)
else:
show(G,perspective_depth=true)
Options
none
Tags
Primary Tags:
Secondary Tags:
A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.
Related Cells
Any related cells go here. Provide a link to the page containing the information about the cell.
Attribute
Permalink:
Author:
Date: 29 Jul 2020 23:00
Submitted by: Zane Corbiere