222 - Topic 21 - Computing Line Integrals of 2D Vector Fields

1491 days ago by Professor222

# Some interesting choices to use for curves. Plug in the appropriate formulas below. #xx(t)=t+1/2 #yy(t)=t^2-1/4 #a=-1/2 #b=3/2 #xx(t)=2*t #yy(t)=4*t^2-2*t #a=0 #b=1 #xx(t)=2*sin(t) #yy(t)=4*sin(t)^2-2*sin(t) #a=0 #b=pi/2 #xx(t)=t #yy(t)=t^2 #a=0 #b=1 #xx(t)=sin(t) #yy(t)=sin(t)^2 #a=0 #b=pi/2 
       
var('x,y,t') @interact def _(M=input_box(default=x+2*y,label='$M(x,y) = $'), N=input_box(default=2*x-y,label='$M(x,y) = $'), a=input_box(default=0,label='$t_{start} = $'), b=input_box(default=pi/2,label='$t_{end} = $'), xx=input_box(default=sin(t),label='$x(t) = $'), yy=input_box(default=1-cos(t),label='$y(t) = $'), xa=input_box(default=0,label='min x'), xb=input_box(default=1,label='maxx'), ya=input_box(default=0,label='min y'), yb=input_box(default=1,label='min y')): A = M(x=xx,y=yy)*diff(xx,t)+N(x=xx,y=yy)*diff(yy,t) B=integrate(A,t,a,b) delt = b-a G = parametric_plot((xx,yy),(t,a,b)) npts = 10 G += points((xx(t=a+delt*k/npts),yy(t=a+delt*k/npts)) for k in range(npts+1)) G += plot_vector_field((M,N),(x,xa,xb),(y,ya,yb)) pretty_print('Line Integral over the given curve is '+str(B)) show(G) 
       
$M(x,y) = $ 
$M(x,y) = $ 
$t_{start} = $ 
$t_{end} = $ 
$x(t) = $ 
$y(t) = $ 
min x 
maxx 
min y 
min y 

Click to the left again to hide and once more to show the dynamic interactive window

var("x,y") M = x+2*y N=2*x-y xx = sin(t) yy = -cos(t)+1 dx = diff(xx,t) dy = diff(yy,t) integrand = M(x=xx,y=yy)*dx + N(x=xx,y=yy)*dy show(integrand) print "The Line Integral is ",integrate(integrand,t,0,pi/2) 
       
The Line Integral is  2
The Line Integral is  2