Math 112: MATLAB Assignment 2
Due Date:
The sample program below calculates 2nd and 4th degree Taylor polynomials for the function f(x)=1/(1+x^2) about the point a=0. The polynomials are plotted, together with the function, over the interval x=-1, 1.
% Lines beginning with a percent sign (%) are comments
% construct Taylor polynomials.
clear;
x=[-1: .01:1];
y=(1+x.^2).^(-1);
P2=1-x.^2;
P4=1-x.^2+x.^4;
plot(x,y)
hold on
plot(x,P2,'--')
hold on
plot(x,P4,':')
grid on
After running the above example, do the following to hand in: (Consult the MATLAB TA's if you have any questions.)
◙ Calculate the 2nd and 3rd degree Taylor polynomials for the function y=ln(1+x) about the point a=0.
◙ Plot these polynomials and the function on the interval -1<x<3.