%Solution for exercise 9 with inputs: quadEqloesung.m
%Christoph Erath
function quadEqloesung
% no (real) solution
[numSol, sol] = quadEq(1,1)

% one solution
[numSol, sol] = quadEq(2,1)

% two (real) solutions
[numSol, sol] = quadEq(3,1)

% ------------------------------------------------------------------------------
function [numSol, sol] = quadEq(p,q)
  r = (p/2)^2-q;
  if (r<0)
    numSol = 0;
    sol = [];
  elseif (r>0)
    numSol = 2;
    sol = -p/2 + sqrt(r)*[1 -1];
  else
    numSol = 1;
    sol = -p/2;
  end
