hw2 - function y=macheps%Problem 4.3%computes the machine...

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

View Full Document Right Arrow Icon
function y=macheps %Problem 4.3 %computes the machine epsilon, by using algorithm below %machine epsilon can be thought of as the smallest number that when added %to one gives a number greater than 1 eps=1; if (eps+1)<=1 eps=2*eps; end if (eps+1)>=1 eps=eps/2; while (1) if (1+eps)<=1 break ; end eps=eps/2; end eps=2*eps; end fprintf( '%5.4e\n' ,eps); end Function run in matlab EDU>> macheps 2.2204e-16 EDU>> eps ans = 2.2204e-16
Background image of page 1

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

View Full DocumentRight Arrow Icon
function problem4_4 %Problem 4.4 %REALMIN Smallest positive normalized floating point number. % x = realmin is the smallest positive normalized double precision floating % point number on this computer. %This program attempets to find this realmin value. realmin=zeros(100,1); realmin(1)=1; i=1; while (1) i=i+1; realmin(i)=realmin(i-1)/2; if realmin(i)<=0 disp(realmin(i-1)) break end end end Function problem4_4 run in matlab EDU>> realmin ans = 2.2251e-308 EDU>> problem4_4 4.9407e-324 function problem4_15(x,step)
Background image of page 2
%Problem 4.15 %Application using forward, center and backward difference
Background image of page 3

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

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

This note was uploaded on 09/27/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Page1 / 6

hw2 - function y=macheps%Problem 4.3%computes the machine...

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

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