% Synthetic division
%  MVW, 21 Sept 2011
%
% Divide polynomial a(x) = a(1) + a(2)*x + ... + a(n)*x^{n-1}
%   by quadratic polynomial b(x) = x^2 + u*x + v
% 
% Return the quotient q(x) = a(3) + a(4)*x + ... + a(n)*x^{n-3}
%   and the remainder r(x) = a(2)*x + a(1) = s*x + t
%   in the overwritten vector a.
%
function [s,t] = syndiv(a, u, v)
  n = length(a);
  for j=n:-1:3
    a(j-1) = a(j-1) - a(j)*u;
    a(j-2) = a(j-2) - a(j)*v;
  end
  s = a(2);
  t = a(1);
end
