Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Finite difference methods

Siltanen/Railo/Kaarnioja

Spring 2018
Applications of matrix computations

Applications of matrix computations Finite difference methods Spring 2018 1 / 25


Introduction

Finite difference methods (FDM) are numerical methods for solving


(partial) differential equations, where (partial) derivatives are
approximated by finite differences.
Example
For 0 < |h|  1, we have the approximations
f (x + h) − f (x)
(i) f 0 (x) ≈ ,
h
f (x) − f (x − h)
(ii) f 0 (x) ≈ ,
h
f (x + h) − f (x − h)
(iii) f 0 (x) ≈ , and
2h
f (x + h) − 2f (x) + f (x − h)
(iv) f 00 (x) ≈ .
h2

Applications of matrix computations Finite difference methods Spring 2018 2 / 25


Let a = x0 < x1 < · · · < xn = b be a uniform partition of the interval
[a, b], where xk = a + hk, k ∈ {0, 1, . . . , n}, and h = (b − a)/n.

The formulae on the previous page can be used to derive discrete


approximations for
(i) [f 0 (x0 ), f 0 (x1 ), . . . , f 0 (xn−1 )]T = Af,
(ii) [f 0 (x1 ), f 0 (x2 ), . . . , f 0 (xn )]T = Bf,
(iii) [f 0 (x1 ), f 0 (x2 ), . . . , f 0 (xn−1 )]T = C f, and
(iv) [f 00 (x1 ), f 00 (x2 ), . . . , f 00 (xn−1 )]T = Df
using the point values f = [f (x0 ), f (x1 ), . . . , f (xn )]T .

Proof. Homework! :)
Note: By using a suitable quadrature rule (e.g., the left-, mid-, or
right-point rule or the trapezoidal rule), one can obtain a discretized
approximation for the antiderivative as well!

Applications of matrix computations Finite difference methods Spring 2018 3 / 25


Finite difference methods for the equation y 0 (t) = f (t, y (t))

Applications of matrix computations Finite difference methods Spring 2018 4 / 25


Let’s consider the IVP
(
y 0 (t) = f (t, y (t)), t ≥ 0,
y (0) = y0 .

To ensure (local) unique solvability, it is assumed that f is continuous and


that f (t, ·) is Lipschitz-continuous [Picard–Lindelöf theorem].

How do we get rid of the derivative? By integration:

Zt
y (t) = y0 + f (τ, y (τ )) dτ.
0

Bad news: We have just turned our differential equation into an integral
equation, which we still need to solve for y (t).
Good news: We know how to do numerical integration!

Applications of matrix computations Finite difference methods Spring 2018 5 / 25


We are interested in solving the IVP for t ∈ [0, T ], T > 0. Let
0 = t0 < t1 < · · · < tn = T be an equispaced partition of the interval
[0, T ], tk = hk, k ∈ {0, 1, . . . , n}, and h = T /n.

Let us denote y (tk ) = yk . We can recast the integral equation on the


previous page as
tk+1
Z
yk+1 = yk + f (t, y (t)) dt for k = 0, 1, . . . , n − 1.
tk

Let’s try different quadratures for approximating the integral above!

Remark. We omit the detailed error analysis of the resulting formulae and
focus on some heuristics of the solution methods.

Applications of matrix computations Finite difference methods Spring 2018 6 / 25


One-point Riemann sum approximations over [tk , tk+1 ]

Left-point rule:

yk+1 ≈ yk + hf (tk , yk ). (Euler’s method)

Right-point rule:

yk+1 ≈ yk + hf (tk+1 , yk+1 ). (Implicit Euler’s method)

Midpoint rule:

yk+1 ≈ yk + hf (tk + h2 , yk + h2 f (tk , yk )). (Runge–Kutta method)

Applications of matrix computations Finite difference methods Spring 2018 7 / 25


Two-point trapezoidal rule over [tk , tk+1 ]

h
yk+1 ≈ yk + (f (tk , yk ) + f (tk+1 , yk+1 ))
2
h h
≈ yk + f (tk , yk ) + f (tk + h, yk + hf (tk , yk )).
2 2

Applications of matrix computations Finite difference methods Spring 2018 8 / 25


Two-point trapezoidal rule over [tk , tk+1 ]

h
yk+1 ≈ yk + (f (tk , yk ) + f (tk+1 , yk+1 ))
2
h h
≈ yk + f (tk , yk ) + f (tk + h, yk + hf (tk , yk )).
2 2

Applications of matrix computations Finite difference methods Spring 2018 8 / 25


Two-point trapezoidal rule over [tk , tk+1 ]

k1 = hf (tk , yk ),
k1 h
yk+1 ≈ yk + + f (tk + h, yk + k1 ).
2 2

Applications of matrix computations Finite difference methods Spring 2018 8 / 25


Two-point trapezoidal rule over [tk , tk+1 ]

k1 = hf (tk , yk ),
k1 h
yk+1 ≈ yk + + f (tk + h, yk + k1 ).
2 2

Applications of matrix computations Finite difference methods Spring 2018 8 / 25


Two-point trapezoidal rule over [tk , tk+1 ]

k1 = hf (tk , yk ), k2 = hf (tk + h, yk + k1 ),
k1 k2
yk+1 ≈ yk + + .
2 2
This is the second order Runge–Kutta method (RK2).

Applications of matrix computations Finite difference methods Spring 2018 8 / 25


There is a similar relationship between the famous fourth order
Runge–Kutta method (RK4) and Simpson’s rule:

k1 = hf (tk , yk ), k2 = hf (tk + h2 , yk + 12 k1 ),
k3 = hf (tk + h2 , yk + 12 k2 ), k4 = hf (tk+1 , yk + k3 ),
1
yk+1 ≈ yk + (k1 + 2k2 + 2k3 + k4 ).
6
The RK4 rule can be derived by first applying Simpson’s rule and then
balancing the “midstep” (here yk+1/2 = y (tk+1/2 ) and tk+1/2 = tk + h/2)

4f (tk+1/2 , yk+1/2 ) = 2f (tk+1/2 , yk+1/2 ) + 2f (tk+1/2 , yk+1/2 )

by using two different methods:

f (tk+1/2 , yk+1/2 ) ≈ f (tk + h2 , yk + 12 k1 ), (left-point rule)


h 1
f (tk+1/2 , yk+1/2 ) ≈ f (tk + 2 , yk + 2 k2 ). (right-point rule)

Applications of matrix computations Finite difference methods Spring 2018 9 / 25


In summary

There exists a wide range of literature on FD methods for first order IVPs
– and the theory extends nicely to first order systems of ODEs as well.
The examples on pg. 7 highlight a couple of canonical cases:
(A) Explicit methods,
(B) Implicit methods.

While simple and intuitive, explicit methods are never unconditionally


stable. For example, when working with [stiff equations], certain implicit
methods are able to capture the asymptotics of the solution regardless of
the step size.

Another class of FD methods is represented by Runge–Kutta methods,


where the FD solution is adjusted based on point evaluations at additional
intermediate points between the discretization mesh.

Applications of matrix computations Finite difference methods Spring 2018 10 / 25


For an introduction into the approximation and stability theory of first
order FD methods, I highly recommend the monograph
[Griffiths and Higham]!

Applications of matrix computations Finite difference methods Spring 2018 11 / 25


Finite difference methods for Poisson’s equation −∆u = f

Applications of matrix computations Finite difference methods Spring 2018 12 / 25


Let
∂2 ∂2
∆u(x, y ) = u(x, y ) + u(x, y )
∂x 2 ∂y 2
denote the Laplacian.

In the following, we discuss the solution of Poisson’s equation

−∆u = f in a bounded domain Ω ⊂ R2

with the Dirichlet boundary condition

u=g on ∂Ω.

where f and g are given functions.

Applications of matrix computations Finite difference methods Spring 2018 13 / 25


We need to discretize Poisson’s equation in order to find a suitable matrix
approximation Au = m, which we can then solve numerically.

We can obtain an approximate formula for ∆u near (x, y ) by developing


Taylor expansions of u(x, y ) with respect to x and y variables,
respectively. Assuming sufficient smoothness, we obtain

u(x + h, y ) = u(x, y ) + h∂x u(x, y ) + 21 h2 ∂x2 u(x, y ) + 16 h3 ∂x3 u(x, y ) + O(h4 ),


u(x − h, y ) = u(x, y ) − h∂x u(x, y ) + 21 h2 ∂x2 u(x, y ) − 16 h3 ∂x3 u(x, y ) + O(h4 ).

The sum of these is

u(x + h, y ) + u(x − h, y ) = 2u(x, y ) + h2 ∂x2 u(x, y ) + O(h4 )

Applications of matrix computations Finite difference methods Spring 2018 14 / 25


Developing the Taylor expansion w.r.t. the x variable yielded

u(x + h, y ) + u(x − h, y ) = 2u(x, y ) + h2 ∂x2 u(x, y ) + O(h4 ). (1)

Proceeding analogously with the other component:

u(x, y + h) = u(x, y ) + h∂y u(x, y ) + 21 h2 ∂y2 u(x, y ) + 16 h3 ∂y3 u(x, y ) + O(h4 ),


u(x, y − h) = u(x, y ) − h∂y u(x, y ) + 21 h2 ∂y2 u(x, y ) − 16 h3 ∂y3 u(x, y ) + O(h4 )
⇒ u(x, y + h) + u(x, y − h) = 2u(x, y ) + h2 ∂y2 u(x, y ) + O(h4 ). (2)

By summing (1) and (2) together, we obtain

u(x + h, y ) + u(x − h, y ) + u(x, y + h) + u(x, y − h) = 4u(x, y ) + h2 ∆u(x, y ) + O(h4 )


u(x + h, y ) + u(x − h, y ) + u(x, y + h) + u(x, y − h) − 4u(x, y )
⇒ ∆u(x, y ) = + O(h2 ).
h2

Applications of matrix computations Finite difference methods Spring 2018 15 / 25


Five-point stencil (quincunx):

u (x,y+h)

u (x-h,y) u (x,y) u (x+h,y)

u (x,y-h)

u(x + h, y ) + u(x − h, y ) + u(x, y + h) + u(x, y − h) − 4u(x, y )


∆u(x, y ) ≈
h2
Applications of matrix computations Finite difference methods Spring 2018 16 / 25
Recovering missing pixels

During the lecture, we discussed the


example presented in
Poisson FD v2.pdf (see course page).

Figure: Image by Samuli Siltanen.

Applications of matrix computations Finite difference methods Spring 2018 17 / 25


For a given (polygonal) computational domain, we could attempt to create
a quincunx mesh where, for each individual mesh element (x, y ), the
neighbouring coordinates (x ± h, y ) and (x, y ± h) are either
Other mesh elements,
Boundary points.
4 4

3 3

2 2

1 1

0 0

-1 -1
-1 0 1 2 3 4 -1 0 1 2 3 4

Applications of matrix computations Finite difference methods Spring 2018 18 / 25


Example
-5 -4 -3
6 -6
Let’s solve the Dirichlet problem
-5 -2 (
∆u = 0 in Ω,
4 -4 -1
u|∂Ω = g on ∂Ω,
0 1 2 3
-3
where the computational domain Ω
2 -2 4 is the L-shaped domain on the left,
-1 5
the discretization mesh is denoted by
black dots, and the boundary values
0 0
1 2 3 4 5
6 of g are given in red at the
discretization nodes lying on the
0 2 4 6 boundary.
unknowns u(xi ) boundary values gi

Applications of matrix computations Finite difference methods Spring 2018 19 / 25


Let’s give a numbering to the unknowns!

-5 -4 -3 -5 -4 -3
6 -6 6 -6

-5 -2 1 2
-5 -2

4 -4 -1 3 4
4 -4 -1
0 1 2 3
-3 5 6 0 1 2 3
-3
2 -2 4 7 8 9 10 11
2 -2 4
-1 5
12 13 14 15 16
-1 5
0 0 6
1 2 3 4 5
0 0 6
1 2 3 4 5
0 2 4 6
unknowns u(xi ) boundary values gi 0 2 4 6

Applications of matrix computations Finite difference methods Spring 2018 20 / 25


-5 -4 -3
6 -6

1 2
-5 -2

3 4
4 -4 -1
u(x2 ) + u(x3 ) − 4u(x1 ) − 5 − 5
-3
5 6 0 1 2 3 ∆u(x1 ) ≈
h2  
7 8 9 10 11
2 -2 4 u(x1 )
1   10
12 13 14 15 16 ∴ 2 −4 1 1 u(x2 ) = 2
-1 5 h h
u(x3 )
0 0 6
1 2 3 4 5

0 2 4 6

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3
6 -6

1 2
-5 -2

3 4 u(x1 ) + u(x4 ) − 4u(x2 ) − 4 − 2


4 -4 -1 ∆u(x2 ) ≈ 2
-3
5 6 0 1 2 3  h 
7 8 9 10 11
  u(x1 )  
2 -2 4 1 −4 1 1 0  u(x2 ) 1 10
∴ 2   =
12 13 14 15 16 h 1 −4 0 1 u(x3 ) h2 6
-1 5
u(x4 )
0 0 6
1 2 3 4 5

0 2 4 6

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3
6 -6 u(x1 )+u(x4 )+u(x5 )−4u(x3 )−4
∆u(x3 ) ≈ h2
1 2
-5 -2
 
 u(x1 )
3 4
4 -4 -1 
−4 1 1 0 0u(x2 )

-3
5 6 0 1 2 3 1 
1 −4 0 1 0 u(x3 )

=
7 8 9 10 11 h2
2 -2 4 1 0 −4 1 1 u(x4 )
12 13 14 15 16 u(x5 )
-1 5  
10
0 0 6
1  
1 2 3 4 5 6
h2
4
0 2 4 6

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 

 
 
 
3 4  
4 -4 -1 



 
 
5 6 0 1 2 3  
-3 



 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, ·, ·, ·, ·, ·, ·, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

 
3 4  
4 -4 -1 



 
 
5 6 0 1 2 3  
-3 



 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, ·, ·, ·, ·, ·, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 



 
 
5 6 0 1 2 3  
-3 



 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, ·, ·, ·, ·, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 
 1 −4 1 1 

 
 
5 6 0 1 2 3  
-3 



 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, 2, ·, ·, ·, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 
 1 −4 1 1 


 1 1 −4 1 1 

5 6 0 1 2 3  
-3 



 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, 2, 0, ·, ·, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 
 1 −4 1 1 


 1 1 −4 1 1 

5 6 0 1 2 3  1 −4 1 1 
-3 



 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, 2, 0, 0, ·, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 
 1 −4 1 1 


 1 1 −4 1 1 

5 6 0 1 2 3  1 −4 1 1 
-3 
 1 −4 1 1


 
 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, 2, 0, 0, −1, ·, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 
 1 −4 1 1 


 1 1 −4 1 1 

5 6 0 1 2 3  1 −4 1 1 
-3 
 1 −4 1 1


 
 1 −4 1 
7 8 9 10 11  
2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, ·, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


-5 -4 -3  −4 1 1 
6 -6  1 −4 1 
 1 −4 1 1 
1 2
 
-5 -2

 1 1 −4 1 


 1 −4 1 1 

3 4

 1 1 −4 1 

4 -4 -1 
 1 −4 1 1 


 1 1 −4 1 1 

5 6 0 1 2 3  1 −4 1 1 
-3 
 1 −4 1 1


 
 1 −4 1 
7 8 9 10 11 
1 −4 1

2 -2 4
 
 
 
 
12 13 14 15 16  
-1 5
 

0 0 6 =: A
1 2 3 4 5
m := [10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, 0, ·, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


 −4 1 1 
-5 -4 -3  1 −4 1
6 -6

 1
 −4 1 1 

 1 1 −4 1 
1 2
 
-5 -2

 1 −4 1 1 


 1 1 −4 1 

3 4

 1 −4 1 1 

4 -4 -1 
 1 1 −4 1 1 

 1 −4 1 1 
0 1 2 3
 
5 6  1 −4 1 1 
-3 
 1 −4

1
 
 1 −4 1 
7 8 9 10 11 
1 1 −4 1

2 -2 4 



 
 
12 13 14 15 16
-1 5
=: A
0 0 6
1 2 3 4 5 m :=
[10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, 0, −2, ·, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


 −4 1 1 
-5 -4 -3  1 −4 1
6 -6

 1
 −4 1 1 

 1 1 −4 1 
1 2
 
-5 -2

 1 −4 1 1 


 1 1 −4 1 

3 4

 1 −4 1 1 

4 -4 -1 
 1 1 −4 1 1 

 1 −4 1 1 
0 1 2 3
 
5 6  1 −4 1 1 
-3 
 1 −4

1
 
 1 −4 1 
7 8 9 10 11 
1 1 −4 1

2 -2 4  
1 −4 1 
 
 1
 
12 13 14 15 16
-1 5
=: A
0 0 6
1 2 3 4 5 m :=
[10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, 0, −2, −3, ·, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


 −4 1 1 
-5 -4 -3  1 −4 1
6 -6

 1
 −4 1 1 

 1 1 −4 1 
1 2
 
-5 -2

 1 −4 1 1 


 1 1 −4 1 

3 4

 1 −4 1 1 

4 -4 -1 
 1 1 −4 1 1 

 1 −4 1 1 
0 1 2 3
 
5 6  1 −4 1 1 
-3 
 1 −4 1

 
 1 −4 1 
7 8 9 10 11 
1 1 −4 1

2 -2 4  
1 −4 1
 
 1 
1 1 −4 1
 
12 13 14 15 16
-1 5
=: A
0 0 6
1 2 3 4 5 m :=
[10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, 0, −2, −3, −4, ·]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


 −4 1 1 
-5 -4 -3  1 −4 1
6 -6 
 1
 −4 1 1 

 1 1 −4 1 
1 2 
1 −4 1 1

-5 -2
 
 

 1 1 −4 1 

3 4  1 −4 1 1 
4 -4 -1
 

 1 1 −4 1 1 

 1 −4 1 1 
5 6 0 1 2 3 
1 −4 1 1

-3
 
 

 1 −4 1 

 1 −4 1 
7 8 9 10 11 
1 1 −4 1

2 -2 4  
1 −4 1
 
 1 
1 1 −4 1
 
12 13 14 15 16
-1 5 1 1 −4
=: A
0 0 6
1 2 3 4 5 m :=
[10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, 0, −2, −3, −4, −10]T
0 2 4 6

 
u(x1 )
1  .  1
2
A  ..  = 2 m
h h
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


 −4 1 1 
-5 -4 -3  1 −4 1
6 -6 
 1
 −4 1 1 

 1 1 −4 1 
1 2 
1 −4 1 1

-5 -2
 
 

 1 1 −4 1 

3 4  1 −4 1 1 
4 -4 -1
 

 1 1 −4 1 1 

 1 −4 1 1 
5 6 0 1 2 3 
1 −4 1 1

-3
 
 

 1 −4 1 

 1 −4 1 
7 8 9 10 11 
1 1 −4 1

2 -2 4  
1 −4 1
 
 1 
1 1 −4 1
 
12 13 14 15 16
-1 5 1 1 −4
=A
0 0 6
1 2 3 4 5 m=
[10, 6, 4, 1, 3, 0, 2, 0, 0, −1, −6, 0, −2, −3, −4, −10]T
0 2 4 6

 
u(x1 )
1  .  1
 A  ..  = m
h2 h2
u(x16 )

Applications of matrix computations Finite difference methods Spring 2018 21 / 25


Numerical solution:

>> A\m

should give

[u(x1 ), . . . , u(x16 )]T = [−4, −3, −3, −2, −2, −1, −1, 0, 1, 2, 3, 0, 1, 2, 3, 4]T .

Compare this with the analytical solution u(x, y ) = x − y . (They are


exactly the same!)

Applications of matrix computations Finite difference methods Spring 2018 22 / 25


Numerical experiment
Let’s return to the isospectral drums discussed earlier during the course.
4 4

3 3

2 2

1 1

0 0

-1 -1
-1 0 1 2 3 4 -1 0 1 2 3 4

Figure: Isospectral drum shapes in 2D [Gordon, Webb, and Wolpert].

Two drums with clamped boundaries give the same sound if they have the
same set of (Dirichlet) eigenvalues λ satisfying
−∆u = λu in D, u|∂D = 0, D ⊂ R2 bounded domain.
Applications of matrix computations Finite difference methods Spring 2018 23 / 25
The quincunx pattern has extremely important applications in statistics as
well!

https://www.youtube.com/watch?v=AUSKTk9ENzg

Applications of matrix computations Finite difference methods Spring 2018 24 / 25


Bibliography

C. Gordon, D. Webb, and S. Wolpert. Isospectral plane domains and


surfaces via Riemannian orbifolds. Inventiones Mathematicae
110(1):1–22, 1992. DOI:10.1007/BF01231320
D. F. Griffiths and D. J. Higham. Numerical Methods for Ordinary
Differential Equations. Springer, 2010.

Applications of matrix computations Finite difference methods Spring 2018 25 / 25

You might also like