# A fast sweeping method for Eikonal equations

By Hongkai Zhao

## Abstract

In this paper a fast sweeping method for computing the numerical solution of Eikonal equations on a rectangular grid is presented. The method is an iterative method which uses upwind difference for discretization and uses Gauss-Seidel iterations with alternating sweeping ordering to solve the discretized system. The crucial idea is that each sweeping ordering follows a family of characteristics of the corresponding Eikonal equation in a certain direction simultaneously. The method has an optimal complexity of for grid points and is extremely simple to implement in any number of dimensions. Monotonicity and stability properties of the fast sweeping algorithm are proven. Convergence and error estimates of the algorithm for computing the distance function is studied in detail. It is shown that Gauss-Seidel iterations is enough for the distance function in dimensions. An estimation of the number of iterations for general Eikonal equations is also studied. Numerical examples are used to verify the analysis.

## 1. Introduction

The Eikonal equation

with boundary condition, , has many applications in optimal control, computer vision, geometric optics, path planing, etc. This nonlinear boundary value problem is a first order hyperbolic partial differential equation (PDE). Information propagates along characteristics from the boundary. Due to the nonlinearity, characteristics may intersect like the formation of shocks in hyperbolic conservation law. The solution is still continuous at these intersections but may not be differentiable. The existence and uniqueness of the viscosity solution are shown in Reference4.

There are two key ingredients for any numerical algorithm for the Eikonal equation. The first key ingredient is the derivation of a consistent and accurate discretization scheme, i.e., a numerical Hamiltonian. The numerical scheme has to follow the causality of the partial differential equation and has to deal with non-differentiability at intersections of characteristics properly. Since the problem is nonlinear, a large system of nonlinear equations has to be solved after the discretization. Hence the second key ingredient is an efficient method for solving the large nonlinear system.

There are mainly two types of approaches for solving the Eikonal equation. One approach is to transform it to a time dependent problem. For example, if we have , , then is the first arrival time at for a wave front starting at with a normal velocity that is equal to . This can be solved by the level set method. In the control framework, a semi-Lagrangian scheme is obtained for Hamilton-Jacobi equations by discretizing in time the dynamic programming principle Reference9Reference10. However, many time steps may be needed for the convergence of the solution in the entire domain due to finite speed of propagation and CFL condition for time stability. The other approach is to treat the problem as a stationary boundary value problem and to design an efficient numerical algorithm to solve the system of nonlinear equations after discretization. For example, the fast marching method Reference19Reference16Reference11 is of this type. In the fast marching method, the update of the solution follows the causality in a sequential way; i.e., the solution is updated one grid point by one grid point in the order that the solution is strictly increasing (decreasing). Hence an upwind difference scheme and a heapsort algorithm are needed. The complexity is of order for grid points, where the factor comes from the heapsort algorithm.

Here we present and analyze an iterative algorithm, called the fast sweeping method, for computing the numerical solution for the Eikonal equation on a rectangular grid in any number of space dimensions. The fast sweeping method is motivated by the work in Reference2 and was first used in Reference21 for computing the distance function. The main idea of the fast sweeping method is to use nonlinear upwind difference and Gauss-Seidel iterations with alternating sweeping ordering. In contrast to the fast marching method, the fast sweeping method follows the causality along characteristics in a parallel way; i.e., all characteristics are divided into a finite number of groups according to their directions and each Gauss-Seidel iteration with a specific sweeping ordering covers a group of characteristics simultaneously. The fast sweeping method is extremely simple to implement. The algorithm is optimal in the sense that a finite number of iterations is needed. So the complexity of the algorithm is for a total of grid points. The number of iterations is independent of grid size. The accuracy is the same as any other method which solves the same system of discretized equations. The fast sweeping method has been extended to more general Hamilton-Jacobi equations Reference18Reference12. Extensions to high order discretization will be studied in future reports.

The idea of alternating sweeping ordering was also used in Danielssonâ€™s algorithm Reference6. The algorithm computes the distance mapping, i.e., the relative coordinate of a grid point to its closest point using an iterative procedure. Danielssonâ€™s algorithm is based on a strict dimension by dimension discrete formulation which in general does not follow the real characteristics of the distance function in two and higher dimensions and hence results in low accuracy and twice as many iterations compared to the fast sweeping method we present here. Danielssonâ€™s algorithm does not work for distance functions to more general data sets such as the distance to a curve or a surface. Neither does it extend to general Eikonal equations. Recently another discrete approach that uses the idea of fast sweeping method was proposed in Reference17. It can compute the distance function more accurately but does not apply to general Eikonal equations either. Other related methods include a dynamic programming approach and post sweeping idea in Reference15 and a group marching method in Reference13.

Here is the outline of the paper. In Section 2 we present the scheme and the motivation behind it. We then show a few monotonicity properties and a maximum change principle for the fast sweeping algorithm in Section 3. In Section 4 we prove the convergence and error estimates for the distance function. We discuss the fast sweeping method for general Eikonal equations in Section 5. In Section 6 we present numerical results to verify our analysis and we show a few applications.

## 2. The fast sweeping algorithm and the motivation

We present the fast sweeping method for computing the viscosity solution for the model problem

where . For simplicity the algorithm is presented in two dimensions. The extension to higher dimensions is straightforward. We use to denote a grid point in the computational domain ,â€… to denote the grid size and to denote the numerical solution at .

### 2.1. The fast sweeping algorithm

Discretization

We use the following Godunov upwind difference scheme Reference14 to discretize the partial differential equation at interior grid points:

where and

One sided difference is used at the boundary of the computational domain. For example, at a left boundary point , a one sided difference is used in the direction,

Initialization

To enforce the boundary condition, for , assign exact values or interpolated values at grid points in or near . These values are fixed in later calculations. Assign large positive values at all other grid points. These values will be updated later.

Gauss-Seidel iterations with alternating sweeping orderings

At each grid whose value is not fixed during the initialization, compute the solution, denoted by , of (Equation2.2) from the current values of its neighbors and then update to be the smaller one between and its current value; i.e., . We sweep the whole domain with four alternating orderings repeatedly:

The unique solution to the equation

where , is

In dimensions the unique solution to

can be found in the following systematic way. First we order the â€™s in increasing order. Without loss of generality, assume and define . There is an integer , , such that is the unique solution that satisfies

i.e., is the intersection of the straight line , with the sphere centered at of radius in the first quadrant in . We find and in the following recursive way. Start with . If , then . Otherwise find the unique solution that satisfies

If , then . Otherwise repeat the procedure until we find and that satisfy (Equation2.6).

Here are a few remarks about the algorithm:

(1)

The upwind difference scheme (Equation2.2) is a special case of the general Godunov numerical Hamiltonian proposed in Reference1. The numerical Hamiltonian can be written as

where

and means taking the positive part and means taking the negative part. Instead of using the upwind difference scheme (Equation2.2), we can also use

which corresponds to the numerical Hamiltonian

Both numerical Hamiltonians are monotone. The only difference between these two formulations is at the intersections of characteristics. The second formulation may have larger truncation errors at those intersections as will be explained in Section 4.

(2)

In practice it may be desirable to restrict the computation to a neighborhood of the boundary . For example, if we want to restrict the computation in the neighborhood where the first arrival time is less than , i.e., , then we can use the following simple cutoff criterion: in the Gauss-Seidel iteration we update the solution at a grid point only if at least one of its neighbors has a value smaller than , i.e., if .

(3)

The large value assigned initially should be larger than the maximum possible value of in the computation domain. For example, let and let be the diameter of the computational domain . The initially assigned large value should be larger than .

(4)

In higher dimensions, the discretization (Equation2.2) is easily extended dimension by dimension and there are different sweeping orderings in dimensions.

(5)

If we want to compute the viscosity solution for (Equation2.1), we modify the discretization (Equation2.2) to

where and

In the initialization, we assign small negative values at grid points whose values are to be updated. In the Gauss-Seidel iteration, we update the value at a grid point only if the new value obtained by solving (Equation2.8) is larger than its old value.

### 2.2. The motivation

In the fast sweeping algorithm the upwind difference scheme used in the discretization enforces the causality; i.e., the solution at a grid point is determined by its neighboring values that are smaller. The one sided difference scheme at the boundary enforces the propagation of information to be from inside to outside since the data set is contained in the computational domain. If all grid points can be ordered according to the causality along characteristics, one iteration of the Gauss-Seidel iteration is enough for convergence. For example, the heapsort algorithm is used in the fast marching method to sort out this order every time a grid point is updated. The key point behind Gauss-Seidel iterations with different sweeping ordering is that each sweep will follow the causality of a group of characteristics in certain directions simultaneously and all characteristics can be divided into a finite number of such groups according to their directions. The value at each grid point is always nonincreasing during the iterations due to the updating rule. Whenever a grid point obtains the minimal value it can reach, the value is the correct value and the value will not be changed in later iterations.

We use the distance function as an example to illustrate the motivation. The distance function to a set satisfies the Eikonal equation

All characteristics of this equation are straight lines that radiate from the set . In one dimension, the upwind differencing at the interior grid point is

We use two Gauss-Seidel iterations with sweeping orderings, and successively, to solve the above system. The update of the distance value at grid simply becomes

Figure 2.1 shows how one sweep from left to right followed by one more sweep from right to left is enough to finish the calculation of the distance function. This follows because there are only two directions for the characteristics in one dimension, left to right or vice versa. In another word, the distance value at any grid point can be computed from either its left neighbor or right neighbor by exactly . The first sweep will cover those characteristics that go from left to right; i.e., those grid points whose values are determined by their left neighbors are computed correctly. Similarly, in the second sweep all those grid points whose values are determined by their right neighbors are computed correctly. Since we only update the current value if the newly computed value is smaller, those values that have been calculated correctly in the first sweep have achieved their minimal possible values and will not be changed in the second sweep. Convergence in two sweeps is true for arbitrary Eikonal equations in one dimension. In the special case of the distance function, it is easy to see that the fast sweeping method finds the exact distance function in two sweeps.

In higher dimensions characteristics have infinitely many directions which cannot be followed exactly by the Cartesian grid lines. Here are two important questions for the fast sweeping algorithm: (1) How many Gauss-Seidel iterations are needed? (2) What is the error estimate? The most important observation is that all directions of characteristics can be classified into a finite number of groups for distance functions. For example, in two dimensions all directions of characteristics can be classified into four groups, up-right, up-left, down-left and down-right. Information propagates along characteristics in the above four groups of directions. The four different orderings of the Gauss-Seidel iterations and the upwind differencing are meant to cover the four groups of characteristics, respectively. Figure 2.2(a) illustrates why the fast sweeping method converges after four sweeps with different orderings for the distance function to a single point. The solution at each grid point in the first quadrant depends on the solution at and which have already been computed and can be recursively traced all the way back to the data point in the first sweep. So we get the correct values for all grid points in the first quadrant plus the points on the positive and axes after the first sweep. For the same reason, after the second sweep the grid points in the second quadrant and on the negative axis get the correct values. Moreover, since those grid points in the first quadrant and on the positive and axes already have their minimal values and satisfy the discretized equations, these values will not change in the second sweep. Similarly, after the third sweep those grid points in the third quadrant and on the negative axis get the correct values and the computed correct values in the first and second quadrants are maintained. After four sweeps we get the correct values for all grid points that satisfy the system of equations (Equation2.2). Figure 2.2(b) demonstrates another case which computes the distance function to a circle in two dimensions using the fast sweeping algorithm. Again, each grid point gets its correct value in one of the four sweeps.

In the case of one data point, the distance function is smooth except at the data point. For a more general data set, interactions of characteristics at their intersections can cause more than sweeps for the iteration to converge in dimensions. It is impossible to track the exact number of sweeps for the highly nonlinear discretized system in general. However, we will show that in dimensions, after sweeps the fast sweeping method can compute a numerical solution to the distance function that is as accurate as the numerical solution after the iteration converges. This means sweeps is good enough in practice for computing the distance function to an arbitrary data set. For general Eikonal equations, the characteristics are curves instead of straight lines. So more than one sweep may be needed to cover one characteristic curve. We will see that given a fixed domain and the right-hand side , the number of sweeps needed is still finite and is independent of grid size.

## 3. Basic properties of the fast sweeping algorithm

Here we prove a few basic monotonicity properties and a maximum change principle for the fast sweeping algorithm. The following simple fact for the solution of equation (Equation2.5) provides the monotonicity and maximum change principle for the fast sweeping algorithm.

### Lemma 3.1

Let be the solution to equation Equation2.5. We have

and

### Proof.

Differentiating equation (Equation2.5) with respect to , we get

â–

As a direct consequence of the lemma, we have

### Proposition 3.2

In the Gauss-Seidel iteration for the fast sweeping method, the maximum change of at any grid point is less than or equal to the maximum change of at its neighboring points.

### Lemma 3.3

The fast sweeping algorithm is monotone in the initial data.

### Proof.

This is a direct consequence from Lemma 3.1; i.e., the monotonicity property of the solution to (Equation2.5). If at all grid points initially, then at all grid points after any number of Gauss-Seidel iterations.

â–

### Lemma 3.4

The solution of the fast sweeping algorithm is nonincreasing with each Gauss-Seidel iteration.

### Proof.

This is exactly because of the way we update the solution in the Gauss-Seidel iterations described in the third step of the algorithm.

â–

The following corollary shows the stability property for the fast sweeping method. We present it in two dimensions but it is true in general.

### Corollary 3.5

Let and be two numerical solutions at the -th iteration of the fast sweeping algorithm. Let be the maximum norm. We have

(1) ,

(2) .

### Proof.

Let us assume that the first update at the -th iteration is at point , , where solves (Equation2.2) with neighboring values , , , . The same is true for . From the maximum change principle, we have

For an update at any other grid point later in the iteration, the neighboring values used for the update are either from the previous iteration or from an earlier update in the current iteration, both of which satisfy the above bound. By induction, we prove (1).

The second statement is a simple consequence of the monotonicity of the fast sweeping method and the previous statement by setting .

â–

### Remark

The second statement provides an effective stopping criterion for sweeping. Before correct information from the boundary has reached all grid points, is of . When is , the information has reached all points and we can stop the sweeping in practice. Although the iteration has not converged yet, the numerical solution is already as accurate as the converged one as we will see from the numerical examples. The iterative solution will change less and less in later iterations and converges to the solution of the discretized system.

### Theorem 3.6

The iterative solution by the fast sweeping algorithm converges monotonically to the solution of the discretized system.

### Proof.

Denote the numerical solution after the -th sweep by . Since is bounded below by and is nonincreasing with Gauss-Seidel iterations, is convergent for all . After each sweep, for each we have

because any later update of neighbors of in the same sweep is nonincreasing. Moreover, it is easy to see that after is updated, the function

is Lipschitz continuous in all variables and the Lipschitz constant is bounded by

Since is monotonically convergent for every , we can have an upper bound for the Lipschitz constant. Let be the maximum change at all grid points during the -th sweep. From Corollary 3.5 and the convergence of , goes monotonically to zero. After the -th iteration, we have

So converges to the solution to (Equation2.2).

â–

## 4. Convergence and error estimate for the distance function

Although it is shown that the fast sweeping algorithm is convergent by Theorem 3.6, the main issue for the efficiency of the fast sweeping method is the number of iterations needed and the error estimate. In this section we prove a few concrete results for the distance function. Since the fast sweeping algorithm is highly nonlinear, the proof can only be based on the monotonicity properties and the maximum change principle proved in Section 3. Some of the proofs will be stated in two dimensions for simplicity. We use the following notations: denotes the data set to which we want to compute the distance function, denotes the numerical solution using the fast sweeping method, denotes the exact distance function, is the grid size, and is the spatial dimension.

### Theorem 4.1

For a single data point , the numerical solution, , of the fast sweeping method converges in sweeps in and satisfies

where is the distance function to .

### Proof.

We prove the theorem in two dimensions. The proof can be easily extended to any number of dimensions.

First, assume the data point is a single grid point. Without loss of generality the point is at the origin. For each grid point in the first quadrant its value only depends on its two down-left neighbors . Each grid point on the positive axis depends on its left neighbor and each point on the positive axis depends on its neighbor below. The first Gauss-Seidel iteration exactly propagates information from the data point to all these grid points in the right order. This order of dependence is illustrated clearly in Figure 4.1(a) for points in the first quadrant, e.g., values at grid points on the dashed line two are determined by values at grid points on dashed line one, etc. In exactly the same way grid points in the second quadrant and on the negative axis, grid points in the third quadrant and on the negative axis, and points in the fourth quadrant get their correct values of in the second, third and fourth sweep successively. Moreover the four quadrants are separated by two grid lines, i.e., the and axes. The values of grid points on these two lines do not depend on any values of grid points off these two lines. So the propagation of information in one quadrant during the corresponding sweep cannot cross these two lines into other quadrants. Actually, whenever a grid point achieves its correct value of for the system of equations (Equation2.2), it is the minimum value that can be achieved and will not change afterward.

For a data point that is not a grid point, we initially assign the exact distance values for grid points that are the vertices of the grid cell that contains the data point. The closest vertical grid line and the closest horizontal grid line partition the whole domain into four quadrants. It can be checked that the solution at grid points on these two lines does not depend on values of grid points off these two lines and the grid points in each quadrant get their correct values in one of the corresponding Gauss-Seidel sweeps. Figure 4.1(b) shows an example of a particular partition. This ends the proof that for a single data point the fast sweeping algorithm converges in four Gauss-Seidel iterations with alternating sweeping ordering in two dimensions.

Now we show the error estimate for grid points in the first quadrant. The proof is exactly the same for all other quadrants. Again we first assume the data point is a grid point. The exact distance function satisfies the Eikonal equation everywhere except at the data point. Using Taylor expansion at grid point , we have

where and are two intermediate points on the line segments connecting , and connecting , , respectively. At ,

So the distance function satisfies the following equation at :

Since the solution of the quadratic equation (Equation2.3) depends monotonically on , we have . Using the explicit expression (Equation4.2) for the derivatives and the maximum change principle, the local truncation error satisfies

The global error estimate comes from the fact the accumulation of truncation errors is in the same direction of information propagation as is shown in Figure 4.1(a); i.e., grid points on line depend only on grid points on line . Define . Using the simple fact that

and the maximum change principle, we have

So the maximum error that can be accumulated at for is

Here is the maximum error for grid points on the line , which is 0 if the data point is a grid point. The proof and estimate are exactly the same in dimensions.

If the data point is not a grid point, all the error estimates are the same except that , which yields the same result.

â–

### Remark

The error estimate is sharp since there is no cancellation of local truncation errors and the accumulation of truncation errors for grid points on the diagonal is exactly of .

When there is more than one data point, the situation becomes more complicated because there are interactions among data points. Characteristics from different data points intersect and the distance function is not differentiable at equal distance points. For the exact distance function to a data set composed of discrete points, i.e., , the interaction is simply the minimum rule, i.e.,

Let be the numerical solution to the distance function to a single point by the fast sweeping method and define

From our previous results for a single point we have

after four sweeps.

### Lemma 4.2

For an arbitrary set of discrete points , .

### Proof.

For any fixed there is an , , such that

After the initialization step, . From the monotonicity in initial data for the fast sweeping algorithm, stated in Lemma 3.3, we have

after any number of sweeps.

â–

Let be the solution to the system of discretized equations, e.g., (Equation2.2) in two dimensions.

### Theorem 4.3

For an arbitrary set of discrete points , the numerical solution by the fast sweeping method after sweeps, satisfies

### Proof.

The solution to the system of discretized equations, , can be viewed as the solution by the fast sweeping algorithm after the iteration converges as is shown in Theorem 3.6. Since the solution of the fast sweeping algorithm is nonincreasing with Gauss-Seidel iterations, we have after any number of sweeps. So after sweeps, the numerical solution produced by the fast sweeping algorithm satisfies

â–

Since the upwind difference is of first order accuracy, is at most . The general results for Hamilton Jacobi equations, e.g., Reference5Reference14Reference3Reference7, show that the numerical solution from a consistent and monotone scheme converges to the viscosity solution with the order of . The upper bound in the above theorem is sharp as is shown in Theorem 4.1. If the error estimate, , is also or worse, the theorem says that for the distance function, the iterative solution after sweeps is as accurate as . Any other method that solves the same discretized system of equations has the same accuracy too.

However, we do not have for a general data set due to the interactions among data points. Figure 4.2 shows an example of two data points. At those circled grid points the characteristics from both data points meet. The distance function follows either one of the characteristics. For example at grid point (1, 1) the distance function satisfies

and . However in our upwind scheme, the numerical solution uses both characteristics and satisfies

which gives . We can view this as the information propagation speed is numerically doubled. However, since the upwind scheme uses at most two characteristics from in the -direction and from in the -direction in two dimensions, we show that this is actually the worst truncation error that can occur at a grid point due to the interactions of data points, i.e. when characteristics intersect orthogonally and align with both axes. For instance in two dimensions, without loss of generality suppose and

Then and the equality holds when . On the other hand the distance function satisfies and the equality holds when the axis is a characteristic. In dimensions, the characteristics can be used at most times when they intersect at one grid point. So the worst local truncation error due to the interactions of characteristics is . For the modified version of the fast sweeping algorithm (Equation2.7), the truncation errors at equal distance points can be twice as much.

To get a clearer picture of the convergence of the iteration and error estimate for a general data set, we have to study the interactions among data points more carefully. We can partition all grid points into the Voronoi cell of each data point. The Voronoi diagram is according to the the numerical solution ; i.e., a grid point is in the Voronoi cell of if

If a grid point and all its neighboring grid points belong to the same Voronoi cell, we call it an interior point. Otherwise we call it a boundary point. The interaction of different data points occurs only at boundary points. Figure 4.3(a) shows a typical Voronoi cell for a data point . For cell boundary points (those circled points), may pick up information from more than one data point.

To get the lower bound for the numerical solution after sweeps, we use as the initial data and start the fast sweeping iteration. Due to the monotonicity in initial data we get a solution that provides a lower bound for the numerical solution for which we use the standard initialization step. already satisfies the discretized equations at interior points of each Voronoi cell. After we start the fast sweeping algorithm, the decrease of the values at interior points of each Voronoi cell is caused by the interactions at Voronoi cell boundaries. Moreover, if we start with , it is easy to show from the system of discretized equations at each grid point and the definition of Voronoi cells. Hence from the maximum change principle Proposition 3.2, we can imagine that the maximum decrease of values at all grid points due to the interactions at the Voronoi cell boundary is of order . But unlike the case for the real distance function where information propagates only along characteristics and all characteristics flow into the Voronoi cell boundary, in the finite difference scheme a grid point may have a larger domain of dependence as is illustrated in Figure 4.3(b). So interactions at Voronoi cell boundaries may propagate into the cell. This may also cause more than sweeps for convergence in dimensions. Example 1 in Section 6 shows that even for two data points in two dimensions, more than four sweeps are needed for the iteration to converge.

Now we consider computing the distance function to an arbitrary set. For example, instead of discrete points, is a smooth curve or surface.

### Theorem 4.4

If the distance function in the neighborhood of an arbitrary data set in is given initially, let be the numerical solution by the fast sweeping method after sweeps. We have

where is the solution to the discretized system Equation2.2.

### Proof.

Let be the set of grid points that encloses the set ; i.e., contains vertices of all those grid cells that intersect with . We have

since for any such that and vice versa.

By the monotonicity in initial data, after any number of sweeps, since initially starts with distance to for while for . However, the initial difference between and is . By the contraction property from Corollary 3.5, we have

after any number of sweeps. We apply Theorem 4.3 to and combine it with (Equation4.7) and (Equation4.8) to finish the proof.

â–

Actually for an arbitrary data set, which can be discrete points and/or continuous manifolds, we only need approximate distance values at grid points near the data set within first order accuracy, since the upwind finite difference scheme is at most of first order.

## 5. General Eikonal equations

For the general Eikonal equation (Equation2.1), the characteristics are curves starting from the boundary. The key issue is the maximum number of sweeps needed to cover information propagation along a single characteristic curve. This number, which is analogous to the condition number for elliptic equations, determines the number of iterations needed for the fast sweeping algorithm. For a single characteristic curve starting at a point , we divide it into the least number of pieces such that the tangent directions in each piece belong to the same quadrant. Information propagation along each piece can be covered by one of the sweepings ordering successively. So the number of sweeps needed to cover the whole characteristic curve is proportional to the number of pieces or turns. Figure 5.1 shows an example in 2D. The characteristic curve starting from can be divided into five pieces. The tangent directions in each piece belong to the same quadrant. If we order one round of four alternating sweeps as in Section 2, the first and the second pieces are covered by the first and fourth sweeps in the first round, respectively, the third piece is covered by the third sweep in the second round, the fourth piece is covered by the second sweep in the third round and the fifth piece is covered by the first sweep in the fourth round.

One quantity that can characterize how sharp the tangent of a curve can turn is curvature. The following lemma shows a bound on the curvature of any characteristic curve.

### Lemma 5.1

The maximum curvature for any characteristic curve of equation Equation2.1 is bounded by .

### Proof.

Denote , where . The characteristic equation is

The information propagates along the characteristics from smaller to larger . Since , the curvature along a characteristic is

where is the projection on the normal direction . So .

â–

So for general Eikonal equations the number of iterations for the fast sweeping method depends on the right-hand side and the size and dimension of the computational domain only. The computed numerical solution has the same accuracy as the solution by any other method that uses the same discretization.

If the boundary and are smooth and , then is a noncharacteristic boundary and there is a neighborhood of in which characteristics do not cross each other and the solution is smooth (see Reference8). Let this neighborhood be . We have

### Theorem 5.2

The numerical solution to the discretized system Equation2.2 is of first order in ; i.e., .

### Proof.

Without loss of generality, suppose the numerical solution to (Equation2.2) satisfies the equation

at a grid point , while the true solution satisfies

at , where and are two intermediate points on the line segments connecting , and connecting , , respectively. Since are bounded, from the maximum change property, Lemma 3.1, we can deduce that the local truncation error is . The propagation and accumulation of truncation errors following the causality along characteristics in a finite domain is at most .

â–

This error estimate breaks down when the solution has singularities. Since the characteristics do intersect for general Eikonal equations, we cannot use this argument after characteristics intersect. We quote the general error estimate results for monotone schemes for Hamilton-Jacobi equations Reference5Reference14Reference3Reference7. The error is of order . In general, there are two scenarios for the solution to have singularities. In the first scenario is smooth but characteristics intersect and shocks are formed. The solution is continuous but not differentiable at shocks. The numerical solution can be only first order accurate at shocks. However, characteristics and information flow into shocks for the true solution. Numerically we also observe that errors made at shocks do not propagate away from shocks and hence high order schemes can achieve high order accuracy in smooth regions. In the second scenario has singularities such as corners and kinks. Hence the solution also has singularities at . The distance function to a single point is such an example. Again only first order accuracy can be achieved near the boundary for any numerical scheme. Since characteristics and information flow out of the boundary, errors made near the boundary will propagate out to the computational domain. So the global error will be at most of first order no matter what scheme is used. The only solution is to use a finer grid near singularities at the boundary.

## 6. Numerical results

In this section we will use numerical examples to test the fast sweeping algorithm and to verify the analysis in previous sections. We can compute the distance function only in a narrow neighborhood of the data set as is described in Section 2 if needed, which saves an order of magnitude of computational cost.

For computing the distance function to a set of discrete points, we use the following procedure for the initialization step. First initialize the distance value of all grid points to be a large value, which should be larger than the maximum possible values for our later computed distance value in the domain. Then go through each data point and update the distance values of its neighboring grid points. For example, for each data point we find the grid cell that contains it and then compute the exact distance value of vertices of the grid cell to the data point. We replace the current values of these vertices whenever distance to this data point provides a smaller value. Of course we can include more neighboring grid points for which the exact distance values are computed. In our calculations, distance values are computed at grid points that are within two grid cells of the data set in the initialization step except for the first example. After going through all data points, we have computed exact distance values at those grid points in a neighborhood of the data set. All other grid points remain to have a large value. This procedure is of complexity for data points. In general we can find the global distance function to any data set as long as the distance values on grid points neighboring the set are provided or computed initially.

### Example 1

This example shows the interaction of two data points on a simple grid in two dimensions. Five iterations are needed for the fast sweeping algorithm to converge. However, changes after four iterations are no matter what size the grid is as we have tested. In Figure 6.1 we show the results after each iteration on a grid. The two data points are grid points at . For this example, we scale the grid size to be 1. Initially, as is shown in Table 6.1(a), we assign a large enough number (100 is enough for this grid) to grid points that are not data points and assign zero to those two data points. Table 6.1(b) shows the numerical solution after the first sweep, . Table 6.1(c)â€“(f) shows the numerical solution after second, third, fourth and fifth sweep. Table 6.2 shows the maximum change between each sweep. The changes in the first four sweeps are significant since every time there are grid points whose values change from their initial (large) assignments to the correct values. The change between fourth sweep and fifth sweep, which is caused by the interaction of two points when their characteristics intersect at the Voronoi cell boundary, is much less than ( in this case). For tests with different grid sizes and different locations of two data points, it may take more than five iterations to converge but changes after four iterations are always small. Table 6.1(g) shows the exact distance function. Those underlined numerical values in Table 6.1(e) show where the numerical solution is smaller than the exact distance function due to the interaction of these two data points. Table 6.1(h) shows the Voronoi diagram according to the numerical solutions of the distance function to each single data point, as is explained in Section 4. The integer at each grid point shows to which data point it is closer. We see the interaction occurs exactly at the Voronoi boundary. All these numerical results agree with our analysis.

### Example 2

In this example we compute the distance function to discrete points in both two and three dimensions to test the convergence and accuracy of the fast sweeping method. In the first case we have a single data point in both two and three dimensions. The domain is a unit square/cube. The data point is located at in two dimensions and in three dimensions. Table 6.3 shows errors measured in different norms with different grid sizes. For one single point the fast sweeping method converges exactly in four sweeps in two dimensions and in eight sweeps in three dimensions.

In the second case, we generate a set of 100 random points in a unit square in two dimensions and in a unit cube in three dimensions. In two dimensions it takes up to eight sweeps to converge. In three dimensions it takes up to 20 sweeps to converge. We show in Table 6.4 the errors after four sweeps in two dimensions and eight sweeps in three dimensions.

### Example 3

In this example we compute the distance function to two continuous sets, four linked circles in two dimensions and four spheres in three dimensions. Again it takes more than four sweeps in two dimensions and eight sweeps in three dimensions to converge in both cases. We show errors after four sweeps in two dimensions and eight sweeps in three dimensions in Table 6.5 In Figure 6.1 we show the contour plot of the numerical solution in two dimensions and a particular contour in three dimensions.

### Example 4

In this example we present two cases for general Eikonal equations. In the first case we show convergence and order of accuracy of the fast sweeping algorithm. The exact solution is

where . Also, is computed explicitly and is used as the given . The boundary condition is at the circle . We use the exact values of at grid points near the circle initially. We set the convergence criterion to be . The number of iterations and errors in different norms are shown in Table 6.6. We see that the number of iterations is independent of grid size. The contour plot of the solution is shown in Figure 6.2.

Note that the errors in all norms show first order convergence. This is due to the fact that the boundary, i.e., the initial wave front, is smooth. The only singularity is at the center where . However, characteristics flow into the singularity; i.e., the error at the singularity is determined by the error around it. This is contrary to the case where the boundary has singularities; e.g., the boundary is a single point or there are corners at the boundary. In this case characteristics flow out of the singularities of the boundary. Hence numerical errors made at singularities will propagate out and can accumulate, which gives a global error of order just as in the case for the distance function to a single point.

In the second case we compute the first arrival time for a point source at . The Eikonal equation is

So the corresponding velocity field is and the ratio between the maximum velocity and the minimum velocity is . The function is shown in Figure 6.3(a). In Figure 6.3(b) the solid line is the contour plot of the arrival time and the dashed line is the contour plot of . The largest difference between two consecutive iterations is shown in Table 6.7. We set the initial large value to be . The convergence criterion is the maximum difference between two consecutive iterations less than . Although six to seven iterations are needed for this convergence criterion for different grids, we can see clearly from this table that only the first six iterations are essential. After six iterations, the difference drops dramatically and is much smaller than the grid size. This means that it takes six iterations to cover the information propagation along all characteristic curves in the computation domain. This pattern is independent of grid size. The computing time scales linearly with the grid size. For this example, it only takes 0.2 seconds for the computation on a grid using a 2.4 GHz PC.

### Example 5

We present a potential application for function reconstruction. In theory, for a function , if all local minima (or maxima) of together with its gradient are known, we can reconstruct the function by solving the Eikonal equation with the prescribed local minima (or maxima) as the boundary condition. Here we apply this idea to the reconstruction of a discrete function. Suppose is a two dimensional discrete function defined at grid points . We first search for all local minima. is a local minimum if . We record the location, , and the value . Next we extract the gradient information at points that are not local minima. In order to construct the exact inverse process for our fast sweeping algorithm, we use upwind difference to compute the gradient at a grid point as follows. Let

Define

and

By enforcing the values at the minima and solving the system (Equation2.2), we can recover to machine precision. In regions where is constant, . Here we show the reconstruction of the peak function and the hat function in Matlab. For the peak function, there are six local minimal grid points and it takes 10 iterations to converge. The reconstruction is exact to machine precision and is shown in Figure 6.4(a). For the hat function, there are many local minima due to the valleys and the number of minima scales with the number of grid points. It takes seven iterations to converge. The reconstruction is also exact to machine precision and is shown in Figure 6.4(b).

### Example 6

As the last example, we present an application of the distance function in computer visualization. In Reference20, efficient algorithms are developed to analyze and visualize large sets of unorganized points using the distance function and distance contours. In particular, an appropriate distance contour can be extracted very quickly for the visualization of the data set, which avoids sorting out complicated ordering and connections among all data points. Figure 6.5 shows the visualization of a Buddha statue using a distance contour on a grid from points obtained by a laser scanner. The data set has 543,652 points and is obtained from The Stanford 3D Scanning Repository. The whole process takes a few seconds due to the fast computation of the distance function.

## Acknowledgment

The author would like to thank Dr. Paul Dupuis for some interesting discussions that started the work.

Figure 2.1.
Figure 2.2.
Figure 4.1.
Figure 4.2.
Figure 4.3.
Figure 5.1.
Table 6.1.
Table 6.2.
Table 6.3.
Table 6.4.
Table 6.5.
Figure 6.1.
Figure 6.2.
Figure 6.3.
Table 6.6.
Table 6.7.
Figure 6.4.
Figure 6.5.

## Mathematical Fragments

Equation (2.1)
Equation (2.2)
Equation (2.3)
Equation (2.5)
Equation (2.6)
Equation (2.7)
Equation (2.8)
Lemma 3.1

Let be the solution to equation Equation2.5. We have

and

Proposition 3.2

In the Gauss-Seidel iteration for the fast sweeping method, the maximum change of at any grid point is less than or equal to the maximum change of at its neighboring points.

Lemma 3.3

The fast sweeping algorithm is monotone in the initial data.

Corollary 3.5

Let and be two numerical solutions at the -th iteration of the fast sweeping algorithm. Let be the maximum norm. We have

(1) ,

(2) .

Theorem 3.6

The iterative solution by the fast sweeping algorithm converges monotonically to the solution of the discretized system.

Theorem 4.1

For a single data point , the numerical solution, , of the fast sweeping method converges in sweeps in and satisfies

where is the distance function to .

Equation (4.2)
Theorem 4.3

For an arbitrary set of discrete points , the numerical solution by the fast sweeping method after sweeps, satisfies

Equation (4.7)
Equation (4.8)
Example 1

This example shows the interaction of two data points on a simple grid in two dimensions. Five iterations are needed for the fast sweeping algorithm to converge. However, changes after four iterations are no matter what size the grid is as we have tested. In Figure 6.1 we show the results after each iteration on a