function y=linode1(p,q) % - revision feb 12 2004(RMM) % - Linear nonhomogeneous first order ode % - usage y=linode1(p,q) to solve y'+p y =q. % - some authors like to call the integrating factor a source or Green function. syms x u yh yp y c f disp(' you are solving yprime+py=q') disp(' where p = '); disp(p) disp(' and, where q = '); disp(q) disp('Integrating Factor u= exp(int(p),x)') u=simplify(exp(int(p,'x'))) disp(' Homogeneous solution is yh=c/u') yh=c/u disp(' The Particular solution is yp=1/u * Int( u*q)') yp=simplify(int(u*q,'x')/u) disp(' The general solution is y = yh+yp') y=simplify(yh+yp) disp(' compare with output from the dsolve routine in matlab') dsolve('Df=p*f+q','x') return