function [r1, r2] = quadratic_solve2(varargin)
%solves ax^2 +bx+c with variable number of arguments
% if n=2 the function solves x^2+bx+c
% if n=3 the function solves ax^2+bx+c
% otherwise the function returns an error message

if(nargin==2) %varargin has 2 inputs
    a=1;
    b=varargin{1};
    c=varargin{2};
elseif(nargin==3)
    a=varargin{1};
    b=varargin{2};
    c=varargin{3};
else
    error('Input to quadratic solve should be 2 or 3 arguments');
end
d = b^2-4*a*c;
r1 = -b + sqrt(d)/(2*a);
r2 = -b - sqrt(d)/(2*a);

%if the user enters 1 output argument
if nargout <2
    r1 = [r1,r2];
end   
end

