222 - Topic 22 - Line Integral 2D Vector Field

2762 days ago by Professor222

Computing the line integral of a vector field

John Travis

Mississippi College

%auto var('x,y,t,s') @interact(layout=dict(top=[['M','u'], ['N','v']], bottom=[['a'],['b'],['xx'],['yy']])) def _(M=input_box(default=x*y,width=30,label="$M=$"), N=input_box(default=-y,width=30,label='$N=$'), u=input_box(default=(sin(t)+1*cos(t)*sin(t)^3)/1,width=30,label='$x(t)=$'), v=input_box(default=1-cos(t),width=30,label='$y(t)=$'), a=input_box(default=0,width=10), b=input_box(default=2*pi,width=10), xx = range_slider(-5, 5, 1, default=(-2,2), label='x Range'), yy = range_slider(-5, 5, 1, default=(-1,3), label='y Range')): dr = [derivative(u,t),derivative(v,t)] A = (M(x=u,y=v)*dr[0]+N(x=u,y=v)*dr[1]).simplify_trig().simplify() pretty_print(html('$\int_C <%s'%str(latex(M))+',%s'%str(latex(N))+'> dr =$')) print pretty_print(html('$\int_{%s}'%str(latex(a))+'^{%s}'%str(latex(b))+'%s dt$'%str(latex(A)))) line_integral = integrate(A,t,a,b) pretty_print(html('<h2 align=center>Vector Field Integral = %s</h2>'%str(line_integral))) G = plot_vector_field((M,N),(x,xx[0],xx[1]),(y,yy[0],yy[1])) G += parametric_plot([u,v],(t,a,b),thickness='5',color='yellow') show(G) 
       
$M=$  $x(t)=$ 
$N=$  $y(t)=$ 
x Range 
y Range 

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