MATH 417 Lecture 5

From Notes
Jump to navigation Jump to search

« previous | Tuesday, January 28, 2014 | next »


Best Floating Point Adding Algorithm

  1. sort collection of numbers
  2. arrange in "baskets" of size 2n for n. (e.g. 1/32, 1/16, 1/8, 1/4, 1/2, 1, 2, 4, 8, 16, 32)
  3. starting with smallest basket, remove 2 numbers and insert their sum into the next basket
  4. repeat (3) until only one number remains in the largest basket

Roundoff error will be minimized.


Polynomial Interpolation

Given f(x) for x[0,1], we want to approximate with a simpler function p(x).

Stuff to show:

  1. there exists only one polynomial
  2. find it
  3. find the error

Existence

Theorem. Given f(x)C[0,1] and ϵ>0, there exists a polynomial p(x) of degree N(ϵ) such that |f(x)p(x)|<ϵ for all x[0,1].

Proof. [Omitted in the book, so we will not cover it here]

quod erat demonstrandum

The good news: every function can be approximated by a polynomial. Weierstrass proved the existence of such polynomials, but Bernstein actually found one.

Lagrange Interpolating Polynomial

For n0, given n+1 measurements f(x0),f(x1),,f(xn), where x0<x1<<xn, We want to find Ln such that Ln(xk)=f(xk) for k=0,1,,n, and degLnn.


Theorem 1. There exists a unique p(x)=Ln(x) which satisfies the conditions above:

p(x)=anxn+an1xn1++a1x+a0

Proof. We take our initial conditions p(xi)=f(xi) and construct a matrix equation Ax=b:

[x0nx0n1x01x1nx1n1x11xn1nxn1n1xn11xnnxnn1xn1][anan1a1a0]=[f(x0)f(x1)f(xn1)f(xn)]

There is only one unique solution if and only if detA0.

Basis.

  1. Given one point x0, the determinant is just 10.
  2. Given two points x0,x1, the determinant is (x1x0)0 since points are distinct.
  3. Given three points x0,x1,x2, the determinant is (x2x0)(x2x1)(x1x0)0

Induction. In general, detAn=(1)0i<jn(xixj)0


To find Ln, We construct a polynomial Pn,k that is 0 at all points xi except when i=k, in which case Pn,k(xk)=1.

Pn,k(x)=ikxxixkxi

Therefore Ln=f(x0)Pn,0(x)+f(x1)Pn,1(x)++f(xn)Pn,n(x), or in short

Ln(x)=k=0nf(xk)Pn,k(x)
quod erat demonstrandum


Example

x 0 1 2 3
f(x) 4 1 7 28

L3(x)=4(x1)(x2)(x3)(01)(02)(03)+1(x0)(x2)(x3)(10)(12)(13)+7(x0)(x1)(x3)(20)(21)(23)+28(x0)(x1)(x2)(30)(31)(32).

Error Estimation

Theorem. Let f(x)C(n+1)[a,b] for ax0<x1<<xnb.

f(x)Ln(x)=(xx0)(xx1)(xxn)f(n1)(ξ)(n+1)!

Proof. Let g(t)=f(t)Ln(t)(f(x)Ln(x))(tx0)(tx1)(txn)(xx0)(xx1)(xxn). This function is special because g(x)=0 and g(xk)=0. Hence there are n+2 roots, and it is (n+1)-differentiable. Let's compute that derivative:

g(n+1)(t)=f(n+1)(t)f(x)Ln(x)(xx0)(xx1)(xxn)(n+1)!

We know g(n+1)(t) has a zero at some ξ[a,b]. To solve for it, we set 0=f(n+1)(ξ)f(x)Ln(x)(xx0)(xx1)(xxn)(n+1)!. Therefore our desired equation follows

quod erat demonstrandum