KEN1540 Numerical Mathematics 2017/2018 Formula Sheet Algebraic Equations Cubic Spline Interpolation
KEN1540 Numerical Mathematics 2017/2018 Formula Sheet Algebraic Equations Cubic Spline Interpolation
Formula Sheet Knots Interpolate (x0 , y0 ), . . . , (xn , yn ) with knots xj . Set hj = xj+1 − xj .
Interpolant s(x) = sj (x) = aj+bj (x−xj )+cj (x−xj )2+dj (x−xj )3 for xj ≤ x < xj+1 .
Coefficients
Algebraic Equations aj = yj , bj =
1 h
(aj+1 − aj ) − j (2cj + cj+1 ), dj =
1
(cj+1 − cj ).
hj 3 3hj
Secant method pn − pn−1 Knot conditions
pn+1 = pn − f (pn ). 3 3
f (pn ) − f (pn−1 ) hj−1 cj−1 + 2(hj−1 + hj )cj + hj cj+1 = (aj+1 − aj ) − (aj − aj−1 ).
hj hj−1
Newton’s method pn+1 = pn − f (pn )/f 0 (pn ).
Derivatives 1 h
s0j (xj ) = bj = (aj+1 − aj ) − j (2cj + cj+1 ); s00j (xj ) = 2cj .
hj 3
Polynomial Interpolation Natural spline s00 (x0 ) = s00 (xn ) = 0, so c0 = cn = 0.
Lagrange form Interpolating polynomial Clamped boundary s0 (x0 ) = w0 , s0 (xn ) = wn , so b0 = w0 ; bn = wn ;
a − a0 an − an−1
2h0 c0 + h0 c1 = 3 1
x−xj
p(x) = n − b0 ; hn−1 cn−1 + 2hn−1 cn = 3 bn − .
P Q
k=0 yk lk (x) where lk (x) = j6=k xk −xj h0 hn−1
Divided differences f [xi ] = f (xi ); recurrence relation Not-a-knot s000 is continuous at x1 and xn−1 , so
f [xi+1 , . . . , xi+k ] − f [xi , . . . , xi+k−1 ] h1 c0 − (h0 + h1 )c1 + h0 c2 = 0; hn−1 cn−2 − (hn−1 + hn−2 )cn−1 + hn−2 cn = 0.
f [xi , . . . , xi+k ] =
xi+k − xi 3
Equally-spaced cj−1 + 4cj + cj+1 = 2 (aj−1 − 2aj + aj+1 );
h
Theorem (Divided differences and derivatives) If f (n) is continous on [a, b] 2c0 + c1 = h32 a1 − a0 − hb0 ; cn−1 + 2cn = h32 hbn − an + an−1 .
and x0 , . . . , xn are distinct points in [a, b], there exists ξ ∈ [a, b] with
f [x0 , . . . , xn ] = f (n) (ξ)/n! Differentiation
Nested form Let ak = f [x0 , . . . , xk ]. Then
Two-point forward difference f 0 (x) = (f (x + h) − f (x))/h − f 00 (ξ)h/2.
p(x) = a0 + (x − x0 ) a1 + (x − x1 ) a2 + · · · + (x − xn−2 ) an−1 + (x − xn−1 )an
Three-point centred difference f 0 (x) = (f (x + h) − f (x − h))/2h − f 000 (ξ)h2 /6.
Chebyshev nodes xk = a+b − b−a 2k+1
cos 2(n+1) π for k = 0, . . . , n.
2 2 Three-point forward difference
Theorem (Error of polynomial interpolation) If p is the degree-n polynomial f 0 (x) = (−f (x + 2h) + 4f (x + h) − 3f (x))/2h + f 000 (ξ)h2 /3.
of interpolating f at the n + 1 distinct nodes x0 , x1 , . . . , xn in [a, b], and f (n+1) Five-point centred difference
is continuous, then for each x in [a, b], there is a ξ in (a, b) for which f 0 (x) = −f (x + 2h) + 8f (x + h) − 8f (x − h) + f (x − 2h) /12h + f (5) (ξ)h4 /30.
n
1 Y
Second derivative f 00 (x) = f (x + h) − 2f (x) + f (x − h) /h2 − f (4) (ξ) h2 /12.
f (x) − p(x) = f n+1 (ξ) (x − xi )
(n + 1)! i=0
Error I(f ) − S(f, P ) = −(b − a) h4 f (4) (ξ)/180. Linear least squares g(x) = ax + b fitting data (x1 , y1 ), . . . , (xm , ym ) where
2
Error estimate |I(f ) − S(f, P4 )| ≈ |S(f, P2 ) − S(f, P4 )|/15 a = (XY − X · Y )/(X 2 − X ); b = Y − a X.
= f (a) − 4f ( 3a+b
4
) + 6f ( a+b
2
) − 4f ( a+3b
4
) + f (b) (b − a)/180
Nonlinear least squares If g(x) = n
P
where P2 = (a, a+b , b), P4 = (a, 3a+b , a+b , a+3b , b). k=0 ck φk (x) then for j = 0, . . . , n:
2 4 2 4 n m m
Rb X X X
Romburg integration a f (x) dx ≈ Rn,n . Let hm = (b − a)/m. ck φj (xi )φk (xi ) = φj (xi )yi .
Rk,1 = T2k−1 ; Rk,j = Rk,j−1 + (Rk,j−1 − Rk−1,j−1 )/(4j−1 − 1). k=0 i=1 i=1
Pn
P k−1 Continuous least squares If g(x) = k=0 ck φk (x) fits f (x), then for j = 0, . . . , n:
1
f (a) + f (b) ; T2k = 21 T2k−1 + h2k 2i=1 f (a + (2i − 1)h2k ).
T1 = h1 2
Xn Z b Z b
Differential Equations ck
k=0
w(x) φj (x) φk (x) dx =
a
w(x) φj (x) f (x) dx.
a
Euler’s method wi+1 = wi + hf (ti , wi ). Local error O(h2 ); global error O(h).
Least-squares for orthogonal functions
Error wi+1 − y(ti+1 ) = 21 ÿ(τi )h2 for some τi in (ti , ti+1 ) if wi = y(ti ). Rb Z b
Taylor method Local error O(h3 ). w(x) φk (x) f (x) dx
ck = aR b if w(x) φj (x) φk (x) dx = 0 for j 6= k.
wi+1 = wi + hf (ti , wi ) + 12 h2 f,t (ti , wi ) + f,y (ti , wi )f (ti , wi ) .
a
w(x) φk (x)2 dx a
3
Trapezoid (modified Euler) method Local error O(h ). Square error for orthogonal functions
1
wi+1 = wi + 2 h f (ti , wi ) + f (ti+1 , wi + hf (ti , wi )) . Rb Rb Rb
w(x)(f (x)−g(x))2 dx = a w(x)f (x)2 dx− n 2 2
P
k=0 αk ck where αk = a w(x)φk (x) dx.
Midpoint method Local error O(h3 ). a
wi+1 = wi + hf (ti + 12 h, wi + 21 hf (t, wi )). Generating orthogonal polynomials φk (x) = (x − Bk )φk−1 (x) − Ck φk−2 (x)
Rb Rb
Ralston’s 2nd-order method Local error O(h3 ). x w(x) (φk−1 (x))2 dx x w(x) φk−1 (x) φk−2 (x) dx
wi+1 = wi + 14 h f (ti , wi ) + 3f (ti + 32 h, wi + 23 hf (ti , wi )) .
with Bk = Ra b , Ck = a R b .
w(x) (φ (x)) 2 dx w(x) (φk−2 (x))2 dx
k−1
ki,1 = hf (ti , wi ); ki,2 = hf (ti + 23 h, wi + 23 ki,1 ); wi+1 = wi (t) + 41 (ki,1 + 3ki,2 ). a a