Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
x xa
Absolute and relative errors Ea x xa , a
xa
x xn 1
Iterative schemes and stop criterion: a n s
xn
1
For n digits correct, base 10: s 10
n
Number representations
Integer representation
Floating-Point representation: x = m be
Consequence of Floating Point Reals:
Limited range (underflow & overflow )
Limited precision (Quantizing errors)
Relative error constant, absolute error growths with number
x
For t = significant digits with rounding: = b1-t = Machine Epsilon
x 2
2.29 Numerical Fluid Mechanics PFJL Lecture 2, 3
Numerical Fluid Mechanics TODAYs Outline
Absolute Error
Relative Error
Unbounded for
m = m1 m2 0
Multiplication:
Add exp, multiply mantissa, normalize and chop/round
Division:
Subtract exp, divide mantissa, normalize and chop/round Relative Error
Bounded
%The following accounts for the case when another digit is added when
%summing two numbers... ie. if the number of digits desired is only 3,
%then 999 +3 = 1002, but to keep only 3 digits, the 2 needs to be wiped out.
if (sc ~= 0)
if (log10(sc*ct) >= n)
ct=round(ct/10)*10;
% 'ct'
end
end
But note:
>> round(10^1*(0.095/10^(-1)))
10
Recursion Algorithm
>> horner
p =
General order n
55
If
N=20; sum=0; sumr=0;
b=1; c=1; x=0.5;
xn=1;
% Number of significant digits in computations Result of small, but significant
dig=2;
ndiv=10; term destroyed by subsequent
for i=1:N
recur.m addition and subtraction of almost
a1=sin(pi/2-pi/(ndiv*i));
a2=-cos(pi/(ndiv*(i+1))); equal, large numbers.
% Full matlab precision
xn=xn*x;
addr=xn+b*a1; Remedy:
addr=addr+c*a2;
ar(i)=addr; Change order of additions
sumr=sumr+addr;
z(i)=sumr;
% additions with dig significant digits ' i delta Sum delta(approx) Sum(approx)'
add=radd(xn,b*a1,dig); res=[[1:1:N]' ar' z' a' y']
add=radd(add,c*a2,dig);
hold off
recur.m
% add=radd(b*a1,c*a2,dig);
% add=radd(add,xn,dig); a=plot(y,'b'); set(a,'LineWidth',2); Contd.
a(i)=add; hold on
sum=radd(sum,add,dig); a=plot(z,'r'); set(a,'LineWidth',2);
y(i)=sum; a=plot(abs(z-y)./z,'g'); set(a,'LineWidth',2);
end legend([ num2str(dig) ' digits'],'Exact','Error');
sumr
b = 1; c = 1; x = 0.5;
dig=2
..\codes_2\recur.png
res =
Recurrence Relation:
Proof :
3-digit Recurrence:
> y2 !!
< 0 !! Correct
Exercise: Make MATLAB script
Forward Recurrence
Forward Recurrence
Unstable
Backward Recurrence
Millers algorithm
Stable
with N ~ x+20
Example
Discretization
Recurrence
Order p of accuracy indicates how fast the error is reduced when the
grid is refined (not the magnitude of the error)
2.29 Numerical Fluid Mechanics PFJL Lecture 2, 19
Derivation of
General Differential Error Propagation Formula
Univariate Case y f ( x)
x 2 x 3 x n n
Recall: f (xi 1 ) f ( xi ) x f '( xi ) f ''( xi ) f '''( xi ) ... f ( xi ) Rn
2! 3! n!
x n 1 ( n 1)
R n f ( ) O ( x n 1 )
n 1!
Hence, y f f ( xi 1 ) f ( xi )
x 2 x 3 x n n
x f '( xi ) f ''( xi ) f '''( xi ) ... f ( xi ) Rn
2! 3! n!
For x 1, f x f '( xi ) O ( x 2 ) x f '( xi )
Multivariate case
n
f ( x1 ,..., xn )
y f ( x1, x2 , x3 ,..., xn ) For xi 1, y i
i 1 xi
Derivation done in class on the board
Absolute Errors
? y~f (x)x
Function of one variable x = x - x
> y~f (x)x
Fct. of n var., General Error Propagation Formula
x x
=>
=>
=> r y r i
r y r i
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.