% Horner's algorithm to divide a polynomial p by the
% linear factor z-z0
%
% i.e.
%
% p(z) = q(z) (z-z0) + r
%
% Inputs
% p vector of polynomial coefficients, from highest to lowest degree
% for example the polynomial 2z^4 - z^3 + z would be:
% p = [2 -1 0 1 0];
%
% z0 root of linear factor
%
% Outputs
% q vector of polynomial coefficients for the quotient polynomial
% ordered from highest to lowest degree
%
% r residual (a scalar)
function [q,r] = horner(p,z0)
n = length(p)-1; % the degree of the polynomial
q = zeros(size(p)); % initialize vector of zeroes of same size as p
% TO BE COMPLETED