Recall, the Laplacian of a function F of n variables x1,…,xn is
∇2(F)= |
| + |
| + ⋯+ |
|
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;
|
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 −y(a + (k−1)Δ x) + 2 y(a + kΔ x) − y (a + (k−1)Δ x) (implicitly assuming that y(a) = y(a + (N+1)Δ x) = 0), 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:
Example
Find the Laplacian of F(x,y,z)=2x2y−xz3.
Input:
Output:
−6 x z+4 y |
To compute the discrete Laplacian matrix:
Examples.
⎡ ⎢ ⎢ ⎣ |
| ⎤ ⎥ ⎥ ⎦ |
⎡ ⎢ ⎣ |
| ⎤ ⎥ ⎦ |