THE UNIVERSITY OF WESTERN ONTARIO LONDON ONTARIO Paul Klein Office: SSC 4028 Phone: 661-2111 ext. 85227 Email: [email protected] URL: www.ssc.uwo.ca/economics/faculty/klein/ Finite element function approximation In these notes we consider function approximation where the basis functions do not have full support (are zero on most of the domain). 1 Piecewise linear interpolation Let the grid be given by fx1; x2; : : : ; xng. Then we define the following ”tent” functions. 8 x − xi−1 > if x 2 [xi−1; xi] > xi − xi−1 < xi+1 − x i(x) = if x 2 [xi; xi+1] (1) > xi+1 − xi > :> 0 elsewhere: These functions are illustrated in Figure1 with a grid given by f0; 1=4; 2=3; 1g. Notice that the points needn’t be evenly spaced. One may verify that if n ^ X f(x) = f(xi) i(x) i=1 1 1 φ φ φ φ 0.9 1 2 3 4 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Figure 1: Basis functions for piecewise linear interpolation. 2 ^ then f(x) = f(x) for each x 2 fx1; x2; : : : ; xng. In the notation of the handout on multi-dimensional interpolation, Ψ = I. In several dimensions, life is a little bit more complicated. Then the usual approach is to let f^ be piecewise multilinear, i.e. on each element (rectangle), f^ is linear in each of the dimensions separately, keeping the others constant.1 We will define a piecewise bilinear approximation for the two-dimensional case. For arbitrarily many dimensions, see the handout on multi-dimensional interpolation. Let f be a function of two variables x1 and x2, and let the grids be given by 1 1 1 2 2 2 j x1; x2; : : : ; xn1 and x1; x2; : : : ; xn2 . Write i for the ith tent function associ- ated with the jth grid. Then n1 n2 ^ 1 2 X X 1 2 1 1 2 2 f(x ; x ) = f(xi ; xj ) i (x ) j (x ): i=1 j=1 1 1 2 2 Notice that this is not a linear function on a rectangle [xi ; xi+1] × [xj ; xj+1] but that it is bilinear on such a rectangle. A smart way of calculating the relevant sum is based on the fact that, in any given dimension, only two of the basis functions are non-zero, and these are consecutive; call them k and k+1. To find k given x you use a locating algo- rithm that essentially proceeds by bisection. 1It is possible, and for some purposes preferable, to define elementwise linear functions on multi-dimensional domains. But we won’t do that here. 3 2 Cubic splines Piecewise linear interpolation is nice, but it yields an interpolating function that is not differentiable at the grid points. An interpolation technique that does yield differentiable approximating functions, and has other nice proper- ties as well, is the cubic spline. Like linear interpolation, cubic spline interpolation begins with a grid of x- values fx1; x2; : : : ; xng and the value of the approximating function fb at those points: fy1; y2; : : : ; yng. A cubic spline specifies fb to be a separate cubic function on each segment [xi; xi+1). Each cubic function has four parameters. This means that there are 4(n − 1) parameters to determine. To do this, we impose the following conditions: 1. fb(xi) = yi; i = 1; 2; : : : ; n (n conditions) 2. Continuity of fb at x2; x3; : : : ; xn−1 (n − 2 conditions) 0 3. Continuity of fb at x2; x3; : : : ; xn−1 (n − 2 conditions) 00 4. Continuity of fb at x2; x3; : : : ; xn−1 (n − 2 conditions) 00 00 5. fb (x1) = fb (xn−1) = 0 (2 conditions). The final two conditions can of course easily be modified to something else depending on what is suitable in the particular case at hand. In principle, one could impose all of these conditions at once, and the result 4 would be a large linear system. However, this problem is best approached in 00 two steps. First, we impose fb(xi) = yi, continuity of fb and continuity of fb at the gridpoints. It turns out that these requirements force us to write the cubic on each interval [xi; xi+1) as xi+1 − x x − xi fb(x) = · yi + · yi+1+ xi+1 − xi xi+1 − xi ( " 3 # " 3 #) 1 2 xi+1 − x xi+1 − x x − xi x − xi + (xi+1−xi) ai − + ai+1 − 6 xi+1 − xi xi+1 − xi xi+1 − xi xi+1 − xi where ai; i = 1; 2; : : : ; n remain to be determined. With this specification, it 00 turns out that fb (xi) = ai. We now proceed to determine these second deriva- 0 00 00 tives. We do it by imposing continuity of fb and fb (x1) = fb (xn−1) = 0. Conti- nuity of fb0 at the gridpoints boils down to yi+1 − yi 1 1 + (xi+1 − xi)ai + (xi+1 − xi)ai+1 = xi+1 − xi 6 3 yi+2 − yi+1 1 1 = − (xi+2 − xi+1)ai+1 − (xi+2 − xi+1)ai+2 xi+2 − xi+1 3 6 for i = 1; 2; : : : ; n − 2. These equations, together with a1 = an = 0 (this choice for the endpoints is called a “natural” spline), together constitute a tridiagonal linear system of equations. Specifically, we have Ma = b where 2 3 0 6 7 6 q2 q1 7 6 − 7 6 h2 h1 7 6 q q 7 6 3 − 2 7 6 7 b = 6 h3 h2 7 6 . 7 6 . 7 6 7 6 qn−1 qn−2 7 6 − 7 6 hn−1 hn−2 7 4 5 0 5 and 2 3 1 0 0 0 0 ··· 0 6 7 6 7 6 h1 2(h1 + h2) h2 0 0 ··· 0 7 6 7 6 7 1 6 0 h2 2(h2 + h3) h3 0 ··· 0 7 M = 6 7 6 6 . .. .. .. .. 7 6 . 7 6 7 6 7 6 0 0 0 0 hn−2 2(hn−2 + hn−1) hn−1 7 4 5 0 0 0 0 0 0 1 where qi = yi+1 − yi and hi = xi+1 − xi. Setting a1 = an = 0 is of course a bit arbitrary. Another, equally arbitrary choice would be a1 = a2 and that an = an−1. 2.1 Not-a-knot cubic splines n So far we have worked with nodes (or gridpoints) fxigi=1 and until now that concept has had two distinct connotations. One is that we have data (function values) for these points, and the other is that the interpolating function fbis a polynomial on each subinterval [xi; xi+1]. Now we will change the terminology somewhat and distinguish between a node, for which we have a given function value, and a knot, where we switch from using one polynomial to another. Notice that a knot may or may not be a node and a node may or may not be a knot. The not-a-knot approach to cubic splines is an alternative to setting a1 = an = 0 or a1 = a2 and an = an−1. It imposes continuity of the third derivative at the nodes x2 and xn−1. This of course amounts to insisting that these nodes are 6 not really knots in the sense that the first cubic polynomial, i.e. the one valid for the interval [x1; x2), is in fact identical to the second cubic polynomial, i.e. the one valid for the interval [x2; x3), and similarly for the (n − 1)th and nth cubic polynomials. Equating the relevant third derivatives, we have −a + a −a + a 1 2 = 2 3 x2 − x1 x3 − x2 and −a + a −a + a n−2 n−1 = n−1 n xn−1 − xn−2 xn − xn−1 This modification leads to the following modified coefficient matrix of our lin- ear system Ma = b. The modified b is left as an exercise for the reader. 2 3 −h2 h1 + h2 −h1 0 0 ··· 0 6 7 6 7 6 h1 2(h1 + h2) h2 0 0 ··· 0 7 6 7 6 7 1 6 0 h2 2(h2 + h3) h3 0 ··· 0 7 M = 6 7 6 6 . .. .. .. .. 7 6 . 7 6 7 6 7 6 0 0 0 0 hn−2 2(hn−2 + hn−1) hn−1 7 4 5 0 0 0 0 −hn−1 hn−2 + hn−1 −hn−2 3 Shape-preserving splines Sometimes it is important that the interpolating function preserve the “shape” of the true function. More precisely, it should be increasing (decreasing) wher- ever the true function is increasing (decreasing) and convex (concave) wherever the true function is convex (concave). Use Schumaker(1983) with the slope ap- proximation of Butland(1980), a combination suggested by Iqbal(1992), who 7 shows that Butland’s choice of slope approximations implies that Schumaker’s conditions 3.3 for co-monotonicity are satisfied. Here is a cook-book description of Iqbal’s Butland-Schumaker algorithm. What is given is the following: Nodes xi; i = 1; 2;:::;N and function values at these nodes yi; i = 1; 2;:::;N. What we want to compute are knots zj; j = 1; 2;:::;K and coefficients Aj, Bj and Cj; j = 1; 2;:::;K so that the following function defines a shape-preserving quadratic interpolating spline, defined on the interval [x1; xN ]: 2 fb(x) = Aj + Bj(x − xj) + Cj(x − xj) if x 2 [zj; zj+1) Except by fluke, we have that K = 2N − 2 because exactly one extra knot is inserted inside each interval between adjacent nodes.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-