Professional Documents
Culture Documents
CM SA 02 Taylor FiniteDiff
CM SA 02 Taylor FiniteDiff
Climate Modelling
3rd year, SA Bachelor
1
26/08/21
∂p Hydrostatic equation
+ gρ = 0
∂z
dT Q
+ (γ −1)T ∇ ⋅ V = Thermodynamic equation
dt cp
∂ρ Mass conservation
+ ∇ ⋅ ρV = 0
∂t
Water conservation
∂ρ w
+ ∇ ⋅ ρ w V = [sources − sinks]
∂t
7 equations, 7 variables (u,v,w,p,T,ρ,ρw). 3
2
26/08/21
du u tan φ 1 ∂p
−( f + )v + + Fx = 0
dt a ρ ∂x
dv u tan φ 1 ∂p
+( f + )u + + Fy = 0
dt a ρ ∂y
The basic idea of Finite Difference method (FDM) à to replace the partial
derivatives by approximations obtained by Taylor expansions near the point of
interests
3
26/08/21
f ( x + dx ) − f ( x)
∂ x f = lim
dx →0 dx
f ( x) − f ( x − dx )
∂ x f = lim
dx →0 dx
f ( x + dx ) − f ( x − dx )
∂ x f = lim
dx →0 2dx
x-Δx x x+Δx
All definitions are right when dx->0.
f ( x) − f ( x − dx )
∂x f − ≈
dx forward
backward
Centered differencing
x-Δx x x+Δx
f ( x + dx ) − f ( x − dx )
∂x f ≈
2dx
4
26/08/21
Question
How good is a finite differencing approximation?
≈≠=
àTaylor’s expansion....
Taylor’s expansion
§ Taylor’s expansion of a given function about a single point to
approximate the derivative(s) at that point
à Derivatives are replaced by finite difference approximations
§ Suppose u is a function of x possessing derivatives of all orders in
the interval (x-nΔx, x+nΔx).
à We can obtain the value of u at points x±nΔx in terms of the
value of u(x) and its derivatives at point x.
5
26/08/21
Taylor’s expansion
Similarly
Taylor’s expansion
6
2 f a h 2f
h2 f a h f a h 2 f a h f h'' 2 a f '' a
f a h f a hf ' a f '' a and f a h f a hf ' a f '' a h
2 2
By adding the second-order Taylor series expansion, we get likewise the second derivative 26/08/21
Example 1.1 f a h 2f a f a h
f a h f a h 2 f a h 2 f '' a f '' a
Write the 2n 1 order Taylor series h 2 expansion of the function sin
f x f' x sin x cos x f '' x sin x f (3) x c
ample 1.1
an approximation of the second derivative, we
Taylor’s expansion (3)
ite the 2n 1 order Taylor f series
0 is more0,
This equation f ' than
expansion
accurate 0 the of
1, the
first f ''ones.
two 0To obtain
function 0,anfsin x0 about
approximation etc.derivative, we
of the1second
0.
h2 write the second-order Taylor series expansion
This equation is moreof accurate
f: than the first two ones. To obtain an approximation of the second derivative, we
(3)
f '' a x cos① Q1: Write the Taylor’s expansion till 2n+1 order for the
x 2 sin f' x x '' write
f Thisxequation sin
is morex3accurate
x Taylorxfthan
2the second-order
h
5seriesthexfirst two2 ofcos
expansion ones.
h f: n xetc.
x obtain
f : To 2 nan1approximation of the second derivative, we
2n 1
e the second derivative Then
f a h f a sin
(3) a xthe second-order
hf 'write f '' ax and f Taylor
function sin(x) at x=0 ? a h series expansion of
hf a hf ' a f ''1a 2
h x 2 x
0 0, f ' 0 1, f '' 0 0, f 0 1 etc. 3! h 5!
2 2
f a 2 hfn' a 1 !f2'' a
f a h f a hf ' a f '' a and f a h f2a hf ' ah f '' a 2
a f a h f a Taylor
By adding the second-order h fseries
a expansion,
hf ' a we2fget
2
and fthea second
'' alikewise h derivative2
By2adding
n 1 the second-order Taylor series expansion, we get likewise the second derivative
② Q2: Write the Taylor’s expansion till n order for the function
x3 x5 n Byxadding2the second-order
2 n 1 f a series
Taylor h 2 fexpansion,
a f a weh get likewise the second derivative
a1 h 2 f f aa hh f '' fa ax hf '' a2 f ax h 2 f '' a 2 f '' a f a h 2 f a f af ha h
f a h 2 f a
en sin x x f a h ef x at x=0 ?
h
3! 5! Examplef21.2 a h 1 f! a h 2 f a h f '' a
n 2
f '' a 2
h
h 2
Example③ Q3: Write the Taylor’s expansion till n order for the function
x about 0. Write
1.1
the
1 order Taylor
n-th
Example 1.1
Example 1.1
Write the 2n 1/(1-x) for x<1 at x=0?
Write the
series
order
1 order of
2nexpansion
Taylor
Taylor
the
series
series expansion
function sin x of the
about 0.
expansion
function sin x about 0.
of the function e x ab
ample
s x etc.1.2 Writexthe 2n 1 order Taylor series expansion of the function sin x about 0.
f x sinf x x f ' xf fe x x sin fxf'' x' f x
xcos sin
(3) ' x xcos
f ' x sincos
xxetc.x f efxx x cosfcosx(3)etc.
ex xxf f x'' fx'' fxcos''sinx xsin x
x etc. e x etc. (3)
ite the n-th order Taylor series expansion of the function e about 0.
(3)
x
④ Q4: Write the Taylor’s expansion till n order for the function
(3)
f 0 0, (3) f ' 0 1, f '' 0 0, f 0 1 etc.
00 1,1 fetc.
x f 0 0, f ' 0 1, f ''f 0x0 0,0,f f ' (3) '' 0 x0, f 0 1 etc. (3) (3)
x e x
f' x e f f'' xx03+x32+x+1 at x=2
e 1, f 'f 0 x2n 1x1, xef '' etc. 0 1,
3 5 x f 0 1 etc.
2n 1
3
2n 1
5
n
2n 1
5
xThensinsinx x n x x x x 2 n 1
x Then 1
n1 x 2 n x1 x
Then sin x (3)x 1 3! x5! x 2n 1 !x x
0 1, f ' 0 1, f '' 0 1, f 0
3! 5! 1 etc. 3!
2n 1 ! 5!
2
x3 2 n
x
1 ! n
x
x
2 3 Then
n eExample
11.21.2x
Example xn x
x x Example 1.2 x 2! 3! of n
of!the x
en
ut 0.e
x
1 x xWrite
n
Write xthen-th
the n-th order
order Taylor
Taylor series
series expansion
expansion the function
function e about
e about 0. 0. x
f 0 1, f ' 0 Function
1, f '' 0 1, f 0of 1xtwo
x x x real
(3)
etc. x x2variables:
2 let f x, y be a function of two r
3 3 n n
3
x x n! n!
x
Then e x 1 x xn x
first and second partial derivatives, which are continuous in the v
n
2! 3! Function! f f has
first and second partial derivatives, which
Function are
of of
twotwo continuous
real
real let letf xin
variables:
variables:
Taylor’s expansion
f , yx,the
ybe be vicinity
a function
a function ofof
of two reala
two point
real variables
variables x and by . Ity. is.We
ax ,and note
Itassumed
is assumed
that that
f has
f f 0, 0
yy x j k y xx xy yy
j 1k 1
f x, y cos x cos y 0, f 0, 0 0, f x, y 1, f 0, 0 0 et f 0, 0 1
26/08/21
16