% Problem 8

% Clear variables and figures.

clear
close all

% Declare x to be symbolic and define poly to be the given polynomial.

syms x
poly = x^6 - 21*x^5 + 175*x^4 - 735*x^3 + 1624*x^2 - 1764*x + 720
 
poly =
 
x^6-21*x^5+175*x^4-735*x^3+1624*x^2-1764*x+720
 

% a)

factor(poly)
 
ans =
 
(x-1)*(x-2)*(x-3)*(x-4)*(x-5)*(x-6)
 
% The polynomial factors quite nicely.

% b)

solve(poly)
 
ans =
 
[ 1]
[ 2]
[ 3]
[ 4]
[ 5]
[ 6]
 
% The roots are consistent with the factorization.

% c)

ezplot(poly, [0.5 6.5])
title 'Figure 8.1'
pause
print -deps figA8-1

% The graph is shown in Figure 8.1.

% d)

hold on
ezplot(diff(poly), [0.5 6.5])
hold off
% Let's add a grid so that we can see zero crossings more easily

grid on
title 'Figure 8.2'
pause
print -deps figA8-2

% The graph is shown in Figure 8.2.  Notice that when the derivative
% is positive, the polynomial is increasing, and when the derivative
% is negative, the polynomial is decreasing.  Also, the derivative
% crosses zero precisely when the polynomial reaches a local maximum
% or minimum.

echo off
diary off