function roots = quadroots(coefs)
%QUADROOTS  Find roots of a quadratic polynomial using quadratic formula
%
%  coefs is the vector of coefficients.  I.e., for 2 x^2 -3x + 9, 
%  coefs=[3 -2 1].  The output roots is a vector containing the two
%  roots, in this case [3 -1.5].

%  Note: this routine blindly uses the quadratic formula, which may
%  not be a good idea.  A better idea is to use Matlab's roots function.

a=coefs(1); b=coefs(2); c=coefs(3);

% Here's the quadratic formula:
%%  the square root part
s=sqrt(b*b-4*a*c);
%%  root with plus sign
r1=(-b+s)/(2*a);
%%  root with minus sign
r2=(-b-s)/(2*a);

roots=[r1,r2];
