Discrete Harmonic Functions and Dirichlet's Relaxation Method

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Discrete harmonic functions are derived from harmonic functions (i.e. solutions to the Laplace equation). More specifically, a discrete harmonic function on a two-dimensional domain is a function defined on the lattice points (i.e. points with integer coordinates) of that satisfies the discrete mean-value property


for every lattice point in the interior of . Under some mild assumptions on , a discrete harmonic function is uniquely determined by its values on the boundary lattice points of , and it is the unique function that minimizes the discrete analog of the Dirichlet energy integral. 

The Dirichlet method of relaxation is an iterative method for computing discrete harmonic functions with given boundary values. Starting with an arbitrary initial function on  with the given boundary values, construct a sequence of functions by replacing, at each step, the value on each interior lattice point by the average of the values at its four neighboring points.

This Demonstration illustrates discrete harmonic functions and the Dirichlet relaxation method in the case that is a rectangular region, possibly with a rectangular hole. Choose the dimensions of the rectangle (and, optionally, the dimensions of the hole), choose a boundary function from the options given and then increment the number of iterations in the relaxation method from 0 to its maximal value. Observe that as the number of iterations increases, the Dirichlet energy decreases. Accordingly, the graph of the function constructed in the relaxation process approaches a limit, representing the unique discrete harmonic function with the given boundary values.


Contributed by: Yuheng Chang (January 2019)
Based on an undergraduate research project at the Illinois Geometry Lab by Yuheng Chang, Baihe Duan, Yirui Luo, Yitao Meng, Cameron Nachreiner and Yiyin Shen and directed by A. J. Hildebrand.
Open content licensed under CC BY-NC-SA


Discrete Harmonic Functions and Electric Networks

Discrete harmonic functions have a natural interpretation in the context of electric networks. Interpret the lattice points in a 2D domain as nodes of an electric network connected with resistors, and let denote the voltage at the point . Then the function is a discrete harmonic function; see [1] for details.

Dirichlet Method of Relaxations

This is an iterative method for computing discrete harmonic functions with given boundary values. Starting with an arbitrary initial function satisfying the boundary conditions, the method constructs a sequence of functions defined by


As , approaches a harmonic function; see [1, p. 16].

Boundary Functions

Three families of boundary functions are provided for the outer and inner (if selected) boundaries of the domain:




where , , are user-defined parameters.

The values of at the boundary are random real numbers chosen uniformly from the interval , where is a user-defined parameter.


For this Demonstration, we chose to initialize the values of in the interior of the domain to random real numbers chosen uniformly from the interval , whereis a user-defined parameter. Choosing as 0 is equivalent to initializing the values in the interior of to .

Dirichlet Energy

For continuous functions defined on some domain , the integral , where denotes the gradient, is called the Dirichlet energy integral. This integral can be interpreted as the potential energy of a system or as a measure of the "energy" of the surface . The smaller this integral, the flatter the surface. A characteristic property of harmonic functions is that they minimize the Dirichlet energy integral. From among all functions having given values on the boundary of , the harmonic function satisfying the given boundary conditions is the unique function that minimizes the Dirichlet energy integral.

The discrete analog of the Dirichlet energy integral is the sum over the squares of the differences of values of on all pairs of neighboring points; that is


where the sum runs over all interior lattice points in . In analogy to the continuous case, discrete harmonic functions are the unique functions that, for given boundary conditions, minimize the discrete Dirichlet energy.


[1] P. G. Doyle and J. L. Snell, Random Walks and Electric Networks, Washington, DC: Mathematical Association of America, 1984.


Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.