{VERSION 2 3 "IBM INTEL NT" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Helvetica" 0 12 0 0 0 1 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R 3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Helvetica" 0 12 0 0 255 1 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Courier" 0 11 0 128 128 1 2 1 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Fancy2.mws" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "contour plot" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 19 "plot embe llishments" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "more general plotting of dsolve results (Perry's magic)" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 46 "automated solving of N equations in N unknowns" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 31 "charge distribution over a wire" }} {PARA 0 "" 0 "" {TEXT -1 20 "rotating mass-spring" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "restart; with(plots ): " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 "The contour plot is a special case of plot3d, which shows conto urs. " }}{PARA 0 "" 0 "" {TEXT -1 69 "Any plot3d graph can be manipula ted (oriented) to give contour plots." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "f:=1/sqrt((x-a)^2+(y-b)^2);" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "g:=subs(a=-1,b=1,f)-subs(a= 1,b=2,f);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "plot3d(g,x=-2. .1,y=0..3,contours=35,view=-5..5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "subs(a=-1,b=1,f)-subs(a=1,b=2,f);" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "The 'view' instruction limits the range of the z- direction, " }}{PARA 0 "" 0 "" {TEXT -1 69 "and the 'grid' command giv es the grid on which the contour is based. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "The 3d view is a manipulated vi ew of the contour plot. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 70 " Here is a problem where a 40x40 is set up via a loop and then solved " }}{PARA 0 "" 0 " " {TEXT -1 64 "and the results graphed. This problem is one model of h ow charge" }}{PARA 0 "" 0 "" {TEXT -1 65 "accumulates at sharp points, in this case, at the ends of a wire." }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 68 "This calculates the approximate surfa ce charge on a long thin wire, " }}{PARA 0 "" 0 "" {TEXT -1 62 "where \+ the wire radius is small compared to its overall length." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 "It ultimately dete rmines the charges on each subsection of the wire " }}{PARA 0 "" 0 "" {TEXT -1 41 "by solving N equations in N unknowns, by " }}{PARA 0 "" 0 "" {TEXT -1 57 "specifying that the potential on the axis of each ho llow " }}{PARA 0 "" 0 "" {TEXT -1 44 "cylindrically- shaped element be the same V." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart; with(plots):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 "Potential due to a charge d section of a cylinder when the ends " }}{PARA 0 "" 0 "" {TEXT -1 41 "of the cylinder are located at Z1 and Z2 " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "V:=Int(Int(k*rho*2*Pi*r/s qrt(r^2+z^2),r=0..R),z=Z1..Z2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "V:=value(V); # Evaluate the double integral. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 74 "Set the v alue of the k constant to 1, and the radius of the cylinder to 1." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "Vsu b:=subs(\{k=1,R=1\},V); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "L:=5; # The length of a section " } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "Vs:=1; # The potential mea sured at each section " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 79 "Find the potential at different segment d istances away from a charged segment. " }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "d:=(dist)->evalf(subs(\{Z1=-L/2 +L*dist,Z2=L/2+L*dist\},Vsub));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 "Make a function for the potential of the section at \"dist\" sections " }}{PARA 0 "" 0 "" {TEXT -1 49 "awa y from the charged section with rho=\"charge\". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "Vsec:=(dist,charge) ->subs(rho=charge,d(dist));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 67 "Set up 4 equations to find the 4 unknown charges on the 4 sections." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "V1:=Vs=Vsec(0,rho1)+Vsec(1,rho2)+Vsec(2,r ho3)+Vsec(3,rho4); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "V2:= Vs=Vsec(1,rho1)+Vsec(0,rho2)+Vsec(1,rho3)+Vsec(2,rho4); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "V3:=Vs=Vsec(2,rho1)+Vsec(1,rho2)+Vs ec(0,rho3)+Vsec(1,rho4); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "V4:=Vs=Vsec(3,rho1)+Vsec(2,rho2)+Vsec(1,rho3)+Vsec(0,rho4);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "fsolve(\{V.(1..4)\},\{rho.(1..4)\}); # Solve four equations for fo ur unknowns " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 59 "Now do the same problem with more segments in the cylin der." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "NumSeg:=40; # Number of segments in cylinder. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 36 "Use a loop to c reate the equations. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "for m from 1 to NumSeg do " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "V.m:=Vs=convert([seq(Vsec(abs(m-n),rho.n),n=1..NumSeg )],`+`): od:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 86 "This loop creates NumSeg equations. In each equation Vs is equated to a sum of items. " }}{PARA 0 "" 0 "" {TEXT -1 92 "This s um is converted (via '+' ) from a sequence of items, created from the \+ Vsec function.. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "sol:=fsolve(\{V.(1..NumSeg)\},\{rho.(1..NumSeg)\}): # Solve the 40 equations for the 40 unknowns. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "assign(sol): # Assign the solutions to p1-p40 " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 99 "plot([seq([n,rho.n],n=1.. NumSeg)],title=`Charge distribution across the bar`); # plot the resul ts. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 64 "Here is complex problem solved \+ via Lagrange's equations using a " }}{PARA 0 "" 0 "" {TEXT -1 65 "nume ric version of dsolve. Then some creative (Perry) functional " }} {PARA 0 "" 0 "" {TEXT -1 59 "assignments are made which allow the resu lts to be plotted." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 77 "Two equal masses are connected by a spring, and are rotat ing about their CM. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart;with(plot s): " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "alias(r=r(t),phi=ph i(t)): " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "x1:=r/2*cos(phi) : y1:=r/2*sin(phi): x2:=-x1:y2:=-y1: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 " KE:=simplify(m/2*(diff(x1,t)^2+diff(y1,t)^2+diff (x2,t)^2+diff(y2,t)^2));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "PE:=k/2*(r-r0)^2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "L:=KE -PE; # lagrangian" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 60 "valuesin:=\{diff(r,t)=rdot,diff(phi,t)=phido t,r=ra,phi=phia\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "Lsvel :=subs(valuesin,L); # L with dummy variables" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 46 "Generalized momenta w/ \+ symbols (pj = dLdqjdot)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 48 "pr:=diff(Lsvel,rdot); pphi:=diff(Lsvel,phidot) ; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "dLdr:=diff(Lsvel,ra);dLdphi:=diff(Lsvel,phia); # dL/d qj" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "valuesback:=\{rdot=diff(r,t),phidot=diff(phi,t),ra=r, phia=phi\};" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "pra:= subs(valuesback,pr);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 54 "pphia:=subs(valuesback,pphi); # generalized p' s 'live'" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "dLdra:=subs(val uesback,dLdr);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "dLdphia:= subs(valuesback,dLdphi);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "eqr:= diff(pra,t)-dLdra = 0; # lagr ange's eqn in r." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "eqphi:= diff(pphia,t)-dLdphia = 0; # ditto for phi." }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "eqra:= subs(r=a(t ),phi=b(t),m=1,r0=1,k=2,eqr);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "eqphia:=subs(r=a(t),phi=b(t),m=1,r0=1,k=2,eqphi); # new set of n amed vars" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 129 "The square brackets in the following command are importa nt in the following dsolve command to keep the solutions in correct or der" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 84 "sol:=dsolve(\{eqra,a(0)=3/2,D(a)(0)=0,eqphia,b(0)=0,D(b)(0)=10\},[ a(t),b(t)],numeric);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "sol (1); # take a look at the solution when t=1 sec" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 97 "rp:= z -> rhs( sol(z)[2]); phip:= z -> rhs(sol(z)[4]); # magic assignments (Perry wor ked this out)" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "h:=plot(rp,0..3,color=blue): " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "j:=plot(phip,0..3,color=red): " }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 50 "display(\{h,j\},title=` r(blue) and phi(red) vs t`) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "plot([rp,phip,0..12],coords=polar,title=`polar plot o f motion`); " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 13 "end of Fancy2" }}}}{MARK "46 5 0" 13 }{VIEWOPTS 1 1 0 1 1 1803 }