Lecture 5 Flashcards
Relative error
er = |x-^x|/|x|
Independent of magnitude (≠ to absolute errors)
Significant digits/figures
digits carrying meaningful information
- 00350 = 3 digits
- 14159 = 6 digits
- 00035 = 2 digits
Relation relative error / accurate digits
rel_er <= 10^{-n+1}, n is the number of accurate significant digits
You know a tree is 170 ft tall, but your tool has a rel_err=10%. What’s the max measurement to expect?
187 ft
^x = x(1 ± err)
You measure 170 ft tall with a measurement tool rel_err=10%, what’s the actual min height?
155 ft
x = ^x / (1 ± err)
After rounding, a number has 5 digits, what’s an estimate of the upper bound of the relative error?
10^-4 (n=5, rel_err <= 10^{-n+1})
Sources of error
- rounding (1/3 = 0.333…)
- truncation (approx. math exp cos/sin…)
f(x) = 2x^2 + 27x + 1000
Big O with x→0, x→∞
- |f(x)| <= M*1, f(x) = O(1)
2. |f(x)| <= Mx^2, f(x)=O(x^2)
Taylor approximation x_0
f(x) = ∑i=0→∞ f^(i)(x_0)(x-x_0)^i/i!
Taylor approximation error
h=x-x_0
error = |f(x) - ∑(0→n) f^(i)(x0)h^i/i!| = |∑(n+1→∞) f^(i)(x0)h^i/i!|
Order n → error O(h^{n+1}) – exponent of the dominant term of the remainder (which is the error)
If ξ \in (x0,x), then error <= f^(n+1)(ξ)/(n+1)! (h)^{n+1} = M(h)^{n+1}
Degree of Taylor app?
Terms from 0→n (first n+1) gives approximation of degree n (in range(n+1)…) that is s.t. x^n is in the expression
Find error / order on a graph f(x) = error (loglog)
e = ax^n
log(e) = log(a)+n.log(x)
n=(y2-y1)/(x2-x1) is the slope → error O(x^4)
Approximation order n-1!
Factorial python
from math import factorial
Calculate python (sin(√x))^(2)(0)
import sympy as sp sp.init_printing() sp.var("x") expr = sp.sin(sp.sqrt(x)) expr.diff(x,2).subs(x,0).evalf()
Generate 1000 points between -1 and 1
np.linspace(-1, 1, 1000)