FINITE DIFFERENCES AND INTEGRATION
The one-dimensional acoustic wave equation is:
![]()
![]()
Where v(x) is the velocity of waves (sound, vibrations, etc.) and Y (x, t) is the displacement at location x and time t.
The Taylor series expansion for a function Y (x+Dx, t) at a distance Dx from Y (x, t) is as follows:
![]()
Where v(x) is the velocity of waves (sound, vibrations, etc.) and Y (x,t) is the displacement at location x and time t.
The Taylor series expansion for a function Y (x+Dx,t) at a distance Dx from Y (x,t) is as follows:
![]()
By summing the two Taylor series together, we get:
(3)
where O (Dx4) are the 4th and higher order terms.
By rearranging, we get:
(4)
and
(5)
Similarly, we can do the same for ¶2Y(x, t) / ¶t2:

and again, by substituting (-Dt) in place of Dt, we get:

By adding Y (x, t-Dt) and Y (x, t+Dt) together, we get a formula that contains the second derivative of Y (x, t) with respect to t:

By rearranging, we get:
![]()
or

Now we can return to equation (1):
![]()
and complete the details by substituting equations (4) and (9) to get:
![]()

We can rearrange this to get:
![]()
![]()
To find the displacement, Y, at every point, x, along the string in the future t+Dt, we need to know the displacement, Y(x,t) and Y(x, t-Dt), along the string at the present time, t ,and at a past time, t-Dt. So after dropping the error terms:
![]()
To solve this problem in a computer, we are going to have to know the displacements, Y, at every location of x for the present time, Y(x,t), Y(x+Dx,t), Y(x-Dx,t).
We will also have to know the displacements at a previous time step Y(x,t–Dt). These displacements will be contained in two different arrays; one for current times Y(x,t) and one for past times Y(x,t–Dt).
We will also have to know the distance, Dx, between adjacent points along the string, the time step between calculations, Dt, and the velocity at each point along the string v(x).
For a 4th order approximation, remember we have dropped the O(Dx4) and the O (Dt4) terms.
Initial and Boundary Conditions:
When solving this equation, the initial condition needs to be specified. The following diagrams illustrate a possible initial and boundary condition for a one-dimensional string at times
Y(x,t = -Dt) and Y(x,t = 0).
At time Y (x,t-Dt)

x=xo x=xn
At time Y (x,t)

x=x0 x=xn
Note the boundary conditions here are: Y (x=xo) = Y (x=xn) = 0 for all t.
Comment:
There are two methods we can use to perform finite difference calculations:
Explicit: Current values of ∂/∂x and past value of ∂/∂t are used to get the new values of Y(t+Dt). This is the method described above and it can be unstable if the right values for Dx and Dt are not used.
Implicit: New values of Y(t+Dt) are calculated by inverting a matrix. This is always a stable process.
We can calculate the numerical approximation for higher order derivatives by a substitution of the previous Taylor series. As an example, we calculate ¶4Y(x,t) / ¶x4. Note that:

But from equation (4), we know:

We can use the distributive property to calculate the derivatives of the right hand side.

![]()

![]()
We already know ¶2Y(x,t) / ¶x2 and we can find the other two derivatives by substituting (x+Dx) and (x–Dx) in place of x to get:
![]()
![]()
Therefore, by substituting equations (4, 15a, and 15b) into equation (14), we get:


or
(17)
First Order Derivatives: Forward, Backward, and Central Differences:
There are three fundamental operators used to approximate the first-order derivative of a discrete series of data in a computer. Each of these methods depend on a Taylor series expansion, e.g.,
(18)
Again by substituting (–Dx) in place of Dx in equation (18), we get:
(19)
Forward Difference Method:
Here we calculate the first derivative of Y by looking at positions x and x+Dx. Dropping the t dependence and by manipulating equation (18), we have:
![]()
where O(Dx2) are the Dx2 and higher order terms. This idea can be coded in the following lines of FORTRAN:
DO J = 1, N-1
DX (J) = (X (J+1) - X (J)) / DELX
END DO
DX (N) = ?
Here, DX (N) is not defined, since X (N+1) does not exist.
Backward Difference Method:
Here we calculate the first derivative of Y by looking at positions x and x–Dx. Dropping the dependence and by manipulating equation (19), we have:
![]()
where O (Dx2) are the Dx2 and higher order terms. This idea can be coded in the following lines of FORTRAN:
DX (1) = ?
DO J = 2, N
DX (J) = (X (J) - X (J-1)) / DELX
END DO
Here, the derivative at DX (1) is not defined, since X(0) does not exist.
Central Difference Method:
Here we calculate the first derivative of Y by subtracting Y(x–Dx,t) from Y (x+Dx,t).
![]()
![]()
Dropping the t dependence and subtracting, we have
![]()
or
![]()
where O(Dx3) are the Dx3 and higher order terms. This idea can be coded in the following lines of FORTRAN:
DX (1) = ?
DX (N) = ?
DO J = 2, N-1
DX (J) = ( X(J+1) - X (J-1)) / (2. * DELX)
END DO
Here both DX (1) and DX (N) are not defined, since X (0) and X (N+1) do not exist.
Note: Both the forward and the backward difference operators are accurate to O(Dx2); however, the central difference operator is accurate to O(Dx3).
Integration:
Suppose you have a set of discrete data points at x1, x2,, x3,, .....xn. At each of these data points, a curve has the values f(x1), f(x2), f(x3),....f(xn). The distance between each of the data points is Dx.
f (x)

We want to compute:

Trapezoidal rule:
