clear all; close all;

p1 = [1, 0, -4]; % Create a polynomial f(x) = x^2 -4


% Create some x values to evaluate f(x)
xmin = -5.0;
xmax = 5.0;
xstep = 0.2;

yoffset = 1.0; % extend axes beoynd range of y for plot

x=xmin:xstep:xmax;  % Make x

y = polyval(p1,x); %evaluate polynomial

plot(x,y); % plot it

%%%  Plot X and Y axes and label

title('f(x) = x^2 - 4')

hold on
plot([xmin xmax],[0 0],'-k'); % X Axis
plot([0 0],[min(y)-yoffset max(y)+yoffset],'-k'); % Y Axis


axis tight % force concise display of plot


roots_p1 = roots(p1)  % Solve the Equation  


% Plot Roots

plot(roots_p1(1),0,'o','LineWidth',2,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','r',...
                'MarkerSize',10);



plot(roots_p1(2), 0,'o','LineWidth',2,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','r',...
                'MarkerSize',10);


shg; % show figure