function polyeg
% Cubic Polynomial Advanced Example: y = f(x) = x^3+x^2-3*x-3;
clc
% MATLAB Zero Finding Function "fzero" for m-file subfunction f
%   near a point (here 2):
[xs,fs] = fzero(@f,2); % Note: for non-inline function, 
%  function argument needs a function handle "@".
fprintf('\n f(x) roots near x=2: xs = %9.6f; f(xs) = %10.4e;',xs,fs);
%
% MATLAB Polynomial Root Finder Function "root":
r = roots([1,1,-3,-3]);  % Uses polynomial coeffs,
%   from highest to lowest degree in row vector form.
fprintf('\n Polynomial Roots of f(x): r ='); 
fprintf('%9.6f; ',r); % Prints roots vector by reusing format.
fprintf('\n Zero Errors: f(r) ='); 
fprintf('%10.4e; ',f(r)); 
%
% Polynomial Plot with vectors (x,y):
fprintf('\n See Improved Plot of ''x^3+x^2-3*x-3'':\n');
x=-3:0.1:+3;
y=f(x);
ysize=size(y,2); % 61
plot(x,y,'linewidth',3);
xlabel('x','fontsize',24,'fontweight','bold');
ylabel('y','fontsize',24,'fontweight','bold');
ht=title('MATLAB Plot of ''x^3+x^2-3*x-3''','fontsize',28,'fontweight','bold');
% get(ht,'fontname'); % Helvetica
set(gca,'fontsize',20,'fontweight','bold');
set(gcf,'color','white','units','centimeters','position',[30,2,30,30]);
grid on
%
function y=f(x)
% Class Polynomial Example in Vector Compatible Format:
y=x.^3+x.^2-3*x-3;