function y=linode20(a,b,c); % - revision of march first 2002(RMM) % - classifying a second order homogeneous ode with constant coefficients % - a y'' + b y'+ c y =0. % - usage y=linode20(a,b,c) % - to solve the nonhomogeneous equtation see linode22(a,b,c,q1) syms x m m1 m2 yh y1 y2 delta c1 c2 alpha beta disp(' Second order Linear homogeneous ODE with constant coefficients') disp(' a D2y + b Dy + C y= 0') sprintf(' where a = %d',a) sprintf(' b = %d',b) sprintf(' and, c = %d',c) disp('The characteristic equation is a m^2+bm+c=0') %you could use solve here ... solve('a*m^2+b*m+c', 'm'); delta = b^2-4*a*c; sprintf(' delta= b^2-4ac =%d ',delta) if delta==0 disp(' class B (critical double roots m1=m2=-b/(2a)') m1=-b/(2*a); m2=m1; y1=exp(m1*x) y2=x*y1 end if delta >0 disp(' class A supercritical, two different real roots,') m1= (-b+sqrt(delta))/(2*a); m2= (-b-sqrt(delta))/(2*a); sprintf(' m1=%d',m1) sprintf('m2=%d',m2) y1=exp(m1*x) y2=exp(m2*x) end if delta <0 disp(' class C subcritical , complex conjucate roots') alpha=-b/2/a beta=sqrt(-delta)/2/a y1=exp(alpha*x)*cos(beta*x) y2=exp(alpha*x)*sin(beta*x) end y=c1*y1+c2*y2; fprintf(' The Homogeneous solution yh=c1 y1+c2 y2 is :') return