# Symbolic Math Toolbox Functions

## Symbolic Computations in MATLAB

### Symbolic Variables, Expressions, Functions, and Preferences

 argnames Input variables of symbolic function children Subexpressions or terms of symbolic expression disp Display symbolic input display Display symbolic input formula Mathematical expression defining symbolic function funtool Function calculator pretty Prettyprint symbolic expressions sympref Set symbolic preferences sym Create symbolic variables, expressions, functions, matrices symfun Create symbolic functions syms Shortcut for creating symbolic variables and functions symvar Find symbolic variables in symbolic expression, matrix, or function

### Operators and Elementary Operations

#### Arithmetic Operations

 minus Symbolic subtraction plus Symbolic addition times Symbolic array multiplication ldivide Symbolic array left division rdivide Symbolic array right division power Symbolic array power mtimes Symbolic matrix multiplication mldivide Symbolic matrix left division mrdivide Symbolic matrix right division mpower Symbolic matrix power transpose Symbolic matrix transpose ctranspose Symbolic matrix complex conjugate transpose ceil Round symbolic matrix toward positive infinity fix Round toward zero floor Round symbolic matrix toward negative infinity frac Symbolic matrix element-wise fractional parts mod Symbolic modulus after division quorem Quotient and remainder round Symbolic matrix element-wise round conj Symbolic complex conjugate imag Imaginary part of complex number real Real part of complex number cumprod Symbolic cumulative product cumsum Symbolic cumulative sum

#### Relational Operations

 eq Define equation ge Define greater than or equal to relation gt Define greater than relation le Define less than or equal to relation lt Define less than relation ne Define inequality in Numeric type of symbolic input isequaln Test symbolic objects for equality, treating NaN values as equal

#### Logical Operations

 and Logical AND for symbolic expressions not Logical NOT for symbolic expressions or Logical OR for symbolic expressions xor Logical XOR for symbolic expressions all Test whether all equations and inequalities represented as elements of symbolic array are valid any Test whether at least one of equations and inequalities represented as elements of symbolic array is valid in Numeric type of symbolic input isequaln Test symbolic objects for equality, treating NaN values as equal isfinite Check whether symbolic array elements are finite isinf Check whether symbolic array elements are infinite isnan Check whether symbolic array elements are NaNs logical Check validity of equation or inequality nnz Number of nonzero elements nonzeros Nonzero elements

### Conversion Between Symbolic and Numeric

 char Convert symbolic objects to strings double Convert symbolic matrix to MATLAB numeric form int8, int16, int32, int64 Convert symbolic matrix to signed integers poly2sym Create symbolic polynomial from vector of coefficients single Convert symbolic matrix to single precision sym Create symbolic variables, expressions, functions, matrices sym2poly Extract vector of all numeric coefficients, including zeros, from symbolic polynomial symfun Create symbolic functions uint8, uint16, uint32, uint64 Convert symbolic matrix to unsigned integers vpa Variable-precision arithmetic

## Mathematics

### Equation Solving

#### Linear and Nonlinear Equations and Systems

 equationsToMatrix Convert set of linear equations to matrix form finverse Functional inverse linsolve Solve linear system of equations given in matrix form poles Poles of expression or function solve Equations and systems solver vpasolve Numeric solver

#### Ordinary Differential Equations and Systems

 dsolve Ordinary differential equation and system solver massMatrixForm Extract mass matrix and right side of semilinear system of differential algebraic equations odeFunction Convert system of symbolic algebraic expressions to MATLAB function handle suitable for ode45, ode15s, and other ODE solvers odeToVectorField Convert higher-order differential equations to systems of first-order differential equations

#### Differential Algebraic Equations

 daeFunction Convert system of differential algebraic equations to MATLAB function handle suitable for ode15i decic Find consistent initial conditions for first-order implicit ODE system with algebraic constraints findDecoupledBlocks Search for decoupled blocks in systems of equations incidenceMatrix Find incidence matrix of system of equations isLowIndexDAE Check if differential index of system of equations is lower than 2 massMatrixForm Extract mass matrix and right side of semilinear system of differential algebraic equations odeFunction Convert system of symbolic algebraic expressions to MATLAB function handle suitable for ode45, ode15s, and other ODE solvers reduceDAEIndex Convert system of first-order differential algebraic equations to equivalent system of differential index 1 reduceDAEToODE Convert system of first-order semilinear differential algebraic equations to equivalent system of differential index 0 reduceDifferentialOrder Reduce system of higher-order differential equations to equivalent system of first-order differential equations reduceRedundancies Simplify system of first-order differential algebraic equations by eliminating redundant equations and variables

### Formula Manipulation and Simplification

#### Simplification

 simplify Algebraic simplification simplifyFraction Symbolic simplification of fractions subexpr Rewrite symbolic expression in terms of common subexpressions

#### Formula Rearrangement and Rewriting

 coeffs Coefficients of polynomial collect Collect coefficients combine Combine terms of identical algebraic structure compose Functional composition divisors Divisors of integer or expression expand Symbolic expansion of polynomials and elementary functions factor Factorization horner Horner nested polynomial representation numden Extract numerator and denominator partfrac Partial fraction decomposition rewrite Rewrite expression in new terms subexpr Rewrite symbolic expression in terms of common subexpressions

#### Substitution

 subexpr Rewrite symbolic expression in terms of common subexpressions subs Symbolic substitution

### Calculus

#### Differentiation

 diff Differentiate symbolic expression or function functionalDerivative Functional derivative

#### Integration

 int Definite and indefinite integrals rsums Interactive evaluation of Riemann sums

#### Vector Analysis

 curl Curl of vector field divergence Divergence of vector field gradient Gradient vector of scalar function hessian Hessian matrix of scalar function jacobian Jacobian matrix laplacian Laplacian of scalar function potential Potential of vector field vectorPotential Vector potential of vector field

#### Series

 cumprod Symbolic cumulative product cumsum Symbolic cumulative sum pade Padé approximant rsums Interactive evaluation of Riemann sums symprod Product of series symsum Sum of series taylor Taylor series expansion taylortool Taylor series calculator

#### Limits

 limit Compute limit of symbolic expression

#### Transforms

 fourier Fourier transform ifourier Inverse Fourier transform ilaplace Inverse Laplace transform iztrans Inverse Z-transform laplace Laplace transform sympref Set symbolic preferences ztrans Z-transform

### Linear Algebra

#### Matrix Operations and Transformations

 bernstein Bernstein polynomials bernsteinMatrix Bernstein matrix cat Concatenate symbolic arrays along specified dimension diag Create or extract diagonals of symbolic matrices expm Matrix exponential horzcat Concatenate symbolic arrays horizontally inv Compute symbolic matrix inverse pinv Moore-Penrose inverse (pseudoinverse) of symbolic matrix reshape Reshape symbolic array size Symbolic matrix dimensions sort Sort elements of symbolic vectors or matrices toeplitz Symbolic Toeplitz matrix tril Return lower triangular part of symbolic matrix triu Return upper triangular part of symbolic matrix vertcat Concatenate symbolic arrays vertically

#### Linear Equations

 cond Condition number of matrix det Compute determinant of symbolic matrix equationsToMatrix Convert set of linear equations to matrix form inv Compute symbolic matrix inverse linsolve Solve linear system of equations given in matrix form norm Norm of matrix or vector rank Find rank of symbolic matrix rref Reduced row echelon form of matrix (Gauss-Jordan elimination)

#### Matrix Decomposition

 chol Cholesky factorization jordan Jordan form of matrix lu LU factorization qr QR factorization svd Singular value decomposition of symbolic matrix

#### Eigenvalues and Eigenvectors

 charpoly Characteristic polynomial of matrix eig Eigenvalues and eigenvectors of symbolic matrix jordan Jordan form of matrix

#### Vector Spaces and Subspaces

 colon Create symbolic vectors, array subscripting, and for-loop iterators colspace Column space of matrix null Form basis for null space of matrix numel Number of elements of symbolic array orth Orthonormal basis for range of symbolic matrix rank Find rank of symbolic matrix rref Reduced row echelon form of matrix (Gauss-Jordan elimination) size Symbolic matrix dimensions

#### Matrix Analysis

 adjoint Adjoint of symbolic square matrix charpoly Characteristic polynomial of matrix cond Condition number of matrix curl Curl of vector field det Compute determinant of symbolic matrix divergence Divergence of vector field gradient Gradient vector of scalar function hessian Hessian matrix of scalar function jacobian Jacobian matrix laplacian Laplacian of scalar function minpoly Minimal polynomial of matrix norm Norm of matrix or vector potential Potential of vector field vectorPotential Vector potential of vector field

#### Matrix Functions

 expm Matrix exponential funm General matrix function logm Matrix logarithm sqrtm Matrix square root

### Assumptions

 assume Set assumption on symbolic object assumeAlso Add assumption on symbolic object assumptions Show assumptions affecting symbolic variable, expression, or function clear all Remove items from MATLAB workspace and reset MuPAD engine in Numeric type of symbolic input isAlways Check whether equation or inequality holds for all values of its variables isfinite Check whether symbolic array elements are finite isinf Check whether symbolic array elements are infinite isnan Check whether symbolic array elements are NaNs logical Check validity of equation or inequality reset Close MuPAD engine

### Polynomials

 charpoly Characteristic polynomial of matrix chebyshevT Chebyshev polynomials of the first kind chebyshevU Chebyshev polynomials of the second kind coeffs Coefficients of polynomial gegenbauerC Gegenbauer polynomials hermiteH Hermite polynomials jacobiP Jacobi polynomials laguerreL Generalized Laguerre Function and Laguerre Polynomials legendreP Legendre polynomials minpoly Minimal polynomial of matrix poly2sym Create symbolic polynomial from vector of coefficients sym2poly Extract vector of all numeric coefficients, including zeros, from symbolic polynomial

### Mathematical Functions

#### Constants

 catalan Catalan constant eulergamma Euler-Mascheroni constant

#### Logarithms

 log Natural logarithm of entries of symbolic matrix log10 Logarithm base 10 of entries of symbolic matrix log2 Logarithm base 2 of entries of symbolic matrix

#### Trigonometric Functions

 sin Symbolic sine function cos Symbolic cosine function tan Symbolic tangent function cot Symbolic cotangent function sec Symbolic secant function csc Symbolic cosecant function asin Symbolic inverse sine function acos Symbolic inverse cosine function atan Symbolic inverse tangent function acot Symbolic inverse cotangent function asec Symbolic inverse secant function acsc Symbolic inverse cosecant function

#### Hyperbolic Functions

 sinh Symbolic hyperbolic sine function cosh Symbolic hyperbolic cosine function tanh Symbolic hyperbolic tangent function coth Symbolic hyperbolic cotangent function sech Symbolic hyperbolic secant function csch Symbolic hyperbolic cosecant function asinh Symbolic inverse hyperbolic sine function acosh Symbolic inverse hyperbolic cosine function atanh Symbolic inverse hyperbolic tangent function acoth Symbolic inverse hyperbolic cotangent function asech Symbolic inverse hyperbolic secant function acsch Symbolic inverse hyperbolic cosecant function

#### Complex Numbers

 abs Absolute value of real or complex value angle Symbolic polar angle atan2 Symbolic four-quadrant inverse tangent imag Imaginary part of complex number real Real part of complex number sign Sign of real or complex value signIm Sign of the imaginary part of complex number

#### Special Functions

##### Dirac and Heaviside Functions
 dirac Dirac delta function heaviside Heaviside step function kroneckerDelta Kronecker delta function rectangularPulse Rectangular pulse function sympref Set symbolic preferences triangularPulse Triangular pulse function
##### Gamma Functions
 beta Beta function factorial Factorial function gamma Gamma function gammaln Logarithmic gamma function igamma Incomplete gamma function nchoosek Binomial coefficient pochhammer Pochhammer symbol
##### Zeta Function and Polylogarithms
 catalan Catalan constant dilog Dilogarithm function polylog Polylogarithm psi Digamma function zeta Riemann zeta function
##### Airy and Bessel Functions
 airy Airy function besseli Modified Bessel function of the first kind besselj Bessel function of the first kind besselk Modified Bessel function of the second kind bessely Bessel function of the second kind
##### Exponential and Trigonometric Integrals
 coshint Hyperbolic cosine integral function cosint Cosine integral function dawson Dawson integral ei One-argument exponential integral function eulergamma Euler-Mascheroni constant expint Exponential integral function fresnelc Fresnel cosine integral function fresnels Fresnel sine integral function logint Logarithmic integral function sinhint Hyperbolic sine integral function sinint Sine integral function ssinint Shifted sine integral function
##### Error Functions
 erf Error function erfc Complementary error function erfcinv Inverse complementary error function erfi Imaginary error function erfinv Inverse error function
##### Hypergeometric and Whittaker Functions
 hypergeom Hypergeometric function kummerU Confluent hypergeometric Kummer U function whittakerM Whittaker M function whittakerW Whittaker W function
##### Elliptic Integrals
 ellipke Complete elliptic integrals of the first and second kinds ellipticCE Complementary complete elliptic integral of the second kind ellipticCK Complementary complete elliptic integral of the first kind ellipticCPi Complementary complete elliptic integral of the third kind ellipticE Complete and incomplete elliptic integrals of the second kind ellipticF Incomplete elliptic integral of the first kind ellipticK Complete elliptic integral of the first kind ellipticPi Complete and incomplete elliptic integrals of the third kind
##### Lambert W and Wright Functions
 lambertw Lambert W function wrightOmega Wright omega function

### Numbers and Precision

#### Precision Control

 digits Variable-precision accuracy double Convert symbolic matrix to MATLAB numeric form vpa Variable-precision arithmetic

#### Operations on Numbers

 ceil Round symbolic matrix toward positive infinity conj Symbolic complex conjugate fix Round toward zero floor Round symbolic matrix toward negative infinity frac Symbolic matrix element-wise fractional parts imag Imaginary part of complex number max Largest elements min Smallest elements real Real part of complex number round Symbolic matrix element-wise round

### Number Theory

 bernoulli Bernoulli numbers and polynomials divisors Divisors of integer or expression euler Euler numbers and polynomials gcd Greatest common divisor harmonic Harmonic function (harmonic number) lcm Least common multiple mod Symbolic modulus after division quorem Quotient and remainder rem Remainder after division

## Graphics

### Function Plots

 ezcontour Contour plotter ezcontourf Filled contour plotter ezmesh 3-D mesh plotter ezmeshc Combined mesh and contour plotter ezplot Plot symbolic expression, equation, or function ezplot3 3-D parametric curve plotter ezpolar Polar coordinate plotter ezsurf Plot 3-D surface ezsurfc Combined surface and contour plotter

## Code Generation

 ccode C code representation of symbolic expression fortran Fortran representation of symbolic expression latex LaTeX representation of symbolic expression matlabFunction Convert symbolic expression to function handle or file matlabFunctionBlock Convert symbolic expression to MATLAB Function block simscapeEquation Convert symbolic expressions to Simscape language equations texlabel TeX representation of symbolic expression

## MATLAB and MuPAD Integration

### MuPAD Function Calls

 evalin Evaluate MuPAD expressions without specifying their arguments feval Evaluate MuPAD expressions specifying their arguments read Read MuPAD program file into symbolic engine