Lecture 5 Flashcards

1
Q

Relative error

A

er = |x-^x|/|x|

Independent of magnitude (≠ to absolute errors)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Significant digits/figures

A

digits carrying meaningful information

  1. 00350 = 3 digits
  2. 14159 = 6 digits
  3. 00035 = 2 digits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Relation relative error / accurate digits

A

rel_er <= 10^{-n+1}, n is the number of accurate significant digits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

You know a tree is 170 ft tall, but your tool has a rel_err=10%. What’s the max measurement to expect?

A

187 ft

^x = x(1 ± err)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

You measure 170 ft tall with a measurement tool rel_err=10%, what’s the actual min height?

A

155 ft

x = ^x / (1 ± err)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

After rounding, a number has 5 digits, what’s an estimate of the upper bound of the relative error?

A

10^-4 (n=5, rel_err <= 10^{-n+1})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Sources of error

A
  • rounding (1/3 = 0.333…)

- truncation (approx. math exp cos/sin…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

f(x) = 2x^2 + 27x + 1000

Big O with x→0, x→∞

A
  1. |f(x)| <= M*1, f(x) = O(1)

2. |f(x)| <= Mx^2, f(x)=O(x^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Taylor approximation x_0

A

f(x) = ∑i=0→∞ f^(i)(x_0)(x-x_0)^i/i!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Taylor approximation error

A

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}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Degree of Taylor app?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Find error / order on a graph f(x) = error (loglog)

A

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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Factorial python

A

from math import factorial

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Calculate python (sin(√x))^(2)(0)

A
import sympy as sp
sp.init_printing()
sp.var("x")
expr = sp.sin(sp.sqrt(x))
expr.diff(x,2).subs(x,0).evalf()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Generate 1000 points between -1 and 1

A

np.linspace(-1, 1, 1000)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The measured distance between Champaign and Chicago is 277.5 miles with a relative error of 2%, and the measured distance between Chicago and Milwaukee is 225.1 miles with a relative error of 6%

The distance between Champaign to Milwaukee can be given by the sumation of both distances. In the worst case, what is the relative error (in percent) of the distance between Champaign to Milwaukee?

A

err_{X+Y} = \frac{|\hat{x}/(1-err_X) + \hat{y}/(1-err_Y) - (\hat{x}+\hat{y})|}{|\hat{x}/(1-err_X) + \hat{y}/(1-err_Y)|} = 3.83%

17
Q

If the error in a computation behaves as O(h^6) depending on a mesh size parameter h, and if the error for h=0.5 is 0.01, what will the error be for h=0.7?

A

e2 = e1.(h2/h1)^6 = 0.0752

18
Q

If the error for h=0.01 is 0.08 and the error for h=0.005 is 0.01, what power of h would you expect for this calculation?

A

n = log(e2/e1)/log(h2/h1)

19
Q

If the algorithm takes 8 seconds with n=1200 and it takes 2 seconds with n=600, what is the order of the time cost?

A
8 = c.1200^a
2 = c.600^a
a = log(8/2)/log(1200/600)
20
Q

def taylor_exp(n, x0)

A

import sympy as sp
from math import factorial
sp.init_printing()
sp.var(“x”)

def taylor_exp(n, x0):
    taylor = 0
    for i in range(n+1):
        taylor += f.diff(x, i).subs(x, x0)/factorial(i) * (x-x0)**i
    return taylor