Hubbry Logo
Finite difference methodFinite difference methodMain
Open search
Finite difference method
Community hub
Finite difference method
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Contribute something
Finite difference method
Finite difference method
from Wikipedia

In numerical analysis, finite-difference methods (FDM) are a class of numerical techniques for solving differential equations by approximating derivatives with finite differences. Both the spatial domain and time domain (if applicable) are discretized, or broken into a finite number of intervals, and the values of the solution at the end points of the intervals are approximated by solving algebraic equations containing finite differences and values from nearby points.

Finite difference methods convert ordinary differential equations (ODE) or partial differential equations (PDE), which may be nonlinear, into a system of linear equations that can be solved by matrix algebra techniques. Modern computers can perform these linear algebra computations efficiently, and this, along with their relative ease of implementation, has led to the widespread use of FDM in modern numerical analysis.[1] Today, FDMs are one of the most common approaches to the numerical solution of PDE, along with finite element methods.[1]

Derive difference quotient from Taylor's polynomial

[edit]

For a n-times differentiable function, by Taylor's theorem the Taylor series expansion is given as

Where n! denotes the factorial of n, and Rn(x) is a remainder term, denoting the difference between the Taylor polynomial of degree n and the original function.

Following is the process to derive an approximation for the first derivative of the function f by first truncating the Taylor polynomial plus remainder: Dividing across by h gives: Solving for :

Assuming that is sufficiently small, the approximation of the first derivative of f is:

This is similar to the definition of derivative, which is: except for the limit towards zero (the method is named after this).

Accuracy and order

[edit]

The error in a method's solution is defined as the difference between the approximation and the exact analytical solution. The two sources of error in finite difference methods are round-off error, the loss of precision due to computer rounding of decimal quantities, and truncation error or discretization error, the difference between the exact solution of the original differential equation and the exact quantity assuming perfect arithmetic (no round-off).

The finite difference method relies on discretizing a function on a grid.

To use a finite difference method to approximate the solution to a problem, one must first discretize the problem's domain. This is usually done by dividing the domain into a uniform grid (see image). This means that finite-difference methods produce sets of discrete numerical approximations to the derivative, often in a "time-stepping" manner.

An expression of general interest is the local truncation error of a method. Typically expressed using Big-O notation, local truncation error refers to the error from a single application of a method. That is, it is the quantity if refers to the exact value and to the numerical approximation. The remainder term of the Taylor polynomial can be used to analyze local truncation error. Using the Lagrange form of the remainder from the Taylor polynomial for , which is the dominant term of the local truncation error can be discovered. For example, again using the forward-difference formula for the first derivative, knowing that , and with some algebraic manipulation, this leads to and further noting that the quantity on the left is the approximation from the finite difference method and that the quantity on the right is the exact quantity of interest plus a remainder, clearly that remainder is the local truncation error. A final expression of this example and its order is:

In this case, the local truncation error is proportional to the step sizes. The quality and duration of simulated FDM solution depends on the discretization equation selection and the step sizes (time and space steps). The data quality and simulation duration increase significantly with smaller step size.[2] Therefore, a reasonable balance between data quality and simulation duration is necessary for practical usage. Large time steps are useful for increasing simulation speed in practice. However, time steps which are too large may create instabilities and affect the data quality.[3][4]

The von Neumann and Courant-Friedrichs-Lewy criteria are often evaluated to determine the numerical model stability.[3][4][5][6]

Example: ordinary differential equation

[edit]

For example, consider the ordinary differential equation The Euler method for solving this equation uses the finite difference quotient to approximate the differential equation by first substituting it for then applying a little algebra (multiplying both sides by h, and then adding to both sides) to get The last equation is a finite-difference equation, and solving this equation gives an approximate solution to the differential equation.

Example: The heat equation

[edit]

Consider the normalized heat equation in one dimension, with homogeneous Dirichlet boundary conditions

One way to numerically solve this equation is to approximate all the derivatives by finite differences. First partition the domain in space using a mesh and in time using a mesh . Assume a uniform partition both in space and in time, so the difference between two consecutive space points will be h and between two consecutive time points will be k. The points

will represent the numerical approximation of

Explicit method

[edit]
The stencil for the most common explicit method for the heat equation.

Using a forward difference at time and a second-order central difference for the space derivative at position (FTCS) gives the recurrence equation:

This is an explicit method for solving the one-dimensional heat equation.

One can obtain from the other values this way:

where

So, with this recurrence relation, and knowing the values at time n, one can obtain the corresponding values at time n+1. and must be replaced by the boundary conditions, in this example they are both 0.

This explicit method is known to be numerically stable and convergent whenever .[7] The numerical errors are proportional to the time step and the square of the space step:

Implicit method

[edit]
The implicit method stencil.

Using the backward difference at time and a second-order central difference for the space derivative at position (The Backward Time, Centered Space Method "BTCS") gives the recurrence equation:

This is an implicit method for solving the one-dimensional heat equation.

One can obtain from solving a system of linear equations:

The scheme is always numerically stable and convergent but usually more numerically intensive than the explicit method as it requires solving a system of numerical equations on each time step. The errors are linear over the time step and quadratic over the space step:

Crank–Nicolson method

[edit]

Finally, using the central difference at time and a second-order central difference for the space derivative at position ("CTCS") gives the recurrence equation:

This formula is known as the Crank–Nicolson method.

The Crank–Nicolson stencil.

One can obtain from solving a system of linear equations:

The scheme is always numerically stable and convergent but usually more numerically intensive as it requires solving a system of numerical equations on each time step. The errors are quadratic over both the time step and the space step:

Comparison

[edit]

To summarize, usually the Crank–Nicolson scheme is the most accurate scheme for small time steps. For larger time steps, the implicit scheme works better since it is less computationally demanding. The explicit scheme is the least accurate and can be unstable, but is also the easiest to implement and the least numerically intensive.

Here is an example. The figures below present the solutions given by the above methods to approximate the heat equation

with the boundary condition

The exact solution is

Comparison of Finite Difference Methods
c = 4
Explicit method (not stable)
c = 6
Implicit method (stable)
c = 8.5
Crank-Nicolson method (stable)

Example: The Laplace operator

[edit]

The (continuous) Laplace operator in -dimensions is given by . The discrete Laplace operator depends on the dimension .

In 1D the Laplace operator is approximated as This approximation is usually expressed via the following stencil and which represents a symmetric, tridiagonal matrix. For an equidistant grid one gets a Toeplitz matrix.

The 2D case shows all the characteristics of the more general n-dimensional case. Each second partial derivative needs to be approximated similar to the 1D case which is usually given by the following stencil

Consistency

[edit]

Consistency of the above-mentioned approximation can be shown for highly regular functions, such as . The statement is

To prove this, one needs to substitute Taylor Series expansions up to order 3 into the discrete Laplace operator.

Properties

[edit]

Subharmonic

[edit]

Similar to continuous subharmonic functions one can define subharmonic functions for finite-difference approximations

Mean value

[edit]

One can define a general stencil of positive type via

If is (discrete) subharmonic then the following mean value property holds where the approximation is evaluated on points of the grid, and the stencil is assumed to be of positive type.

A similar mean value property also holds for the continuous case.

Maximum principle

[edit]

For a (discrete) subharmonic function the following holds where are discretizations of the continuous domain , respectively the boundary .

A similar maximum principle also holds for the continuous case.

The SBP-SAT method

[edit]

The SBP-SAT (summation by parts - simultaneous approximation term) method is a stable and accurate technique for discretizing and imposing boundary conditions of a well-posed linear partial differential equation using high order finite differences.[8][9]

The method is based on finite differences where the differentiation operators exhibit summation-by-parts properties. Typically, these operators consist of differentiation matrices with central difference stencils in the interior with carefully chosen one-sided boundary stencils designed to mimic integration-by-parts in the discrete setting. Using the SAT technique, the boundary conditions of the PDE are imposed weakly, where the boundary values are "pulled" towards the desired conditions rather than exactly fulfilled. If the tuning parameters (inherent to the SAT technique) are chosen properly, the resulting system of ODE's will exhibit similar energy behavior as the continuous PDE, i.e. the system has no non-physical energy growth. This guarantees stability if an integration scheme with a stability region that includes parts of the imaginary axis, such as the fourth order Runge-Kutta method, is used. This makes the SAT technique an attractive method of imposing boundary conditions for higher order finite difference methods, in contrast to for example the injection method, which typically will not be stable if high order differentiation operators are used.

See also

[edit]

References

[edit]

Further reading

[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The finite difference method (FDM) is a numerical technique for solving differential equations by approximating continuous derivatives with discrete differences between function values at points on a structured grid. This approach discretizes the domain into a mesh of finite intervals, replacing the differential equation with a system of algebraic equations that can be solved computationally. It is widely used for both ordinary differential equations (ODEs) and partial differential equations (PDEs), particularly in boundary value problems where exact analytical solutions are unavailable. The method's theoretical foundations emerged in the early , building on earlier approximations in numerical computation dating back to the . A pivotal early application was L.F. Richardson's 1910 use of s to solve PDEs for stress analysis in , marking one of the first practical implementations for physical problems. In 1928, , Kurt Friedrichs, and Hans Lewy provided a seminal of schemes for hyperbolic PDEs, introducing the stability criterion now known as the CFL condition, which ensures that numerical solutions remain physically meaningful by limiting the time step relative to the spatial grid. Finite difference methods approximate using formulas such as forward differences (e.g., f(x)f(x+h)f(x)hf'(x) \approx \frac{f(x + h) - f(x)}{h}), backward differences, or centered differences for improved accuracy (e.g., second-order precision). These are applied to generate discrete equations on uniform grids, often leading to matrix systems solved iteratively. Key applications include simulating conduction and (via the ), wave propagation (via the wave equation), fluid flow in porous media, and electromagnetic fields through the finite-difference time-domain (FDTD) variant. In fields like and physics, FDM excels on regular geometries due to its simplicity and ease of implementation, though it struggles with complex or irregular domains where adaptive gridding or alternative methods like finite elements are preferred.

Fundamentals

Overview and Definition

The finite difference method is a numerical technique used to approximate solutions to differential equations by discretizing continuous domains into a finite grid of points and replacing derivatives with discrete difference quotients. This approach transforms the continuous problem into a system of algebraic equations that can be solved computationally, making it particularly suitable for problems where analytical solutions are unavailable or impractical. It assumes a basic familiarity with differential equations but focuses on the grid-based discretization process, where the domain is divided into evenly spaced points to enable finite approximations of rates of change. In standard notation, consider a one-dimensional domain discretized with grid spacing hh, yielding points xi=x0+ihx_i = x_0 + i h for ii, and corresponding function values uiu(xi)u_i \approx u(x_i). The first u(x)u'(x) can be approximated using forward, backward, or central differences: the forward difference is u(x+h)u(x)h\frac{u(x + h) - u(x)}{h}, the backward difference is u(x)u(xh)h\frac{u(x) - u(x - h)}{h}, and the central difference is u(x+h)u(xh)2h\frac{u(x + h) - u(x - h)}{2h}. For the second u(x)u''(x), a common central difference approximation is u(x+h)2u(x)+u(xh)h2\frac{u(x + h) - 2u(x) + u(x - h)}{h^2}. These operators provide the foundational building blocks for constructing finite difference schemes across higher dimensions and more complex equations. The origins of finite differences trace back to 18th-century interpolation techniques developed by and Leonhard Euler, who used discrete differences to approximate continuous functions. The method was formalized for solving partial differential equations in the early 20th century, notably by in his 1910 work on approximate arithmetical solutions to physical problems involving differential equations. This laid the groundwork for modern applications in .

Derivation from Taylor Series

The finite difference approximations for derivatives are derived from the expansion of a smooth function around a given point. For a function u(x)u(x) that is sufficiently differentiable, the Taylor theorem states that u(x+h)=u(x)+hu(x)+h22u(ξ)u(x + h) = u(x) + h u'(x) + \frac{h^2}{2} u''(\xi) for some ξ\xi between xx and x+hx + h. Rearranging the expansion for u(x+h)u(x + h) yields the forward difference approximation to the first : u(x+h)u(x)h=u(x)+O(h).\frac{u(x + h) - u(x)}{h} = u'(x) + O(h). The backward difference approximation is obtained analogously from the expansion u(xh)=u(x)hu(x)+h22u(η)u(x - h) = u(x) - h u'(x) + \frac{h^2}{2} u''(\eta) for some η\eta between xhx - h and xx, giving u(x)u(xh)h=u(x)+O(h).\frac{u(x) - u(x - h)}{h} = u'(x) + O(h). The central difference for the first derivative combines the expansions for u(x+h)u(x + h) and u(xh)u(x - h), where the linear terms cancel, resulting in u(x+h)u(xh)2h=u(x)+O(h2).\frac{u(x + h) - u(x - h)}{2h} = u'(x) + O(h^2). For the second derivative, adding the expansions for u(x+h)u(x + h) and u(xh)u(x - h) eliminates the odd-powered terms, yielding the central difference formula u(x+h)2u(x)+u(xh)h2=u(x)+O(h2).\frac{u(x + h) - 2u(x) + u(x - h)}{h^2} = u''(x) + O(h^2). Approximations for higher-order derivatives follow a similar process, employing Taylor expansions at multiple grid points and matching coefficients through the method of undetermined coefficients to achieve the desired accuracy order.

Accuracy and Convergence Order

The truncation error in finite difference methods represents the discrepancy between the exact mathematical derivative and its discrete approximation on a finite grid. This error arises primarily from the truncation of the infinite Taylor series expansion used to derive the approximations. The leading error terms are obtained from the remainders in Taylor expansions. For the forward difference approximation of the first derivative, f(x+h)f(x)h=f(x)+h2f(ξ)\frac{f(x + h) - f(x)}{h} = f'(x) + \frac{h}{2} f''(\xi) for some ξ(x,x+h)\xi \in (x, x + h), the truncation error is O(h)O(h). The backward difference, f(x)f(xh)h\frac{f(x) - f(x - h)}{h}, similarly yields an O(h)O(h) error. In contrast, the central difference for the first derivative, f(x+h)f(xh)2h=f(x)+h26f(ξ)\frac{f(x + h) - f(x - h)}{2h} = f'(x) + \frac{h^2}{6} f'''(\xi) for some ξ(xh,x+h)\xi \in (x - h, x + h), has a leading error of O(h2)O(h^2). For the second derivative using the central difference, f(x+h)2f(x)+f(xh)h2=f(x)+h212f(4)(ξ),\frac{f(x + h) - 2f(x) + f(x - h)}{h^2} = f''(x) + \frac{h^2}{12} f^{(4)}(\xi), the truncation error is also O(h2)O(h^2). The order of accuracy of a finite difference approximation is defined as the largest integer pp such that the truncation error is O(hp)O(h^p) as the grid spacing hh approaches zero. Higher-order methods reduce the error more rapidly with decreasing hh, enabling more efficient computations for a given accuracy level. For schemes applied to partial differential equations, consistency requires that the local vanishes as h0h \to 0. This property ensures that the discrete equations approach the continuous PDE in the limit, forming a prerequisite for convergence of the numerical solution to the exact one. Although reducing hh diminishes , it exacerbates round-off errors from finite-precision arithmetic, as more grid points amplify accumulation of floating-point inaccuracies. Optimal accuracy thus involves selecting an hh that balances these competing error sources.

Applications to Ordinary Differential Equations

First-Order Initial Value Problems

The finite difference method provides a framework for numerically solving first-order initial value problems by approximating the derivative with discrete differences on a uniform grid. The model problem is the ordinary differential equation u(x)=f(x,u)u'(x) = f(x, u) with initial condition u(0)=u0u(0) = u_0 over the interval [0,T][0, T]. To apply the method, the interval is discretized into NN equal steps of size k=T/Nk = T/N, yielding grid points xn=nkx_n = n k for n=0,1,,Nn = 0, 1, \dots, N, where unu_n approximates u(xn)u(x_n). This approach relies on finite difference quotients to replace the continuous derivative, enabling a step-by-step march from the initial condition. The employs the u(xn+k)u(xn)ku(xn)\frac{u(x_n + k) - u(x_n)}{k} \approx u'(x_n), which, when substituted into the , yields the explicit update formula un+1=un+kf(xn,un),n=0,1,,N1,u_{n+1} = u_n + k f(x_n, u_n), \quad n = 0, 1, \dots, N-1, with u0=u0u_0 = u_0. This scheme is straightforward to implement and computationally efficient, as each step requires only evaluation of the known function ff at the current point. The local , arising from the approximation of the exact solution, is O(k2)O(k^2), while the accumulated global error over the interval is O(k)O(k), establishing it as a accurate method. In contrast, the uses the backward u(xn+1)u(xn)ku(xn+1)\frac{u(x_{n+1}) - u(x_n)}{k} \approx u'(x_{n+1}), leading to the implicit relation un+1=un+kf(xn+1,un+1).u_{n+1} = u_n + k f(x_{n+1}, u_{n+1}). This requires solving an equation for un+1u_{n+1} at each step, which may involve nonlinear solvers if ff is nonlinear, but the method offers improved stability for certain problems. The combines the forward and backward approaches by averaging the right-hand side evaluations: un+1=un+k2[f(xn,un)+f(xn+1,un+1)].u_{n+1} = u_n + \frac{k}{2} \left[ f(x_n, u_n) + f(x_{n+1}, u_{n+1}) \right]. This implicit scheme achieves second-order accuracy, with local O(k3)O(k^3) and global error O(k2)O(k^2), providing a balance between precision and the need for iterative solution at each step. A basic implementation for the forward is as follows:

function forward_euler(f, x0, u0, k, N): x = x0 u = u0 for n = 0 to N-1: u_next = u + k * f(x, u) x = x + k u = u_next return x, u

function forward_euler(f, x0, u0, k, N): x = x0 u = u0 for n = 0 to N-1: u_next = u + k * f(x, u) x = x + k u = u_next return x, u

This code advances from the initial values (x0,u0)(x_0, u_0) by NN steps of size kk, evaluating ff explicitly at each iteration.

Boundary Value Problems

Boundary value problems (BVPs) for second-order ordinary differential equations (ODEs) involve solving equations of the form u(x)=f(x,u(x),u(x))u''(x) = f(x, u(x), u'(x)) subject to boundary conditions u(a)=αu(a) = \alpha and u(b)=βu(b) = \beta, where the conditions are specified at the endpoints of the interval [a,b][a, b]. This setup contrasts with initial value problems by requiring the solution to satisfy conditions at two distinct points, leading to a system of algebraic equations rather than a marching procedure. The method discretizes the domain into a uniform grid with spacing h=(ba)/Nh = (b - a)/N, where NN is the number of interior points, and approximates the derivatives using finite difference formulas. For the second derivative, the central difference approximation is employed: ui12ui+ui+1h2u(xi),\frac{u_{i-1} - 2u_i + u_{i+1}}{h^2} \approx u''(x_i), where uiu(xi)u_i \approx u(x_i) and xi=a+ihx_i = a + i h for i=1,,Ni = 1, \dots, N. If the right-hand side depends on the first derivative, it is approximated centrally as u(xi)ui+1ui12hu'(x_i) \approx \frac{u_{i+1} - u_{i-1}}{2h}, yielding the discretized equation ui12ui+ui+1h2=f(xi,ui,ui+1ui12h)\frac{u_{i-1} - 2u_i + u_{i+1}}{h^2} = f\left( x_i, u_i, \frac{u_{i+1} - u_{i-1}}{2h} \right) for i=1,,Ni = 1, \dots, N, with boundary conditions incorporated as u0=αu_0 = \alpha and uN+1=βu_{N+1} = \beta. This results in a system of NN nonlinear algebraic equations for linear problems where ff is independent of uu and uu', the system takes the form Au=bA \mathbf{u} = \mathbf{b}, where AA is an N×NN \times N tridiagonal matrix with 1, -2, and 1 on the subdiagonal, diagonal, and superdiagonal (scaled by 1/h21/h^2), respectively, and b\mathbf{b} incorporates the forcing term and boundary values. Such tridiagonal systems are efficiently solved using the Thomas algorithm, a direct method based on Gaussian elimination tailored for this structure, achieving O(N)O(N) computational complexity. The central finite difference scheme for second-order BVPs exhibits second-order accuracy, with the global being O(h2)O(h^2), as derived from the expansions underlying the approximations. A representative example is the one-dimensional Poisson equation u(x)=π2sin(πx)u''(x) = -\pi^2 \sin(\pi x) on [0,1][0, 1] with Dirichlet boundary conditions u(0)=u(1)=0u(0) = u(1) = 0, whose exact solution is u(x)=sin(πx)u(x) = \sin(\pi x). Discretizing with central differences leads to the tridiagonal system ui12ui+ui+1h2=π2sin(πxi),i=1,,N,\frac{u_{i-1} - 2u_i + u_{i+1}}{h^2} = -\pi^2 \sin(\pi x_i), \quad i = 1, \dots, N, which can be solved via the Thomas algorithm to approximate the solution at grid points, converging to the exact solution at rate O(h2)O(h^2). For nonlinear BVPs, where ff depends on uu and/or uu', the discretization produces a system of nonlinear equations that can be solved iteratively using methods such as . In this approach, an initial guess for the solution vector is refined through successive linearizations of the discretized equations, solving the resulting tridiagonal systems at each iteration until convergence. The method preserves the second-order accuracy of the underlying scheme provided the nonlinearity is sufficiently smooth.

Applications to Partial Differential Equations

Discretization of the Heat Equation

The one-dimensional models the diffusion of heat in a thin rod and is expressed as ut=α2ux2,\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}, where u(x,t)u(x,t) represents the at position xx and time tt, and α>0\alpha > 0 is the constant. This is typically solved on a rectangular domain 0xL0 \leq x \leq L, t0t \geq 0, subject to the u(x,0)=g(x)u(x,0) = g(x) for 0<x<L0 < x < L and homogeneous Dirichlet boundary conditions u(0,t)=u(L,t)=0u(0,t) = u(L,t) = 0 for t>0t > 0. To apply the finite difference method, the spatial domain [0,L][0, L] is discretized into a uniform grid with points xi=iΔxx_i = i \Delta x for i=0,1,,N+1i = 0, 1, \dots, N+1, where Δx=L/(N+1)\Delta x = L / (N+1) and the interior points are at i=1i = 1 to NN. Similarly, the time domain is discretized with tn=nΔtt_n = n \Delta t for n=0,1,2,n = 0, 1, 2, \dots, where Δt>0\Delta t > 0 is the time step size. The solution u(xi,tn)u(x_i, t_n) is approximated by uinu_i^n. The boundary conditions are incorporated by fixing u0n=0u_0^n = 0 and uN+1n=0u_{N+1}^n = 0 for all nn. A key step in the discretization is approximating the spatial second derivative using the central difference stencil, leading to the semi-discrete form via the method of lines. At each interior grid point xix_i, the approximation yields the system of ordinary differential equations duidt=αΔx2(ui12ui+ui+1),i=1,,N,\frac{du_i}{dt} = \frac{\alpha}{\Delta x^2} (u_{i-1} - 2 u_i + u_{i+1}), \quad i = 1, \dots, N, with the boundary values u0(t)=0u_0(t) = 0 and uN+1(t)=0u_{N+1}(t) = 0 enforced at all times tt. This reduces the original PDE to a coupled system of NN ODEs for the vector u(t)=(u1(t),,uN(t))T\mathbf{u}(t) = (u_1(t), \dots, u_N(t))^T, where the right-hand side is represented by a tridiagonal matrix. The initial condition is set as ui(0)=g(xi)u_i(0) = g(x_i) for i=1,,Ni = 1, \dots, N. Full temporal discretization of this semi-discrete can then be achieved using various time-stepping methods, but the framework highlights the role of the dimensionless r=αΔt/Δx2r = \alpha \Delta t / \Delta x^2, which scales the relative importance of temporal and spatial increments in the numerical solution.

Discretization of the Laplace

The two-dimensional Laplace equation, 2u=2ux2+2uy2=0\nabla^2 u = \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = 0, describes steady-state phenomena such as electrostatic potentials or incompressible fluid flow in a rectangular domain Ω=[a,b]×[c,d]\Omega = [a, b] \times [c, d] subject to Dirichlet boundary conditions u=gu = g on Ω\partial \Omega. This requires to obtain a solvable algebraic system, typically via finite differences on a structured grid. To apply the finite difference method, a uniform Cartesian grid is superimposed on the domain with spacing Δx=Δy=h=(ba)/Nx=(dc)/Ny\Delta x = \Delta y = h = (b-a)/N_x = (d-c)/N_y, where NxN_x and NyN_y are the number of intervals in each direction. The second derivatives are approximated using central differences, which are second-order accurate based on expansions as outlined in the derivation section. At an interior grid point (xi,yj)=(a+ih,c+jh)(x_i, y_j) = (a + i h, c + j h) for 1iNx11 \leq i \leq N_x - 1 and 1jNy11 \leq j \leq N_y - 1, the discretized equation becomes the : ui+1,j+ui1,j+ui,j+1+ui,j14ui,jh2=0,\frac{u_{i+1,j} + u_{i-1,j} + u_{i,j+1} + u_{i,j-1} - 4u_{i,j}}{h^2} = 0, which simplifies to ui+1,j+ui1,j+ui,j+1+ui,j1=4ui,ju_{i+1,j} + u_{i-1,j} + u_{i,j+1} + u_{i,j-1} = 4u_{i,j}. Boundary values from the Dirichlet conditions are directly incorporated to form a sparse for the unknown interior values. Ordering the unknowns row-wise (lexicographically by jj then ii), the resulting system Au=bA \mathbf{u} = \mathbf{b} has AA that is block tridiagonal, with tridiagonal blocks along the and sub/super-diagonals connecting adjacent rows. The vector b\mathbf{b} accounts for boundary contributions. This structure allows efficient solution via methods like or iterative solvers such as . The local truncation error of the is O(h2)O(h^2), arising from the second-order accuracy of the central difference operators. Global convergence to the true solution at order O(h2)O(h^2) follows from consistency and stability properties. A representative example is the unit square [0,1]×[0,1][0,1] \times [0,1] with boundary conditions u(0,y)=u(1,y)=u(x,0)=0u(0,y) = u(1,y) = u(x,0) = 0 and u(x,1)=sin(πx)u(x,1) = \sin(\pi x). Discretizing with Nx=Ny=MN_x = N_y = M yields (M1)2(M-1)^2 unknowns and a symmetric positive definite system solvable to demonstrate the method's accuracy, with errors decreasing as O(h2)O(h^2) upon refinement. For domains with irregular boundaries, one approach extends the uniform grid beyond the domain using ghost points—fictitious nodes outside Ω\Omega—to maintain the stencil while interpolating values to enforce boundary conditions accurately. This technique preserves the O(h2)O(h^2) accuracy near the boundary without altering the interior .

Numerical Schemes for Parabolic Equations

Explicit Finite Difference Method

The explicit finite difference method, often referred to as the , provides a simple explicit for solving the one-dimensional ut=α2ux2\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}. This approach approximates the time derivative using a forward difference and the spatial with a central difference, yielding an update rule that computes the solution at the next time level directly from known values at the current level without solving a . The scheme emerges from the method of lines, where the central difference operator discretizes the spatial derivative to produce a semi-discrete system of ordinary differential equations, subsequently integrated in time using the . The resulting fully discrete approximation is uin+1=uin+r(ui1n2uin+ui+1n),u_i^{n+1} = u_i^n + r (u_{i-1}^n - 2u_i^n + u_{i+1}^n), where r=αΔtΔx2r = \alpha \frac{\Delta t}{\Delta x^2}, uinu_i^n denotes the approximate solution at grid point xi=iΔxx_i = i \Delta x and time tn=nΔtt_n = n \Delta t, Δx\Delta x is the spatial grid spacing, and Δt\Delta t is the time step. Implementation involves initializing the spatial grid with the given and then performing iterative updates for each interior grid point using the explicit , while enforcing boundary conditions at the domain edges after each time step. This process is computationally inexpensive per step, relying only on nearest-neighbor values, which facilitates easy coding and execution on uniform grids. The local for this scheme is O(Δt+Δx2)O(\Delta t + \Delta x^2), arising from the first-order accurate forward Euler time discretization and the second-order accurate central spatial difference. Stability of the explicit scheme is conditional, necessitating r12r \leq \frac{1}{2} to prevent oscillatory growth and ensure convergence to the true solution as the is refined. The scheme also incorporates inherent numerical through its truncation terms, which introduce additional smoothing effects that can alter sharp features in the solution beyond the physical diffusion coefficient α\alpha.

Implicit Finite Difference Method

The implicit finite difference method addresses the limitations of explicit schemes by using a backward difference approximation for the time in the , resulting in an unconditionally stable . This approach, known as the , approximates the solution at the next time level uin+1u_i^{n+1} while incorporating the spatial derivatives also at that future time level, leading to a fully implicit . The scheme for the one-dimensional ut=αuxxu_t = \alpha u_{xx} is given by uin+1r(ui1n+12uin+1+ui+1n+1)=uin,u_i^{n+1} - r (u_{i-1}^{n+1} - 2u_i^{n+1} + u_{i+1}^{n+1}) = u_i^n, where r=αΔt/Δx2r = \alpha \Delta t / \Delta x^2 is the dimensionless parameter governing the relative step sizes, and the spatial stencil uses central differences for the second derivative as outlined in the discretization of the heat equation. In matrix form, this implicit scheme can be expressed as (IrA)un+1=un(I - r A) \mathbf{u}^{n+1} = \mathbf{u}^n, where un\mathbf{u}^n is the vector of solution values at time level nn, II is the identity matrix, and AA is the tridiagonal matrix representing the discrete second derivative operator with entries Ai,i1=1A_{i,i-1} = 1, Ai,i=2A_{i,i} = -2, and Ai,i+1=1A_{i,i+1} = 1. At each time step, this linear system must be solved for un+1\mathbf{u}^{n+1}, typically using a direct solver like the Thomas algorithm for tridiagonal matrices, which has a computational cost of O(N)O(N) operations per step for NN spatial grid points. The local truncation error of the backward Euler implicit scheme is O(Δt+Δx2)O(\Delta t + \Delta x^2), achieving second-order accuracy in space but only accuracy in time due to the backward difference . Despite the lower temporal order, the method exhibits unconditional stability for any r>0r > 0, meaning the numerical solution remains bounded regardless of the time step size, as proven via arguments showing that the discrete maximum norm does not amplify errors.

Crank-Nicolson Finite Difference Method

The is a scheme that averages the explicit and implicit methods to solve parabolic partial differential equations such as the , achieving second-order accuracy in time while maintaining the stability benefits of the implicit approach. Developed by John Crank and Phyllis Nicolson in 1947, the method was introduced as a practical technique for numerically evaluating solutions to heat conduction problems, offering improved efficiency over purely explicit schemes. The scheme arises from applying the for temporal integration to the semi-discrete form of the , after central finite differences have discretized the spatial derivatives. For the one-dimensional ut=αuxxu_t = \alpha u_{xx} on a uniform grid with spatial step Δx\Delta x and temporal step Δt\Delta t, define r=αΔt/Δx2r = \alpha \Delta t / \Delta x^2 and let uinu(iΔx,nΔt)u_i^n \approx u(i \Delta x, n \Delta t). The Crank–Nicolson scheme then takes the form uin+1r2(ui1n+12uin+1+ui+1n+1)=uin+r2(ui1n2uin+ui+1n).u_i^{n+1} - \frac{r}{2} (u_{i-1}^{n+1} - 2 u_i^{n+1} + u_{i+1}^{n+1}) = u_i^n + \frac{r}{2} (u_{i-1}^n - 2 u_i^n + u_{i+1}^n). In , let un\mathbf{u}^n denote the vector of solution values at time level nn, and let AA be the representing the discrete operator scaled by 1/Δx21 / \Delta x^2. The scheme can be expressed as the (Ir2A)un+1=(I+r2A)un,\left( I - \frac{r}{2} A \right) \mathbf{u}^{n+1} = \left( I + \frac{r}{2} A \right) \mathbf{u}^n, which is solved iteratively using efficient tridiagonal solvers. The local of the is O(Δt2+Δx2)O(\Delta t^2 + \Delta x^2). It is unconditionally stable for the , permitting time steps unrestricted by stability constraints. However, for large rr, the second-order time accuracy can lead to non-physical oscillations in the numerical solution.

Stability and Properties of Schemes

Stability Analysis for the Heat Equation

Stability analysis in finite difference methods for the focuses on ensuring that discretization errors do not amplify over time, preventing numerical solutions from diverging. A primary tool for this is the , which assumes a solution form ujn=ξneikjΔxu_j^n = \xi^n e^{i k j \Delta x}, where ξ\xi is the amplification factor, kk is the , Δx\Delta x is the spatial step, and i=1i = \sqrt{-1}
Add your contribution
Related Hubs
Contribute something
User Avatar
No comments yet.