| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Symbolic Math Toolbox |
| Contents | Index |
| Learn more about Symbolic Math Toolbox |
| On this page… |
|---|
Symbolic objects are a special MATLAB® data type introduced by the Symbolic Math Toolbox™ software. They allow you to perform mathematical operations in the MATLAB workspace analytically, without calculating numeric values. You can use symbolic objects to perform a wide variety of analytical computations:
Differentiation, including partial differentiation
Definite and indefinite integration
Taking limits, including one-sided limits
Summation, including Taylor series
Matrix operations
Solving algebraic and differential equations
Variable-precision arithmetic
Integral transforms
Symbolic objects present symbolic variables, symbolic numbers, symbolic expressions and symbolic matrices.
To declare variables x and y as symbolic objects use the syms command:
syms x y
You can manipulate the symbolic objects according to the usual rules of mathematics. For example:
x + x + y
ans = 2*x + y
You also can create formal symbolic mathematical expressions and symbolic matrices. See Creating Symbolic Variables and Expressions for more information.
Symbolic Math Toolbox software also enables you to convert numbers to symbolic objects. To create a symbolic number, use the sym command:
a = sym('2')If you create a symbolic number with 10 or fewer decimal digits, you can skip the quotes:
a = sym(2)
The following example illustrates the difference between a standard double-precision MATLAB data and the corresponding symbolic number. The MATLAB command
sqrt(2)
returns a double-precision floating-point number:
ans =
1.4142On the other hand, if you calculate a square root of a symbolic number 2:
a = sqrt(sym(2))
you get the precise symbolic result:
a = 2^(1/2)
Symbolic results are not indented. Standard MATLAB double-precision results are indented. The difference in output form shows what type of data is presented as a result.
To evaluate a symbolic number numerically, use the double command:
double(a)
ans =
1.4142You also can create a rational fraction involving symbolic numbers:
sym(2)/sym(5)
ans = 2/5
or more efficiently:
sym(2/5)
ans = 2/5
MATLAB performs arithmetic on symbolic fractions differently than it does on standard numeric fractions. By default,MATLAB stores all numeric values as double-precision floating-point data. For example:
2/5 + 1/3
ans =
0.7333If you add the same fractions as symbolic objects, MATLAB finds their common denominator and combines them in the usual procedure for adding rational numbers:
sym(2/5) + sym(1/3)
ans = 11/15
To learn more about symbolic representation of rational and decimal fractions, see Estimating the Precision of Numeric to Symbolic Conversions.
![]() | Getting Started | Creating Symbolic Variables and Expressions | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |