Numerical Methods
Numerical Methods
Mona Rahmani
January 2019
Numerical methods are important tools to simulate
different physical phenomena.
• If is sufficiently small:
First derivative approximations
Now, consider the Taylor series expansion of
Subtract the second line from the first line and solve for
This time add the two lines together and solve for
time step
k+1,
time step
k,
x0 = 0 xN = 1.0
x
Solving the 1D heat equation
Step 2 - Discretize the PDE. Use a forward difference scheme for the
time derivative and a central difference scheme for the space
derivative:
Or:
time step
k+1,
time
step k,
time
step k-1, xN = 1.0
x0 = 0
x
Solving the 1D wave equation
Step 2 - Discretize the PDE. Use a central difference scheme
for both time and space derivatives:
I.C. 1:
I.C. 2:
Or:
Discrete wave equation
at :
Combine them:
Solving the 1D wave equation
The discrete approximation of the 1D wave equation:
x x
0 1
The numerical mesh
If :
The node (n,m) is linked to its 4 neighbouring nodes as illustrated in the finite difference
stencil:
Until there is small change in the solution (i.e. the solution has converged), as
measured by:
Matlab codes for numerical solutions of the
heat, the wave and Laplace’s equations:
• For each code, you only need to change the input data
and maybe the plotting part. The solver is already there!
PDE:
B.C.’s:
Tell the code if the B.C.’s prescribe the value of u
(Dirichlet type ) or its derivative (Neumann type)
Results: PDE:
0.8 B.C.’s:
0.4
0
0 0.2 0.4 0.6 0.8 1
x
The Matlab code for the 1D wave equation
PDE:
B.C.’s:
-0.5
-1
0 0.2 0.4 0.6 0.8 1 I.C.’s:
x
Standing waves
The Matlab code for Laplace’s equation
PDE:
B.C.’s:
1
1
0.5 B.C.’s:
0 0.5
2
3
1 2
1 0
y 0 0 x
2 1.8
1.6
1.5 1.4
1.2
1 1
y
0.8
0.5 0.6
0.4
0 0.2
0 1 2 3
x