Chapter 10

Function approximation

We have studied methods for computing solutions to algebraic equations in the form of real numbers or finite dimensional vectors of real numbers. In contrast, solutions to di↵erential equations are scalar or vector valued functions, which only in simple special cases are analytical functions that can be expressed by a closed mathematical formula. Instead we use the idea to approximate general functions by linear com- binations of a finite set of simple analytical functions, for example trigono- metric functions, splines or , for which attractive features are and locality. We focus in particular on piecewise polynomi- als defined by the finite set of nodes of a mesh, which exhibit both near orthogonality and local support.

10.1 approximation

The Lebesgue space L2(I) Inner product spaces provide tools for approximation based on orthogonal projections on subspaces. We now introduce an for functions on the interval I =[a, b], the Lebesgue space L2(I), defined as the class of all square integrable functions f : I R, ! b L2(I)= f : f(x) 2 dx < . (10.1) { | | 1} Za The vector space L2(I)isclosedunderthebasicoperationsofpointwise addition and scalar multiplication, by the inequality, (a + b)2 2(a2 + b2), a, b 0, (10.2)  8 which follows from Young’s inequality.

97 98 CHAPTER 10. FUNCTION APPROXIMATION

Theorem 17 (Young’s inequality). For a, b 0 and ✏>0, 1 ✏ ab a2 + b2 (10.3)  2✏ 2 Proof. 0 (a ✏b)2 = a2 + ✏2b2 2ab✏.  The L2-inner product is defined by b (f,g)=(f,g)L2(I) = f(x)g(x) dx, (10.4) Za with the associated L2 norm,

b 1/2 1/2 2 f = f 2 =(f,f) = f(x) dx , (10.5) k k k kL (I) | | ✓Za ◆ for which the Cauchy-Schwarz inequality is satisfied, (f,g) f g . (10.6) | |k kk k Approximation of functions in L2(I) We seek to approximate a function f in a V ,byalinear combination of functions n V ,thatis { j}j=1 ⇢ n f(x) f (x)= ↵ (x), (10.7) ⇡ n j j j=1 X n with ↵j R.Iflinearlyindependent,theset j j=1 spans a finite dimen- sional subspace2 S V , { } ⇢ n S = fn V : fn = ↵jj(x),↵j R , (10.8) { 2 2 } j=1 X with the set n abasisforS.Forexample,inaFourier series the { j}j=1 functions j are , in a power series . The question is now how to determine the coordinates ↵j so that fn(x) is a good approximation of f(x). One approach to the problem is to use the techniques of orthogonal projections previously studied for vectors in n R , an alternative approach is , where ↵j are chosen such that fn(xi)=f(xi), in a set of nodes xi,fori =1,...,n.Ifwecannotevaluate the function f(x)inarbitrarypointsx,butonlyhaveaccesstoasetof sampled data points (x ,f) m ,withm n, we can formulate a least { i i }i=1 squares problem to determine the coordinates ↵j that minimize the error f(x ) f ,inasuitablenorm. i i 10.1. FUNCTION APPROXIMATION 99

L2 projection The L2 projection Pf,ontothesubspaceS V ,definedby(10.8),ofa function f V ,withV = L2(I), is the orthogonal⇢ projection of f on S, that is, 2 (f Pf,s)=0, s S, (10.9) 8 2 which corresponds to,

n ↵ ( , )=(f, ), i =1,...,n. (10.10) j i j i 8 j=1 X

By solving the matrix equation Ax = b,withaij =(i,j), xj = ↵j, and bi =(f,i), we obtain the L2 projection as

n

Pf(x)= ↵jj(x). (10.11) j=1 X

We note that if i(x)haslocal support,thatisi(x) =0onlyfora subinterval of I,thenthematrixA is sparse, and for n an6 orthonormal { i}i=1 basis, A is the identity matrix with ↵j =(f,j).

Interpolation

The interpolant ⇡f S,isdeterminedbytheconditionthat⇡f(xi)=f(xi), for n nodes x n .Thatis,2 { i}i=1 n

f(xi)=⇡f(xi)= ↵jj(xi),i=1,...,n, (10.12) j=1 X which corresponds to the matrix equation Ax = b,withaij = j(xi), xj = ↵j,andbi = f(xi). The matrix A is an identity matrix under the condition that j(xi)=1, for i = j,andzeroelse.Wethenreferto n as a nodal basis,forwhich { i}i=1 ↵j = f(xj), and we can express the interpolant as

n n

⇡f(x)= ↵jj(x)= f(xj)j(x). (10.13) j=1 j=1 X X 100 CHAPTER 10. FUNCTION APPROXIMATION

Regression If we cannot evaluate the function f(x)inarbitrarypoints,butonlyhave m access to a set of data points (xi,fi) i=1,withm n,wecanformulate the least squares problem, { }

n min f f (x ) =min f ↵ (x ) ,i=1,...,m, (10.14) i n i n i j j i fn S k k ↵j k k 2 { }j=1 j=1 X which corresponds to minimization of the residual b Ax,witha = (x ), ij j i bi = fi,andxj = ↵j,whichwecansolve,forexample,byformingthenormal equations, AT Ax = AT b. (10.15)

10.2 Piecewise approximation

Polynomial spaces We introduce the vector space q(I), defined by the set of polynomials P q p(x)= c xi,xI, (10.16) i 2 i=0 X of at most order q on an interval I R,withthebasisfunctionsxi and 2 coordinates ci,andthebasicoperationsofpointwiseadditionandscalar multiplication,

(p + r)(x)=p(x)+r(x), (↵p)(x)=↵p(x), (10.17) for p, r q(I)and↵ R.Onebasisfor q(I)isthesetofmonomials xi q ,anotheris2P (x 2c)i q ,whichgivestheP power series, { }i=0 { }i=0 q p(x)= a (x c)i = a + a (x c)+... + a (x c)q, (10.18) i 0 1 q i=0 X for c I, with a being an example of a power series, 2

1 2 f(x)=f(y)+f 0(y)(x y)+ f 00(y)(x y) + ... (10.19) 2 10.2. PIECEWISE POLYNOMIAL APPROXIMATION 101

Langrange polynomials For a set of nodes x q , we define the Lagrange polynomials q ,by { i}i=0 { }i=0 (x x0) (x xi 1)(x xi+1) (x xq) x xj i(x)= ··· ··· = , (xi x0) (xi xi 1)(xi xi+1) (xi xq) xi xj i=j ··· ··· Y6 that constitutes a basis for q(I), and we note that P

i(xj)=ij, (10.20) with the Dirac delta function defined as

1,i= j ij = (10.21) 0,i= j ( 6 q so that i=0 is a nodal basis, which we refer to as the Lagrange basis.We can express{ } any p q(I)as 2P q

p(x)= p(xi)i(x), (10.22) i=1 X and by (10.13) we can define the polynomial interpolant ⇡ f q(I), q 2P q ⇡ f(x)= f(x ) (x),xI, (10.23) q i i 2 i=1 X for a continuous function f (I). 2C Piecewise polynomial spaces We now introduce piecewise polynomials defined over a partition of the interval I =[a, b],

a = x

W (q) = v : v q(I ),i=1,...,m+1 , (10.26) h { |Ii 2P i } 102 CHAPTER 10. FUNCTION APPROXIMATION and the continuous piecewise polynomials on I,definedby

V (q) = v W (q) : v (I) . (10.27) h { 2 h 2C } (q) The basis functions for Wh can be defined in terms of the Lagrange basis, for example,

xi x xi x i,0(x)= = (10.28) xi xi 1 hi x xi 1 x xi 1 i,1(x)= = (10.29) xi xi 1 hi (1) defining the basis functions for Wh ,by

0,x=[xi 1,xi], i,j(x)= 6 (10.30) (i,j,x [xi 1,xi], 2 (q) for i =1,...,m+1,andj =0, 1. For Vh we need to construct continuous basis functions, for example,

0,x=[xi 1,xi+1], 6 i(x)= i,1,x[xi 1,xi], (10.31) 8 2 <>i+1,0,x [xi,xi+1], 2 (1) :> for Vh , which we also refer to as hat functions.

φi,1(x) φi(x)

x x x0=a x1 x2 xi-1 xi xi+1 xm xm+1=b x0=a x1 x2 xi-1 xi xi+1 xm xm+1=b

Figure 10.1: Illustration of a mesh h = Ii ,withsubintervalsIj = T { } (1) (xi 1,xi)oflengthhi = xi xi 1, and i,1(x)abasisfunctionforWh (1) (left), and a basis function i(x)forVh (right). 10.2. PIECEWISE POLYNOMIAL APPROXIMATION 103

2 (1) L projection in Vh The L2 projection of a function f L2(I)ontothespaceofcontinuous (1) 2 piecewise linear polynomials Vh ,onasubdivisionoftheintervalI with n nodes, is given by n

Pf(x)= ↵jj(x), (10.32) j=1 X with the coordinates ↵j determined by from the matrix equation Mx = b, (10.33) with mij =(j,i), xj = ↵j,andbi =(f,i). The matrix M is sparse, since mij =0for i j > 1, and for large n we need to use an iterative method to solve (10.33).| | We compute the entries of the matrix M,referredtoas a mass matrix,fromthedefinitionofthebasisfunctions(10.31),starting with the diagonal entries,

1 xi xi+1 2 2 2 mii =(i,i)= i (x) dx = i,1(x) dx + i+1,0(x) dx 0 xi 1 xi Z Z Z xi 2 xi+1 2 (x xi 1) (xi+1 x) = 2 dx + 2 dx xi 1 hi xi hi+1 Z Z 3 xi 3 xi+1 1 (x xi 1) 1 (xi+1 x) hi hi+1 = + = + , h2 3 h2 3 3 3 i xi 1 i+1 xi   and similarly we compute the o↵-diagonal entries,

1 xi+1 mii+1 =(i,i+1)= i(x)i+1(x) dx = i+1,0(x)i+1,1(x) dx Z0 Zxi xi+1 (x x) (x x ) = i+1 i dx h h Zxi i+1 i+1 1 xi+1 = (x x x x x2 + xx ) dx h2 i+1 i+1 i i i+1 Zxi 1 x x2 x3 x2x xi+1 = i+1 x x x + i h2 2 i+1 i 3 2 i+1  xi 1 3 2 2 3 = 2 (xi+1 3xi+1xi +3xi+1xi xi ) 6hi+1

1 3 hi+1 = 2 (xi+1 xi) = , 6hi+1 6 and 1 hi mii 1 =(i,i 1)= i(x)i 1(x) dx = ... = . 6 Z0 104 CHAPTER 10. FUNCTION APPROXIMATION

10.3 Exercises

Problem 34. Prove that the sum of two functions f,g L2(I) is a function in L2(I). 2

Problem 35. Prove that (10.10) follows from (10.9).

Problem 36. Prove that the L2 projection Pf of a function f L2(I), onto the subspace S L2(I), is the best approximation in S, in the2 sense that ⇢ f Pf f s , s S. (10.34) k kk k 8 2 Chapter 11

Boundary value problems in R

The boundary value problem in one variable is an ordinary di↵erential equa- tion, for which an initial condition is not enough, instead we need to specify boundary conditions at each end of the interval. Contrary to the initial value problem, the dependent variable does not represent time, but should rather we thought of as a spatial coordinate.

11.1 The boundary value problem

The boundary value problem We consider the following boundary value problem,forwhichweseeka function u(x) 2(0, 1), such that 2C

u00(x)=f(x),x(0, 1), (11.1) 2 u(0) = u(1) = 0, (11.2) given a source term f(x), and boundary conditions at the endpoints of the interval I =[0, 1]. We want to find an approximate solution to the boundary value problem in the form of a continuous piecewise polynomial that satisfies the boundary conditions (11.2), that is we seek

U V = v V (q) : v(0) = v(1) = 0 , (11.3) 2 h { 2 h } such that the error e = u U is small in some suitable norm . k·k The residual of the equation is defined as

R(w)=w00 + f, (11.4)

105 106 CHAPTER 11. BOUNDARY VALUE PROBLEMS IN R with R(u)=0,foru = u(x)thesolutionoftheboundaryvalueproblem. Our strategy is now to find an approximate solution U Vh,suchthat R(U)issmall. 2 We have two natural methods to find a solution U Vh with a minimal residual: (i) the least squares method,whereweseekthesolutionwiththe2 minimal residual measured in the L2-norm,

min R(U) , (11.5) U V 2 h k k and (ii) Galerkin’s method, where we seek the solution for which the residual is orthogonal the subspace Vh,

(R(U),v)=0, v V . (11.6) 8 2 h With an approximation space consisting of piecewise polynomials, we refer to the methods as a least squares finite element method,andaGalerkin finite element method. With a trigonometric approximation space we refer to Galerkin’s method as a spectral method.

Galerkin finite element method The finite element method (FEM) based on (11.6) takes the form: find U V , such that 2 h 1 1 U 00(x)v(x) dx = f(x)v(x) dx, (11.7) Z0 Z0 for all test functions v V .For(11.8)tobewelldefined,weneedtobe 2 h able to represent the second order derivative U 00,whichisnotobviousfor low order polynomials, such as linear polynomials, or piecewise constants. To reduce this constraint, we can use partial integration to move one derivative from the approximation U to the test function v,sothat

1 1 1 1 U 00(x)v(x) dx = U 0(x)v0(x) dx [U 0(x)v(x)] = U 0(x)v0(x) dx, 0 Z0 Z0 Z0 since v Vh,andthussatisfiestheboundaryconditions. The2 Galerkin finite element method now reads: find U V ,suchthat, 2 h 1 1 U 0(x)v0(x) dx = f(x)v(x) dx, (11.8) Z0 Z0 for all v V . 2 h 11.1. THE BOUNDARY VALUE PROBLEM 107

The discrete problem

We now let Vh be the space of continuous piecewise linear functions, that satisfies the boundary conditions (11.2), that is, U V = v V (1) : v(0) = v(1) = 0 , (11.9) 2 h { 2 h } so that we can write any function v V as 2 h n

v(x)= vii(x), (11.10) i=1 X n over a mesh h with n internal nodes xi,andvi = v(xi)since i i=1 is a nodal basis. T { } We thus search for an approximate solution n

U(x)= Ujj(x), (11.11) j=1 X with Uj = U(xj). If we insert (11.10) and (11.11) into (11.8), we get n 1 1

Uj j0 (x)i0 (x) dx = f(x)i(x) dx, i =1,...,n, (11.12) j=1 0 0 X Z Z which corresponds to the matrix equation Sx = b, (11.13) with sij =(j0 ,i0 ), xj = Uj,andbi =(f,i). The matrix S is sparse, since sij =0for i j > 1, and for large n we need to use an iterative method to solve (11.13).| | We compute the entries of the matrix S,referredtoasasti↵ness matrix, from the definition of the basis functions (10.31), starting with the diagonal entries,

1 xi xi+1 2 2 2 sii =(i0 ,i0 )= (i0 ) (x) dx = (i,0 1) (x) dx + (i0+1,0) (x) dx 0 xi 1 xi Z Z Z xi 1 2 xi+1 1 2 1 1 = dx + dx = + , xi 1 hi xi hi+1 hi hi+1 Z ✓ ◆ Z ✓ ◆ and similarly we compute the o↵-diagonal entries, 1 xi+1 1 1 1 s =(0 ,0 )= 0 (x)0 (x) dx = dx = , ii+1 i i+1 i i+1 h h h Z0 Zxi i+1 i+1 i+1 and 1 1 sii 1 =(i0 ,i0 1)= i0 (x)i0 1(x) dx = ... = . h Z0 i 108 CHAPTER 11. BOUNDARY VALUE PROBLEMS IN R

The variational problem Galerkin’s method is based on the variational formulation,orweak form,of the boundary value problem, where we search for solution in a vector space V ,forwhichthevariationalformiswelldefined:findu V ,suchthat 2 1 1 u0(x)v0(x) dx = f(x)v(x) dx, (11.14) Z0 Z0 for all v V . To construct2 an appropriate vector space V for (11.14) to be well defined, we need to extend L2 spaces to include also derivatives, which we refer to as Sobolev spaces. We introduce the vector space H1(0, 1), defined by,

1 2 2 H (0, 1) = v L (0, 1) : v0 L (0, 1) , (11.15) { 2 2 } and the vector space that also satisfies the boundary conditions (11.2),

H1(0, 1) = v H1(0, 1) : v(0) = v(1) = 0 . (11.16) 0 { 2 } 1 The variational form (11.14) is now well defined for V = H0 (0, 1), since

1 u0(x)v0(x) dx u0 v0 < (11.17) k kk k 1 Z0 by Cauchy-Schwarz inequality, and

1 f(x)v(x) dx f v < , (11.18) k kk k 1 Z0 for f L2(0, 1). 2 Optimality of Galerkin’s method Galerkin’s method (11.8) corresponds to searching for an approximate so- lution in a finite dimensional subspace Vh V ,forwhich(11.1)issatisfied for all test functions v V . ⇢ 2 h The Galerkin solution U is the best possible approximation in Vh,inthe sense that, u U u v , v V , (11.19) k kE k kE 8 2 h with the energy norm defined by

1 1/2 2 w = w0(x) dx . (11.20) k kE | | ✓Z0 ◆ 11.2. EXERCISES 109

Thus U Vh represents a projection of u V onto Vh,withrespectto the inner product2 defined on V , 2

1 (v, w)E = v0(x)w0(x) dx, (11.21) Z0 2 with w E =(w, w)E. Byk subtractingk (11.8) from (11.14), we expose the Galerkin orthogonality property, (u U, v) =0, v V , (11.22) E 8 2 h which we can use to express the optimality of the approximation U.

Theorem 18. The Galerkin solution U Vh is the optimal approximation of u with respect to the energy norm, that2 is

u U u v , v V . (11.23) k kE k kE 8 2 h Proof. For any v V , 2 h u U 2 =(u U, u u ) =(u U, u v) +(u U, v u ) k kE h E E h E =(u U, u v) u U u v . E k kEk kE

11.2 Exercises

Problem 37. Derive the variational formulation and the finite element method for the boundary value problem

(a(x)u0(x))0 + c(x)u(x)=f(x),x(0, 1), (11.24) 2 u(0) = u(1) = 0, (11.25) with a(x) > 0, and c(x) 0.

Chapter 12

Boundary value problems in Rn

12.1 Di↵erential operators in Rn The gradient and Jacobian We recall the definition of the gradient of a scalar function f : Rn R,as ! @f @f T @f grad f = f = ,..., = , (12.1) r @x @x @x ✓ 1 n ◆ i in vector notation and index notation, respectively, which we can interpret as the di↵erential operator

@ @ T @ = ,..., = , (12.2) r @x @x @x ✓ 1 n ◆ i acting on the function f.Thedirectional derivative f,inthedirection rv of the vector v : Rn Rn,isdefinedas ! @f vf =(v )f = vj . (12.3) r ·r @xj

For a vector valued function F : Rn Rm, we define the Jacobian J, ! @F1 @F1 T @x1 @xn ( F1) . ···. . r . @Fi J = F 0 = F = . .. . = . = , (12.4) r 2 3 2 3 @x @Fm @Fm T j ( Fm) 6 @x1 ··· @xn 7 6 r 7 4 5 4 5 with @Fi vF =(v )F = Jv = vj . (12.5) r ·r @xj

111 112 CHAPTER 12. BOUNDARY VALUE PROBLEMS IN Rn

Divergence and rotation For F : Rn Rn we define the divergence, ! @F @F @F div F = F = 1 + ... + n = i , (12.6) r· @x1 @xn @xi and, for n =3,therotation,

rot F =curlF = F, (12.7) r⇥ where e e e 1 2 3 @F @F @F @F @F @F F =det @ @ @ =( 3 2 , 1 3 , 2 1 ), @x1 @x2 @x3 r⇥ 2 3 @x2 @x3 @x3 @x1 @x1 @x2 F1 F2 F3 4 5 3 with e =(e1,e2,e3)thestandardbasisinR . The divergence can be understood in terms of the Gauss theorem,

Fdx= F nds, (12.8) r· · Z⌦ Z which relates the volume integral over a domain ⌦ R3,withthesurface integral over the boundary with normal n. ⇢ Similarly, the rotation can be interpreted in terms of the Kelvin-Stokes theorem, F ds = F dr, (12.9) r⇥ · · Z⌃ Z@⌃ which relates the surface integral of the rotation over a surface ⌃to the line integral over its boundary @⌃withpositiveorientationdefinedbydr.

Laplacian and Hessian We express the Laplacian f as,

2 2 2 2 T @ f @ f @ f f = f = f = f = 2 + ... + 2 = 2 , (12.10) r r r r·r @x1 @xn @xi and the Hessian H,

@2f @2f @x1@x1 ··· @x1@xn 2 T . . . @ f H = f 00 = f = . .. . = . (12.11) 2 . . 3 @x @x rr @2f @2f i j 6 @xn@x1 ··· @xn@xn 7 4 5 12.2. FUNCTION SPACES 113

The vector Laplacian is defined as the

F = 2F =(F ,...,F ), (12.12) r 1 n and for m = n =3,wehave

F = ( F ) ( F ). (12.13) r r· r⇥ r⇥

Partial integration in Rn For a scalar function f : Rn R, and a vector valued function F : Rn ! ! Rn,wehavethefollowinggeneralizationofpartialintegrationoveradomain ⌦ Rn,referredtoasGreen’s theorem, ⇢

( f,F) 2 = (f, F ) 2 +(f,F n) 2 , (12.14) r L (⌦) r· L (⌦) · L () with boundary and outward unit normal vector n = n(x)forx , where we use the notation, 2

(v, w) 2 = v wdx, (12.15) L (⌦) · Z⌦ for two vector valued functions v, w,and

(v, w) 2 = v wds, (12.16) L () · Z for the boundary integral. For two scalar valued functions the scalar product in the integrand is replaced by the usual multiplication. With F = g,for r g : Rn R a scalar function, Green’s theorem gives, !

( f, g) 2 = (f,g) 2 +(f, g n) 2 . (12.17) r r L (⌦) L (⌦) r · L () 12.2 Function spaces

The Lebesgue spaces Lp(⌦) Let ⌦be a domain in Rn and let p be a positive real number, then we define the Lebesgue space Lp(⌦) by

Lp(⌦) = f : f < , (12.18) { k kp 1} with the Lp(⌦) norm,

1/p f = f(x) p dx , (12.19) k kp | | ✓Z⌦ ◆ 114 CHAPTER 12. BOUNDARY VALUE PROBLEMS IN Rn where in the case of a vector valued function f : Rn Rn, ! f(x) p = f (x) p + ... + f (x) p, (12.20) | | | 1 | | n | n n n or a matrix valued function f : R R ⇥ , ! n f(x) p = f (x) p. (12.21) | | | ij | i,j=1 X Lp(⌦) is a vector space, since (i) ↵f Lp(⌦) for any ↵ R,and(ii) f + g Lp(⌦) for f,g Lp(⌦), by the inequality,2 2 2 2 p p 1 p p (a + b) 2 (a + b ), a, b 0, 1 p< , (12.22)   1 which follows from the convexity of the function t tp. Lp(⌦) is a , and L2(⌦) is a Hilbert7! space with the inner product (12.15) which induces the L2(⌦)-norm. In the following we let it be implicitly understood that ( , )=(, ) 2 and = 2 . · · · · L ⌦ k·k k·kL (⌦) Sobolev spaces To construct appropriate vector spaces for variational formulations of par- tial di↵erential equations, we need to extend the spaces L2(⌦) to include also derivatives. The Sobolev space H1(⌦) is defined by, H1(⌦) = v L2(⌦): v L2(⌦) , (12.23) { 2 r 2 } and we define H1(⌦) = v H1(⌦): v(x)=0, x , (12.24) 0 { 2 8 2 } to be the space of functions in H1(⌦) that are zero on the boundary .

12.3 FEM for Poisson’s equation

The Poisson equation We now consider the Poisson equation for an unknown function u : Rn R, ! u = f, x ⌦, (12.25) 2 with ⌦ Rn,andgivendataf : Rn R.Fortheequationtohavea unique solution⇢ we need to specify boundary! conditions. We may prescribe Dirichlet boundary conditions, u = g ,x, (12.26) D 2 12.3. FEM FOR POISSON’S EQUATION 115

Neumann boundary conditions,

u n = g ,x, (12.27) r · N 2 with n = n(x)theoutwardunitnormalonN ,oralinearcombinationof the two, which we refer to as a Robin boundary condition.

Homogeneous Dirichlet boundary conditions We now state the variational formulation of Poisson equation with homo- geneous Dirichlet boundary conditions,

u = f, x ⌦, (12.28) 2 u =0,x, (12.29) 2 1 which we obtain by multiplication with a test function v V = H0 (⌦) and integration over ⌦. Using Green’s theorem, we obtain2 the variational formulation: find u V ,suchthat 2 ( u, v)=(f,v), (12.30) r r for all v V ,sincetheboundarytermvanishesasthetestfunctionisan 2 1 element of the vector space H0 (⌦).

Homogeneous Neumann boundary conditions We now state the variational formulation of Poisson equation with homo- geneous Neumann boundary conditions,

u = f, x ⌦, (12.31) 2 u n =0,x, (12.32) r · 2 which we obtain by multiplication with a test function v V = H1(⌦) and integration over ⌦. Using Green’s theorem, we get the2 variational formulation: find u V ,suchthat, 2 ( u, v)=(f,v), (12.33) r r for all v V , since the boundary term vanishes by the Neumann boundary condition.2 Thus the variational forms (12.30) and (12.33) are similar, with the only di↵erence being the choice of test and trial spaces. However, it turns out that the variational problem (12.33) has no unique solution, since for any solution u V ,alsov + C is a solution, with C R 2 2 116 CHAPTER 12. BOUNDARY VALUE PROBLEMS IN Rn aconstant.Toensureauniquesolution,weneedanextraconditionfor the solution which determines the arbitrary constant, for example, we may change the approximation space to

V = v H1(⌦): v(x) dx =0 . (12.34) { 2 } Z⌦ Non homogeneous boundary conditions Poisson equation with non homogeneous boundary conditions takes the form,

u = f, x ⌦, (12.35) 2 u(x)=g ,x , (12.36) D 2 D u n = g ,x , (12.37) r · N 2 N with =D N .Weobtainthevariationalformulationbybymultipli- cation with a[ test function v V ,with 2 0 V = v H1(⌦): v(x)=w(x),x , (12.38) w { 2 2 D} and integration over ⌦. Using Green’s theorem, we get the variational formulation: find u V , such that, 2 gD

( u, v)=(f,v)+(g ,v) 2 . (12.39) r r N L (N ) for all v V0. The Dirichlet2 boundary condition is enforced through the trial space, and is referred to as an essential boundary condition, whereas the Neumann boundary condition is enforced through the variational form, referred to as a natural boundary condition.

Galerkin finite element method To compute approximate solutions to the Poisson equation, we can formu- late a Galerkin method based on the variational formulation of the equa- tion, replacing the Sobolev space V with a finite dimensional space Vh, M constructed by a set of basis functions i i=1,overamesh h,definedas N { } M T acollectionofelements Ki i=1 and nodes Ni i=1. For the Poisson equation{ } with homogeneous{ } Dirichlet boundary condi- tions, the Galerkin element method takes the form: Find U Vh,such that, 2 ( U, v)=(f,v),vV , (12.40) r r 2 h 12.4. LINEAR PARTIAL DIFFERENTIAL EQUATIONS 117 with V H1(⌦). h ⇢ 0 The variational form (12.40) corresponds to a linear system of equations Ax = b,withaij =(j,i), xj = U(Nj), and bi =(f,i), with i(x)the basis function associated with the node Ni. For Vh apiecewisepolynomialspace,wereferto(12.40)asaGalerkin finite element method.

12.4 Linear partial di↵erential equations

The abstract problem We can express a general linear partial di↵erential equation as the abstract problem, A(u)=f, x ⌦, (12.41) 2 with boundary conditions,

B(u)=g, x . (12.42) 2 For a Hilbert space V ,wecanderivethevariationalformulation:find u V such that, 2 a(u, v)=L(v),vV, (12.43) 2 with a : V V R a bilinear form,thatisafunctionwhichislinearin ⇥ ! both arguments, and L : V R a linear form,orlinear functional,which ! is a linear function onto the scalar field R. Theorem 19 (Riesz representation theorem). For every linear functional L : V R on the Hilbert space V , with inner product ( , ), there exists a unique! element u V , such that · · 2 L(v)=(u, v), v V. (12.44) 8 2 Existence and uniqueness We can prove the existence of unique solutions to the variational problem (12.43), under certain conditions. Assume the bilinear form a( , )issym- metric, · · a(v, w)=a(w, v), v, w V, (12.45) 8 2 and coercive,orV-elliptic,

a(v, v) c v ,vV, (12.46) 0k kV 2 118 CHAPTER 12. BOUNDARY VALUE PROBLEMS IN Rn

with c0 > 0, and V the norm on V .Asymmetricandellipticbilinear form defines an innerk·k product on V ,whichinducesanormwhichwerefer to as the energy norm, w = a(w, w)1/2. (12.47) k kE But if the bilinear form is an inner product on V ,byRieszrepresentation theorem there exists a unique u V , such that 2 a(u, v)=L(v). (12.48)

If the bilinear form is not symmetric, we still have unique solution to (12.43) by the Lax-Milgram theorem,ifthebilinearformiselliptic(12.46), and continuous, a(u, v) C u v ,C> 0, (12.49)  1k kV k kV 1 with also the linear form continuous,

L(v) C v ,C> 0. (12.50)  2k kV 2 A priori error estimation In a Galerkin method we seek an approximation U V such that 2 h a(U, v)=L(v),vV , (12.51) 2 h with Vh V afinitedimensionalsubspace,whichinthecaseofafinite element method⇢ is a piecewise polynomial space. The Galerkin approximation is optimal in the energy norm, since by Galerkin orthogonality,

a(u U, v)=0,vV , (12.52) 2 h we have that

u U 2 = a(u U, u u )=a(u U, u v)+a(u U, v u ) k kE h h = a(u U, u v) u U u v , k kEk kE so that u U u v ,vV . (12.53) k kE k kE 2 h Specifically, by choosing v = ⇡hu, we obtain the a priori error estimate

e u ⇡ u , (12.54) k kE k h kE where the error e = u U is estimated in terms of an interpolation error. 12.5. EXERCISES 119

Aposteriorierrorestimation In contrast to an a priori error estimate which is expressed in terms of the unknown exact solution u,ana posteriori error estimate is bounded in terms of the approximate solution U. We define a linear functional of the solution u, M(u)=(u, ), (12.55) with the Riesz representer of the functional M( ), guaranteed to exist by Theorem 19. To estimate the error with respect to· M( ), we introduce an adjoint problem: find ' V ,suchthat · 2 a(v, ')=M(v), v V. (12.56) 8 2 The a posteriori error estimate then follows, as

M(u) M(U)=a(u, ') a(U,')=L(') a(U,')=r(U,'), (12.57) with the weak residual

r(U,')=L(') a(U,'). (12.58) With U afiniteelementapproximationcomputedoveramesh h,we can split the integral over the elements K in h,sothat T T M(u) M(U)=r(U,')= r (U,')= , (12.59) K EK K h K h X2T X2T with the error indicator = r (U,'), (12.60) EK K defined for each element K.Toapproximatetheerrorindicatorwecan compute an approximation to the adjoint problem, ',sothat ⇡ r (U, ). (12.61) EK ⇡ K Such local error indicators can be used in an adaptive algorithm to identity which elements K that contribute the most to the global error.

12.5 Exercises

Problem 38. Derive the variational formulation (12.39), and formulate the finite element method.