Main Content

laplacian

Laplacian of symbolic field

Description

example

l = laplacian(f,v) returns the Laplacian of the symbolic field f with respect to the vector v in Cartesian coordinates. If f is an array, then the function computes the Laplacian for each element of f and returns the output l that is the same size as f.

example

l = laplacian(f) returns the Laplacian of the symbolic field f with respect to a default vector constructed from the symbolic variables in f.

Examples

collapse all

Create a symbolic function for the scalar field f(x,y,z)=sin(x)+y2+z3. Compute the Laplacian of this function with respect to the vector (x,y,z).

syms x y z
f(x,y,z) = sin(x) + y^2 + z^3;
v = [x y z];
lf = laplacian(f,v)
lf(x, y, z) = 6z-sin(x)+2

Create another scalar field g(x,y,z)=x2y+z. Find the Laplacian without specifying the vector to differentiate with. Because g is a function of symbolic scalar variables, laplacian finds the Laplacian of g with respect to the default variables as defined by symvar(g).

g(x,y,z) = x^2*y + z;
lg = laplacian(g)
lg(x, y, z) = 2y

Since R2023a

Create a symbolic vector field F=[sin(x)+y2+z3x2y+z2]. Find the Laplacian of this vector field with respect to (x,y,z).

syms x y z
F = [sin(x) + y^2 + z^3; x^2*y + z];
v = [x y z];
l = laplacian(F,v)
l = 

(6z-sin(x)+22y)

Since R2023a

Create a 3-by-1 vector as a symbolic matrix variable X. Create a scalar field that is a function of X as a symbolic matrix function ψ(X), keeping the existing definition of X.

syms X [3 1] matrix
syms psi(X) [1 1] matrix keepargs

Show that the divergence of the gradient of ψ(X) is equal to the Laplacian of ψ(X), that is XXψ(X)=ΔXψ(X).

divOfGradPsi = divergence(gradient(psi,X),X)
divOfGradPsi(X) = ΔX ψ(X)
lapPsi = laplacian(psi,X)
lapPsi(X) = ΔX ψ(X)

Create a vector field that is a function of X as a symbolic matrix function A(X).

syms A(X) [3 1] matrix keepargs

Show that the gradient of the divergence of A(X) minus the curl of the curl of A(X) is equal to the Laplacian of A(X), that is XXA(X)-X×X×A(X)=ΔXA(X).

identityA = gradient(divergence(A,X),X) - curl(curl(A,X),X)
identityA(X) = ΔX A(X)

Input Arguments

collapse all

Symbolic field, specified as a symbolic expression, symbolic function, symbolic matrix variable, or symbolic matrix function. The input field can be a scalar, vector, matrix, or a multidimensional array, where the Laplacian is computed for each element in the input.

  • If f is a function of symbolic scalar variables, where f is of type sym or symfun, then the vector v must be of type sym or symfun.

  • If f is a function of symbolic matrix variables, where f is of type symmatrix or symfunmatrix, then the vector v must be of type symmatrix or symfunmatrix.

Data Types: sym | symfun | symmatrix | symfunmatrix

Vector with respect to which you find the Laplacian, specified as a vector of symbolic scalar variables, symbolic function, symbolic matrix variable, or a symbolic matrix function.

  • If you do not specify v and f is a function of symbolic scalar variables, then, by default, laplacian constructs vector v from the symbolic scalar variables in f with the order of variables as defined by symvar(f).

  • If v is a symbolic matrix variable of type symmatrix, then v must have a size of 1-by-N or N-by-1.

  • If v is scalar, then laplacian(f,v) = diff(f,2,v).

Data Types: sym | symfun | symmatrix | symfunmatrix

Limitations

  • Symbolic Math Toolbox™ currently does not support the dot or cross functions for symbolic matrix variables and functions of type symmatrix and symfunmatrix. If vector calculus identities involve dot or cross products, then the toolbox displays those identities in terms of other supported functions instead. To see a list of all the functions that support symbolic matrix variables and functions, use the commands methods symmatrix and methods symfunmatrix.

  • If the input data type of the symbolic field f is symmatrix or symfunmatrix, then laplacian does not evaluate the partial derivatives of f. Instead, it returns an unevaluated formula for symbolic manipulation and formula rearrangement.

More About

collapse all

Laplacian

The Laplacian or Laplace's differential operator of the scalar field f with respect to the vector x = (x1,...,xn) is the sum of the second derivatives of f with respect to x1,...,xn.

Δxf=i=1n2fxi2

If f is a vector field or a tensor field (multidimensional array), then the Laplacian operator is applied to each element in f.

Alternatives

The Laplacian of a scalar function or functional expression is the divergence of the gradient of that function or expression.

Δf=(f)

For a symbolic scalar field f, you can also compute the Laplacian using the divergence and gradient functions.

syms f(x,y)
divergence(gradient(f(x,y)),[x y])

Version History

Introduced in R2012a

expand all