
Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!

Linear Algebra and Geometry - Scientific Computing
a = 1. 483593 , b = 1. 484111.
Determinate the result of ¯s = ¯a ¯b, where ¯x stands for machine-number corresponding to x in the used floating-point arithmetic and stands for the machine-subtraction. Compare ¯s with c = a − b and then compute the relative error of ¯s.
f 1 (x) =
1 − cos(x) x^2 , f 2 (x) =
ex^ − 1 x
f 3 (x) = 1 −
1 − x^2 , f 4 (x) = (x + 1)^2 − 1 x
in x = 10−n, n = 1, 2 , .., 16. After that, reformulate the functions in order to avoid cancellation error. Assuming the values obtained using reformulated functions as exact values, compute relative errors and compare them with machine precision. Print the relative error for every value of x and graphically represent it.
x 1 = 2
xn = 2n−^1 /^2
1 − 41 −nx^2 n− 1 , n ≥ 2
which gives a π approximation. Compute the relative errors |π − xn|/π for n = 1, ..., 40 and plot the relative errors behavior using logarithmic scale. After that, determine an expression ˜xn equivalent to xn which avoids cancellation error. Graphically represent relative errors |π − x˜n|/π for n = 1, ..., 40 using logarithmic scale. Compare this plot with the previous one and comment the results.
f ′(x) ≈ r(x) =
sin(x + h) − sin(x) h
with h = 2−k, k = 1, 2 , ..., 50. Fix for instance x = π/4; graphically represent the relative error |f ′(x) − r(x)|/|f ′(x)| and comment the results. After that, reformulate r(x) in order to avoid cancellation errors and graphically represent the relative error.