## Hv J k

where A = ^ 1 + p2 + q2 — p. Substituting (5.27) and (5.28), we have

A Ii, j = p0( Zi+i, j — Zi, j) + qk"( Zi' j+i — Zi' j)-

Solving for Zi, j+1, we have

Zi, j+i = —a Zi+i, j + (a + 1) Zi, j + p j, where a = phk, P = qA, i = 0,...,n — 2, Z^ = gi(xi) and Zn—i, j = g2( yj), j =

 Z0,j+1 Z1,j+1 = Zn—2, j+1
 I0,j 0 + P Iij + 0 In—2, j — a Zn— 1 , j

Figure 5.1 shows the discretization we are using.

The finite difference scheme (5.29) is called the explicit method since it is given by an iterative formula. If instead, the central (5.25) and forward difference formulas (5.23) are used to approximate the partial derivatives, an implicit finite difference scheme can be derived. The approximate solution is then derived iteratively by using the iteration formula (5.29). Numerical Figure 5.1: The grid mesh for the discretization in Example 3.

methods used to solve these matrix equations, for example, the Jacobi method, can be found in the standard numerical analysis textbooks .

For a nonlinear shape from shading model (5.5), we have to linearize the reflectance map by using Taylor expansion to get a linear equation and then apply the FDM in a similar way as in the above example. To linearize the equation, we only need to replace the nonlinear part in Eq. (5.2) by its linear approximation. We first rewrite the equation to separate the linear and nonlinear parts:

I(x, y)yjl + p0 + qoy 1 + p2 + q2 = P(1 + pop + qoq)■ (5.30)

Denoting the nonlinear part by

F(p, q) :=V 1 + p2 + q2, the Taylor expansion of F(p, q) at (p, q) is