# Numerical Methods Qualification Exam Problems and Solutions (University of Maryland)/Jan04 667

## Problem 4a

 Consider the boundary value problem ${\displaystyle {\begin{cases}-u''(x)+b(x)u(x)=f(x),0\leq x\leq 1\\u(0)=u_{l},u(1)=u_{r}\end{cases}}\qquad (1)\!\,}$  where ${\displaystyle b(x),f(x)\in C[0,1]\!\,}$ , and ${\displaystyle b(x)\geq 0\!\,}$ . Formulate a difference method for the approximate solution of ${\displaystyle (1)\!\,}$  on a uniform mesh of size ${\displaystyle h\!\,}$ . Explain how ${\displaystyle u''(x)\!\,}$  is approximated by a difference quotient

## Solution 4a

From Taylor expansion of ${\displaystyle u(x+h)\!\,}$  and ${\displaystyle u(x-h)\!\,}$  around ${\displaystyle x\!\,}$ , we have

${\displaystyle u''(x)={\frac {u(x+h)-2u(x)+u(x-h)}{h^{2}}}+{\frac {u''''(\xi )}{12}}h^{2}\!\,}$

Let ${\displaystyle P=\{x_{i}\}_{i=0}^{N+1}\!\,}$  be a uniform partition of ${\displaystyle [0,1]\!\,}$  with step size ${\displaystyle h\!\,}$

Then for ${\displaystyle i=2,\ldots ,N-1\!\,}$  we have

${\displaystyle {\begin{bmatrix}-{\frac {1}{h^{2}}}&&&{\frac {2}{h^{2}}}+b(x_{i})&&&-{\frac {1}{h^{2}}}\end{bmatrix}}{\begin{bmatrix}u_{i-1}\\u_{i}\\u_{i+1}\end{bmatrix}}=f(x_{i})\!\,}$

For ${\displaystyle i=1:\!\,}$

${\displaystyle {\begin{bmatrix}{\frac {2}{h^{2}}}+b(x_{1})&&&-{\frac {1}{h^{2}}}\end{bmatrix}}{\begin{bmatrix}u_{1}\\u_{2}\end{bmatrix}}=f(x_{1})+{\frac {u_{l}}{h^{2}}}\!\,}$

For ${\displaystyle i=N:\!\,}$

${\displaystyle {\begin{bmatrix}-{\frac {1}{h^{2}}}&&&{\frac {2}{h^{2}}}+b(x_{N})\end{bmatrix}}{\begin{bmatrix}u_{N-1}\\u_{N}\end{bmatrix}}=f(x_{N})+{\frac {u_{r}}{h^{2}}}\!\,}$

## Problem 4b

 Suppose ${\displaystyle b(x)=0\!\,}$  and ${\displaystyle u_{l}=u_{r}=0\!\,}$  in ${\displaystyle (1)\!\,}$ . Formulate a finite element method for the approximate solution of ${\displaystyle (1)\!\,}$  in this special case, again on a uniform mesh. Using the standard "hat functions" basis for the finite element space, write out the finite element equations explicitly. Show that if an appropriate quadrature formula is used on the right-hand side of the finiite element equations, they (the finite element equations) are the same as the finite difference equations.

## Solution 4b

${\displaystyle {\begin{bmatrix}{\frac {2}{h}}&-{\frac {1}{h}}&&&\\-{\frac {1}{h}}&{\frac {2}{h}}&-{\frac {1}{h}}&&\\&\ddots &\ddots &\ddots &\\&&&-{\frac {1}{h}}&{\frac {2}{h}}\end{bmatrix}}{\begin{bmatrix}u_{1}\\\vdots \\\vdots \\u_{N}\end{bmatrix}}={\begin{bmatrix}\int _{0}^{1}f\phi _{i}\\\vdots \\\\\int _{0}^{1}f\phi _{N}\end{bmatrix}}\!\,}$

Since we are integrating hat functions on the right hand side, an appropriate quadrature formula would be to take half of the midpoint rule. The regular midpoint rule would give double the actual integral value of a hat function.

Therefore ${\displaystyle \int _{0}^{1}f(x)\phi _{i}(x)\approx hf(x_{i})\!\,}$

Then the finite difference method and the finite element method yield the same matrix.

## Problem 4c

 Show that the matrix in ${\displaystyle (b)\!\,}$  is non singluar.

## Solution 4c

Since the matrix is diagonally dominant, it is non-singular.

To show that the matrix has a non-zero determinant, 2n elementary row operation can be used to show that

${\displaystyle {\begin{bmatrix}{\frac {2}{h}}&-{\frac {1}{h}}&&\\-{\frac {1}{h}}&{\frac {2}{h}}&-{\frac {1}{h}}&\\&\ddots &\ddots &\\&&-{\frac {1}{h}}&{\frac {2}{h}}\end{bmatrix}}}$

has the same determinant as

${\displaystyle {\begin{bmatrix}-{\frac {1}{h}}&{\frac {2}{h}}&-{\frac {1}{h}}&\\&\ddots &\ddots &\ddots &\\&&-{\frac {1}{h}}&{\frac {2}{h}}\\&&&{\frac {n+1}{h}}\\\end{bmatrix}}}$

which is ${\displaystyle {\frac {n+1}{h^{n}}}\neq 0}$ .

## Problem 5

 Consider the following dissipative initial value problem, ${\displaystyle {\begin{cases}y'+f(y)=0,0\leq x\leq 1\\y(0)=y_{0}\end{cases}}\qquad (2)\!\,}$  where ${\displaystyle f:R\rightarrow R\!\,}$  is smooth and satisfies ${\displaystyle 0\leq f'(y)\!\,}$

## Problem 5a

 Write the Backward Euler Method for (2). This gives rise to an algebraic equation. Explain how you would solve this equation.

## Solution 5a

Using Taylor Expansion we have

{\displaystyle {\begin{aligned}y(x-h)&=y(x)-y'(x)h+{\frac {y''(\xi )}{2}}h^{2}\\y(x)&=y(x-h)+y'(x)h-{\frac {y''(\xi )}{2}}h^{2}\\y(x_{n})&=y(x_{n-1})+\underbrace {y'(x_{n})} _{-f(y(x_{n}))}h-\underbrace {{\frac {y''(\xi )}{2}}h^{2}} _{O(h^{2})}\qquad (*)\\\end{aligned}}}

Thus we have Backwards Euler Method:

${\displaystyle y_{n}=y_{n-1}-hf(y_{n})\qquad (**)\!\,}$

Let ${\displaystyle e_{n}\equiv y(x_{n-1})-y_{n}\!\,}$

## Problem 5b

 Derive an error estimate of the form ${\displaystyle |y(x_{n})-y_{n}|\leq {\frac {M}{2}}h,n=1,2,\ldots \!\,}$  where ${\displaystyle M=\max _{0\leq x\leq 1}|y''(x)|\!\,}$ . Do this directly, not as an application of a standard theorem. (Note that there is no exponential on the right hand side.

## Solution 5b

Subtracting ${\displaystyle (*)\!\,}$  and ${\displaystyle (**)\!\,}$ , we have

{\displaystyle {\begin{aligned}e_{n}&=e_{n-1}-h[f(y(x_{n}))-f(y_{n})]-{\frac {y''(\xi )}{2}}h^{2}\\&=e_{n-1}-hf'(y(\alpha ))e_{n}-{\frac {y''(\xi )}{2}}h^{2}\quad {\mbox{ (by MVT) }}\\e_{n}^{2}&=e_{n-1}e_{n}-h\underbrace {f'(y\alpha )} _{<0}e_{n}^{2}-{\frac {y''(\xi )}{2}}h^{2}e_{n}\\&\leq e_{n-1}e_{n}-{\frac {y''(\xi )}{2}}h^{2}e_{n}\\e_{n}&\leq e_{n-1}-{\frac {y''(\xi )}{2}}h^{2}\\\|e_{n}\|&\leq \|e_{n-1}\|+{\frac {\|y''\|_{\infty }}{2}}h^{2}\\\|e_{n}\|&\leq n{\frac {\|y''\|_{\infty }}{2}}h^{2}\\&\leq {\frac {M}{2}}h\end{aligned}}\!\,}