HW#5 solutions (part 2)

# HW#5 solutions (part 2) - hold all z=r1-r; %calculation of...

This preview shows pages 1–6. Sign up to view the full content.

HOMEWORK SET# 5 %% 1(a) sum=1; %intializing sum to be 1 x=-12; %given value for n=1:51 %taking 51 terms Sum=sum+x^n/(factorial(n)); summing the terms in expansion end num2str(sum, '%10.5e\n' )%gives five decimal bits %% 1(c) xx=12; %given value sum1=1; %initializing sum to be 1 for n1=1:31 %taking 31 terms sum=sum+(x^n1)/factorial(n1); %summing the terms in the expansion end num2str(1/sum1, '%10.5e\n' )%gives five decimal bits

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
%2.a) Lagranges Interpolation clear all close all clc for k=-3:0.01:0; %taking x in steps of 0.01 r=exp(k); %exponential k r1=0.042098*k^3+0.326096*k^2+0.91613*k+1; %polynomial obtained from lagranges interpolation plot(k,r); %plotting k and r hold all plot(k,r1); %plotting k and polynomial

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: hold all z=r1-r; %calculation of error plot(k,z); %plotting k and error hold all end plotting exp(k)and polynomial obtained from lagranges polynomial Plotting error %2.b) Method of divided differences clear all close all clc for x=-3:0.01:0 %plotting the x in steps of 0.01 r=exp(x); %exponential x r1=0.04978+(x+3)*[0.08555+(x+2)*[0.073495+0.0421 005*(x+1)]]; %polynomial obtaine from divided differences plot(x,r); %plotting x and r hold all plot(x,r1); %plotting x and r1 hold all z=r1-r; %calculating error plot(x,z); %plotting error hold all end max(z); Plotting exp(r)and polynomial from divided differences method Plotting error...
View Full Document

## This note was uploaded on 02/21/2011 for the course EE 456 taught by Professor Dr.yang during the Fall '09 term at SUNY Buffalo.

### Page1 / 6

HW#5 solutions (part 2) - hold all z=r1-r; %calculation of...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online