Graphics Reference
In-Depth Information
Similar reasoning also shows that the first formula we saw is a second-order
accurate central finite difference for the point
x
i
+1
/
2
=(
i
+1
/
2)Δ
x
:
∂q
∂x
(
x
i
+1
/
2
)=
q
i
+1
−
q
i
+
O
(Δ
x
2
)
.
Δ
x
Throughout this topic we also deal with functions sampled at midpoints,
q
i
+1
/
2
=
q
(
x
i
+1
/
2
), for which we can similarly write down
∂x
(
x
i
)=
q
i
+1
/
2
−
q
i−
1
/
2
Δ
x
∂q
+
O
(Δ
x
2
)
.
Higher derivatives can also be estimated. In particular, we can get
a second-order accurate central finite difference for the second derivative
∂
2
q/∂x
2
by writing down the Taylor series yet again:
∂x
(
x
i
)+
Δ
x
2
∂
2
q
∂x
2
(
x
i
)+
Δ
x
3
∂
3
q
∂x
3
(
x
i
)+
O
(Δ
x
4
)
,
q
i
+1
=
q
i
+Δ
x
∂q
2
6
∂
3
q
∂x
3
(
x
i
)+
O
(Δ
x
4
)
.
The following combination cancels out most of the terms:
∂x
(
x
i
)+
Δ
x
2
∂
2
q
∂x
2
(
x
i
)+
Δ
x
3
Δ
x
∂q
q
i−
1
=
q
i
−
2
6
2
q
i
+
q
i−
1
=Δ
x
2
∂
2
q
∂x
2
(
x
i
)+
O
(Δ
x
4
)
.
q
i
+1
−
Dividing through by Δ
x
2
gives the finite difference formula,
∂x
2
(
x
i
)=
q
i
+1
−
∂
2
q
2
q
i
+
q
i−
1
Δ
x
2
+
O
(Δ
x
2
)
.
A.2.2 Time Integration
Solving differential equations in time generally revolves around the same
finite difference approach. For example, to solve the differential equation
∂q
∂t
=
f
(
q
)
with initial conditions
q
(0) =
q
0
, we can approximate
q
at discrete times
t
n
,with
q
n
=
q
(
t
n
). The
time step
Δ
t
is simply the length of time between
these discrete times: Δ
t
=
t
n
+1
t
n
. This time-step size may or may
not stay fixed from one step to the next. The process of
time integration
is determining the approximate values
q
1
,q
2
,...
in sequence; it's called
−