# # Several Maple procedures are written for the purpose of studying the # Wronskian of two functions. # # Procedures in Maple...one way to improve a systems hwk. # # > p:=proc(x)x^2 end; p := proc(x) x^2 end > p(3); 9 > > p0:=proc(f) \ local t,u,v,w; \ u:=(D@@2)(f)(t)-4*D(f)(t)+4*f(t); \ v:=simplify(u); \ w:=unapply(v,t); \ eval(w) \ end; \ p0 := proc(f) local t,u,v,w; u := (D @@ 2)(f)(t)-4*D(f)(t)+4*f(t); v := simplify(u); w := unapply(v,t); eval(w) end > p0(cos);\ t -> 3 cos(t) + 4 sin(t) > p0(t->t*exp(2*t)); 0 > # This next procedure shows how you can extract things such as cycle # time for a predator-prey problem, or hang time for a field-goal # problem. # # The idea is that you have a list, (built up somehow or other, earlier) # and you want to know the first time that an entry of that list is equal to # or greater than some trigger value. This procedure uses a while loop. > p1:=proc(xdata,trigger) \ local k,n,x; \ n:=nops(xdata); \ k:=1; \ x:=xdata[k]; \ while x p1([1,3,4,2,6,2,3,5],4); [3, 4, 4] > p1([1,3,5,2,6,4],4); [3, 5, 4] > p1([1,3,2,2,6,4],5); [5, 6, 5] > > > # This procedure calculates the Wronskian of two functions. Note: it # doesn't find the Wronskian of two expressions. The inputs here have # to be functions. There are more bells and whistles in Maple, and a # really top job version of this wronski procedure would include some # checking for types, so that it would give a warning if you put in the # wrong kind of inputs. But we're not here to become code # wonks... # # Somewhere incremental enhancements tail off into irrelevancy, just # like a paragraph that drags on and on saying nothing in particular but # just wandering around, as if the athor had got to tiured evenb t- # spelnright. > wronski:=proc(f,g) \ local u,df,dg,t,w; \ df:=D(f); \ dg:=D(g); \ u:=f(t)*dg(t)-df(t)*g(t); \ u:=simplify(u); \ w:=unapply(u,t); \ eval(w); \ end; wronski := proc(f,g) local u,df,dg,t,w; df := D(f); dg := D(g); u := f(t)*dg(t)-df(t)*g(t); u := simplify(u); w := unapply(u,t); eval(w) end -------------------------------------------------------------------------------- > wronski(cos,sin); 1 -------------------------------------------------------------------------------- > wronski(t->exp(t)*cos(t),t->exp(t)*sin(t)); t -> exp(2 t) -------------------------------------------------------------------------------- > wronski(t->sin(2*t),t->1+t^2); 2 t -> 2 sin(2 t) t - 2 cos(2 t) - 2 cos(2 t) t -------------------------------------------------------------------------------- > plot("); -------------------------------------------------------------------------------- > ** Maple V Graphics ** # Note that in this third example, the Wronskian of the two functions is # zero infinitely often. The theorem only says that # > # # IF # the two functions are linearly independent (rather than, say, multiples # of each other) solutions of a DE y''+py'+qy=0 with p and q # continuous, then their Wronskian is never zero, that if the Wronskian # is ever different from zero, then the functions are indeed linearly # independent, and that W'(f1,f2)(t)=-p*W(f1,f2)(t). # # The two functions f1 and f2 here are sin(2t), and t^2+1. The text # explains how, given any two (reasonable) functions, you can get a # 2nd order DE which has those for solutions. # # If we assume that p(t) and q(t) are just the coefficients needed so that # the DE y''+py'+qy has those two as solutions, this assumption says # that # # (1) 1+2tp+(t^2+1)q=0 # (2) -4 sin 2t +2 cos 2t p+sin 2t q=0. # # Hey: let's let Maple do the algebra: > eqn1:=2+2*t*p+(t^2+1)*q=0;\ eqn2:=-4*sin(2*t)+2*cos(2*t)*p+sin(2*t)*q=0; 2 eqn1 := 2 + 2 t p + (t + 1) q = 0 eqn2 := - 4 sin(2 t) + 2 cos(2 t) p + sin(2 t) q = 0 -------------------------------------------------------------------------------- > solve({eqn1,eqn2},{p,q}); 2 sin(2 t) t + cos(2 t) {q = - 2 -----------------------------------, 2 cos(2 t) t + cos(2 t) - sin(2 t) t 2 sin(2 t) (2 t + 3) p = -----------------------------------} 2 cos(2 t) t + cos(2 t) - sin(2 t) t -------------------------------------------------------------------------------- > # Well, that goes a long way toward explaining how the Wronskian # could flop around like the graph shows. The p and q are continuous # only on intervals where the denominator is never zero. This # denominator, though, is > pqdenom:=cos(2*t)*t^2+cos(2*t)-t*sin(2*t); 2 pqdenom := cos(2 t) t + cos(2 t) - sin(2 t) t -------------------------------------------------------------------------------- > plot(pqdenom,t=-10..10); -------------------------------------------------------------------------------- > ** Maple V Graphics ** # The Wronskian becomes zero, but only when the denominator in p # and q is zero so that p and q are not continuous. The DE really only # makes sense in certain relatively short intervals...the coefficients # (forces, frictions) become infinite at the endpoints of those intervals.