ps4solnsF06

ps4solnsF06 - %Engineering 6, Fall 2006, Problem 4.1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
%(Estimating value of e using (1+1/n)^n as n gets large) %Suppress extra lines in output and set fixed short g display format compact ; format short g ; clc; %Clear command window %Create vector of values for n n = [1 10 20 50 100 500 1000 2000 4000 8000]; %Calculate value of (1+1/n)^n for each value in the n vector y = (1 + 1./n).^n; %Calculate the relative percentage error between each value %in y and the true value exp(1) rel_error = abs((y-exp(1))/exp(1))*100; %Construct array with each vector being a column table_of_values = [n' y' rel_error']; %Display table of values disp( 'Using (1+1/1n)^n to calculate e (2.7183):' ); disp( ' n (1+1/n)^n Rel. % error' ); disp(table_of_values); Displayed results: Using (1+1/1n)^n to calculate e (2.7183): n (1+1/n)^n Rel. % error 1 2 26.424 10 2.5937 4.5815 20 2.6533 2.3906 50 2.6916 0.98201 100 2.7048 0.49546 500 2.7156 0.099817
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

ps4solnsF06 - %Engineering 6, Fall 2006, Problem 4.1...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online