Documentation

## Choose Symbolic or Numeric Arithmetic

Symbolic Math Toolbox™ operates on numbers by using either symbolic or numeric arithmetic. Numeric arithmetic is either variable precision or double precision. The following information compares symbolic, variable-precision, and double-precision arithmetic.

SymbolicVariable PrecisionDouble Precision
Example: Find sin(π)
```a = sym(pi) sin(a)```
```a = pi ans = 0```
```b = vpa(pi) sin(b)```
```b = 3.1415926535897932384626433832795 ans = -3.2101083013100396069547145883568e-40```
```pi sin(pi)```
```ans = 3.1416 ans = 1.2246e-16```
Functions Used`sym``vpa`
`digits`
`double`
Round-Off ErrorsNo, finds exact resultsYes, magnitude depends on precision usedYes, has 16 digits of precision
SpeedSlowestFaster, depends on precision usedFaster
Memory UsageGreatestAdjustable, depends on precision usedLeast

### Symbolic Arithmetic

By default, Symbolic Math Toolbox uses exact numbers, such as `1/3`, `sqrt(2)`, or `pi`, to perform exact symbolic computations.

### Variable-Precision Arithmetic

Variable-precision arithmetic using `vpa` is the recommended approach for numeric calculations in Symbolic Math Toolbox. For greater precision, increase the number of significant digits. For faster computations and decreased memory usage, decrease the number of significant digits.

### Double-Precision Arithmetic

Double-precision, floating-point arithmetic uses the same precision as most numeric computations in MATLAB®. This arithmetic is recommended when you do not have Symbolic Math Toolbox or are using functions that do not accept symbolic input. Otherwise, exact symbolic numbers and variable-precision arithmetic are recommended. To approximate a value with double precision, use the `double` function.

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos