Laplacian

### 12.7.2 Laplacian

Recall, the Laplacian of a function F of n variables x1,…,xn is

∇2(F)= |
∂2 F
∂ x12
| + |
∂2 F
∂ x22
| + ⋯+ |
∂2 F
∂ xn2
| .

Also, the n× n discrete Laplacian matrix (also called the second difference matrix) is the n × n tridiagonal matrix with 2s on the main diagonal, −1s just above and below the main diagonal;

⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
2 | −1 | 0 | ⋯ | 0
−1 | 2 | −1 | ⋯ | 0
⋮ | ⋱ | ⋱ | ⋱ | ⋮
0 | ⋯ | −1 | 2 | −1
0 | ⋯ | 0 | −1 | 2
| ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦

If L is the n× n discrete Laplacian matrix and Y is an n × 1 column vector whose kth coordinate is yi=y(a+kΔ x) for a twice differential function y, then the kth coordinate of L Y will be (implicitly assuming that y(a)=y(a+(N+1)Δ x)=0):

−y(a+(k−1)Δ x)+2 y(a+kΔ x)−y (a+(k−1)Δ x),

which approximates y′′(a+kΔ x). So L Y is approximately −Δ x2 Y′′, where Y′′ is the n × 1 column vector whose kth coordinate is y′′(a+kδ x).

The laplacian command can compute the Laplacian operator or the discrete Laplacian matrix.

- To compute the Laplacian operator, laplacian takes two arguments:
  - expr, an expression involving several variables.
  - vars, a list of the variable names.
- laplacian(expr,vars) returns the Laplacian of the expression.
- To compute the discrete Laplacian matrix, laplacian takes n, an integer or floating-point integer.
- laplacian(n) returns the n× n discrete Laplacian matrix.

#### Examples

Find the Laplacian of F(x,y,z)=2x2y−xz3.

laplacian(2*x^2*y-x*z^3,[x,y,z])

−6 x z+4 y |  |  |  |  |  |  |  |  |  |

laplacian(3)

⎡ ⎢ ⎢ ⎣ |
2 | −1 | 0
−1 | 2 | −1
0 | −1 | 2
| ⎤ ⎥ ⎥ ⎦

laplacian(2.0)

⎡ ⎢ ⎣ |
2.0 | −1.0
−1.0 | 2.0
| ⎤ ⎥ ⎦