Q #

explain implicit vs explicit scheme in pde and show examples

A #

Implicit vs. Explicit Schemes in Partial Differential Equations (PDEs) #

In numerical analysis, particularly when solving partial differential equations (PDEs), two common approaches are used: implicit and explicit schemes. These schemes are methods for approximating solutions to PDEs, especially when analytical solutions are difficult or impossible to obtain.

Explicit Schemes #

In an explicit scheme, the solution at a future time step is calculated directly from the known values at the current and possibly previous time steps. The primary advantage of explicit schemes is their simplicity and ease of implementation. However, explicit methods can be conditionally stable, meaning they require the time step to be sufficiently small relative to the spatial step size (mesh size) to ensure stability. This condition is often governed by a criterion like the Courant-Friedrichs-Lewy (CFL) condition.

Example: The Explicit Euler Method for the Heat Equation

Consider the one-dimensional heat equation: $$ \frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2} $$ where $ u(x,t) $ represents the temperature at position $ x $ and time $ t $, and $ \alpha $ is the thermal diffusivity.

Using an explicit finite difference scheme: $$ u_i^{n+1} = u_i^n + \Delta t \cdot \alpha \frac{u_{i+1}^n - 2u_i^n + u_{i-1}^n}{(\Delta x)^2} $$ Here, $ u_i^n $ is the temperature at spatial point $ i $ and time $ n $, $ \Delta t $ is the time step, and $ \Delta x $ is the spatial step size.

Implicit Schemes #

Implicit schemes, on the other hand, involve solving one or more equations at each time step, which can include current and future values. This approach typically requires solving a system of equations, often via methods such as Newton-Raphson or through linear solvers if the system is linear. The primary advantage of implicit schemes is their stability; they are often unconditionally stable, allowing for larger time steps without the solution becoming unstable.

Example: The Implicit Euler Method for the Heat Equation

Again considering the one-dimensional heat equation: $$ \frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2} $$

Using an implicit finite difference scheme: $$ u_i^{n+1} = u_i^n + \Delta t \cdot \alpha \frac{u_{i+1}^{n+1} - 2u_i^{n+1} + u_{i-1}^{n+1}}{(\Delta x)^2} $$ This results in a system of linear equations to solve for $ u^{n+1} $ values at each time step.

Comparison and Choice #

Choosing between these methods often depends on the specific characteristics of the problem, including the desired accuracy and computational resources available.

Q #

consider 2d domain pde, can I discrete pde in one direction using implicit scheme while the other using explicit scheme? if so, how to discrete and show me example.

A #

Yes, you can discretize a PDE in a 2D domain using a mixed approach, where one direction is treated with an implicit scheme and the other with an explicit scheme. This method is known as the ADI (Alternating Direction Implicit) method. It is particularly useful for solving 2D heat equations or similar parabolic PDEs, because it can be more stable than a fully explicit method and less computationally intensive per time step than a fully implicit method.

Example: ADI Method for 2D Heat Equation #

Consider the 2D heat equation without sources: $$ \frac{\partial u}{\partial t} = \alpha \left( \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} \right) $$ where $ u(x,y,t) $ is the temperature at position $ (x, y) $ and time $ t $, and $ \alpha $ is the thermal diffusivity.

The ADI method splits the computation into two half-steps. In the first half-step, the $ x $-direction is treated implicitly, and the $ y $-direction is treated explicitly. In the second half-step, the roles are reversed.

Discretization #

Let’s define $ \Delta x $ and $ \Delta y $ as the spatial step sizes in the $ x $ and $ y $ directions, respectively, and $ \Delta t $ as the time step.

First Half-Step (Implicit in $ x $, Explicit in $ y $): $$ u_{i,j}^{n+1/2} = u_{i,j}^n + \frac{\alpha \Delta t}{2} \left( \frac{u_{i+1,j}^{n+1/2} - 2u_{i,j}^{n+1/2} + u_{i-1,j}^{n+1/2}}{(\Delta x)^2} + \frac{u_{i,j+1}^n - 2u_{i,j}^n + u_{i,j-1}^n}{(\Delta y)^2} \right) $$

Second Half-Step (Explicit in $ x $, Implicit in $ y $): $$ u_{i,j}^{n+1} = u_{i,j}^{n+1/2} + \frac{\alpha \Delta t}{2} \left( \frac{u_{i+1,j}^{n+1/2} - 2u_{i,j}^{n+1/2} + u_{i-1,j}^{n+1/2}}{(\Delta x)^2} + \frac{u_{i,j+1}^{n+1} - 2u_{i,j}^{n+1} + u_{i,j-1}^{n+1}}{(\Delta y)^2} \right) $$

Steps for Solving #

  1. Initialize: Define the boundary conditions and initial conditions for $ u(x,y,0) $.
  2. Solve the first half-step: Use a tridiagonal matrix solver (due to the implicit treatment in the $ x $-direction) while simply updating terms explicitly in the $ y $-direction.
  3. Solve the second half-step: Now use the values from the first half-step, apply a tridiagonal matrix solver in the $ y $-direction, and update the $ x $-direction explicitly.

Each of these steps results in solving a tridiagonal system, which is computationally efficient and can be done using algorithms such as the Thomas algorithm.

The ADI method offers a good balance by allowing larger time steps compared to fully explicit methods without requiring the full computational burden of a fully implicit scheme in both directions. This method is especially popular in financial mathematics for solving problems like the two-dimensional Black-Scholes equation in option pricing.