% Homework 1 - example

x = -1.5:0.01:1.5; % create a vector x which is a set of points from -2 to 2 with distance = 0.01
y = 2./(1+x.^2); % create a vector f(x) = 2/(1+x^2)
p3 = 1 + (x + 1) - (x + 1).*x + (2/5)*(x + 1).*x.*(x - 1); %create a vector p3(x)

%Plot graphs of f(x) and p3(x) in the same axes.
plot(x,y,'-r',x,p3,'--b');
%Label the graphs
legend('f(x)', 'p_3(x)');

% %Plot graphs of f(x) and p3(x) in the same axes, with a point (-1,1)
% plot(x,y,'-r',x,p3,'--b',-1,1,'ok');
% %Label the graphs
% legend('f(x)', 'p_3(x)');