function y2= ROO(p,q,y1) % - March 16,2002 revision(RMM) % - ROO is the reduction of order for D2y+p*Dy+q*y=0. % - P and Q are functions of x. % - y1 is one solution and ROO will find the second linearly indep. solution y2. % - % - / % - | - p dx % - / exp( / ) % - y2= y1 | ------------------ dx % - / (y1)^2 % - % - % - usage y2=ROO(p,q,y1) syms x disp(' Reuction of order ') disp(' You know y1(x) is a solution for D2Y+P*Dy+q*y=0 ') disp(' Find y2=y1(x)*u(x). ') disp(' where p(x) = '); disp(p) disp(' and, q(x) = '); disp(q) % - let us also verify that y1 is a solution. z1=diff(diff(y1,'x'),'x')+p*diff(y1,'x')+q*y1; z1=simplify(z1) if z1==0 disp ('Tested y1 is a solution. So we proceed to find y2') z2=int(p,x) z2=exp(-z2) z2=simplify(z2/y1/y1) u=simplify(int(z2,x)) disp(' The second linearly inependent solution y2 is= ') y2=simplify(u*y1) disp( 'Extra the wronskian w= y1*Dy2-y2*Dy1='); w=y1*diff(y2,'x')-y2*diff(y1,'x'); else disp ('z1=');disp(z1) disp(' So y1 is not a solution. try again') end return