Main Content

curl

Curl of symbolic vector field

Description

example

c = curl(V,X) returns the curl of symbolic vector field V with respect to vector X in three-dimensional Cartesian coordinates. Both the vector field V and the vector X must be vectors with three components.

c = curl(V) returns the curl of the vector field V with respect to a default vector constructed from the symbolic variables in V.

Examples

collapse all

Find the curl of the vector field V(x,y,z)=(x3y2z,y3z2x,z3x2y) with respect to vector X=(x,y,z) in Cartesian coordinates.

syms x y z
V = [x^3*y^2*z, y^3*z^2*x, z^3*x^2*y];
X = [x y z];
c = curl(V,X)
c = 

(x2z3-2xy3zx3y2-2xyz3y3z2-2x3yz)

Find the curl of a 2-D vector field F(x,y)=(cos(x+y),sin(x-y),0). Plot the vector field as a quiver (velocity) plot and the z-component of its curl as a contour plot.

Create the 2-D vector field F(x,y) and find its curl. The curl is a vector with only the z-component.

syms x y z
F = [cos(x+y) sin(x-y) 0];
c = curl(F,[x,y,z])
c = 

(00cos(x-y)+sin(x+y))

Plot the 2-D vector field F(x,y) for the region -2<x<2 and -2<y<2. MATLAB® provides the quiver plotting function for this task. The function does not accept symbolic arguments. First, replace symbolic variables in expressions for components of F with numeric values. Then use quiver.

v = -2:0.1:2;
[xPlot,yPlot] = meshgrid(v);
Fx = subs(F(1),{x,y},{xPlot,yPlot});
Fy = subs(F(2),{x,y},{xPlot,yPlot});
quiver(xPlot,yPlot,Fx,Fy)
hold on

Next, plot the contour of the z-component of the curl using contour.

cPlot = subs(c(3),{x,y},{xPlot,yPlot});
contour(xPlot,yPlot,cPlot,"ShowText","on")
title("Contour Plot of Curl of 2-D Vector Field")
xlabel("x")
ylabel("y")

Figure contains an axes object. The axes object with title Contour Plot of Curl of 2-D Vector Field, xlabel x, ylabel y contains 2 objects of type quiver, contour.

Since R2023a

Derive the electromagnetic wave equation in free space without charge and without current sources from Maxwell's equations.

First, create symbolic scalar variables to represent the vacuum permeability and permittivity. Create a symbolic matrix variable to represent the Cartesian coordinates. Create two symbolic matrix functions to represent the electric and magnetic fields as functions of space and time.

syms mu_0 epsilon_0
syms X [3 1] matrix
syms E(X,t) B(X,t) [3 1] matrix keepargs

Next, create four equations to represent Maxwell's equations.

Maxwell1 = divergence(E,X) == 0
Maxwell1(X, t) = X·E(X,t)=01,1
Maxwell2 = curl(E,X) == -diff(B,t)
Maxwell2(X, t) = 

X×E(X,t)=-t B(X,t)

Maxwell3 = divergence(B,X) == 0
Maxwell3(X, t) = X·B(X,t)=01,1
Maxwell4 = curl(B,X) == mu_0*epsilon_0*diff(E,t)
Maxwell4(X, t) = 

X×B(X,t)=ε0μ0t E(X,t)

Then, find the wave equation for the electric field. Compute the curl of the second Maxwell equation.

wave_E = curl(Maxwell2,X)
wave_E(X, t) = 

X X·E(X,t)-ΔX E(X,t)=-X×t B(X,t)

Substitute the first Maxwell equation in the electric field wave equation. Use lhs and rhs to obtain the left and right sides of the first Maxwell equation.

wave_E = subs(wave_E,lhs(Maxwell1),rhs(Maxwell1))
wave_E(X, t) = 

-ΔX E(X,t)=-X×t B(X,t)

Compute the time derivative of the fourth Maxwell equation.

dMaxwell4 = diff(Maxwell4,t)
dMaxwell4(X, t) = 

X×t B(X,t)=ε0μ0t t E(X,t)

Substitute the term that involves the magnetic field X×tB(X,t) in wave_E with the right side of dMaxwell4. Use lhs and rhs to obtain these terms from dMaxwell4.

wave_E = subs(wave_E,lhs(dMaxwell4),rhs(dMaxwell4))
wave_E(X, t) = 

-ΔX E(X,t)=-ε0μ0t t E(X,t)

Using similar steps, you can also find the wave equation for the magnetic field.

wave_B = curl(Maxwell4,X)
wave_B(X, t) = 

X X·B(X,t)-ΔX B(X,t)=ε0μ0X×t E(X,t)

wave_B = subs(wave_B,lhs(Maxwell3),rhs(Maxwell3))
wave_B(X, t) = 

-ΔX B(X,t)=ε0μ0X×t E(X,t)

dMaxwell2 = diff(Maxwell2,t)
dMaxwell2(X, t) = 

X×t E(X,t)=-t t B(X,t)

wave_B = subs(wave_B,lhs(dMaxwell2),rhs(dMaxwell2))
wave_B(X, t) = 

-ΔX B(X,t)=-ε0μ0t t B(X,t)

Input Arguments

collapse all

Three-dimensional symbolic vector field, specified as a vector of symbolic scalar variables, symbolic function, symbolic matrix variable, or symbolic matrix function. V must have a size of 1-by-3 or 3-by-1.

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

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

Data Types: sym | symfun | symmatrix | symfunmatrix

Three-dimensional vector with respect to which you find the curl, specified as a vector of symbolic scalar variables, symbolic function, symbolic matrix variable, or symbolic matrix function. X must have a size of 1-by-3 or 3-by-1.

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

Data Types: sym | symfun | symmatrix | symfunmatrix

Limitations

  • The curl function does not support tensor derivatives. If the input V is a tensor field or a matrix rather than a vector, then the curl function returns an error.

  • 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.

More About

collapse all

Curl of Symbolic Vector Field

The curl of the symbolic vector field V = (V1, V2, V3) with respect to the vector X = (X1, X2, X3) in Cartesian coordinates is this vector.

curl(V)=X×V=(V3X2V2X3V1X3V3X1V2X1V1X2)

Version History

Introduced in R2012a

expand all