Numerical methods Jiří Zelinka Autumn 2017 □ Numerical methods Literature Literature • Mathews, J.H., Fink, K.D.: Numerical methods using MATLAB, Pearson Prentice Hall, 2003 • Stoer, J., Bulirsch R.: Introduction to Numerical Analysis, Spriger, 1992 Assumptions a Linear algebra • Differential calculus • Integral calculus □ Numerical methods x: exact value, x: approximation x x — x: absolute error x error x — x < a: estimate of the absolute x—x x : relative error x—x x < S: estimate of the relative error Approximation x of x to s digits: x — x x < 5.10"5. Jiří Zelinka □ Numerical methods Error for the computer representation of the numbers Matlab code: » c=0.1; » x=c*ones(l,100); » sum (x)-10 ans = -1.953992523340276e-14 °/o rearrangement of the computation » A=reshape(x,10,10); » sum(sum(A))-10 ans = -1.776356839400250e-15 □ Numerical methods SP Conditionality Condition number: Ay y Ax X output relative error I input relative error 1 - the task is well-conditioned Cp > 100 - the task is ill-conditioned Condition number for matrix A - non-singular matrix CA= A A -i Jiří Zelinka □ i3" Numerical methods 5/9 Example of ill-conditioned matrix: Hilbert matrix H = (/j/j), hjj = -r^j Matlab code: » H=hilb(8) H = 1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/10 1/4 1/5 1/6 1/7 1/8 1/9 1/10 1/11 1/5 1/6 1/7 1/8 1/9 1/10 1/11 1/12 1/6 1/7 1/8 1/9 1/10 1/11 1/12 1/13 1/7 1/8 1/9 1/10 1/11 1/12 1/13 1/14 1/8 1/9 1/10 1/11 1/12 1/13 1/14 1/15 » cond(H) ans = 15257575253 □ i3" Jiří Zelinka Numerical methods 6/9 Typical ill-conditioned tasks • dividing by a small number • subtracting almost the same numbers • cumulation of errors in iterative calculation An = n- An_ľ Example: ln = J xnex-1dx o li = \f itegration by parts: ln = 1 — nln_i The initial error is multiplied by n in every step, i.e. n = 10 is the error multiplied by 10! = 3, 628, 800. Jiří Zelinka □ i3" Numerical methods Symbols Oy o f,g- functions defined in the neighbourhood of a point a (it is possible a = ±oc) f (x) = 0(g(x)) for x —>► a there exists a constant C > 0 |f(x)| < C-\g(x)\ in the neigbourhood of a point a. Meaning: function f is similar to g in the neigbourhood of a point a. r(x) = o(g(x)) for x ^ a limM = 0. Meaning: function f converges to 0 faster then g in the point a. Jiří Zelinka Numerical methods 8/9 For sequences {an)™=0, {bn)™=0 an = 0(bn) or an = o(bn) pro n —>► oc Sometimes the point a is clear - we can omit it: an = 0{1/n), f(h) = o(h3) Example: Taylor series f (x + h) = f (x) + f'(x)h + f(x+h) = f(x)+f'(x)h+0{h2), f(x+h) = f{x)+f'{x)h+o{h) □ i3> Jiří Zelinka Numerical methods 9/9