This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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)
a =
ans =
b = vpa(pi)
b =
ans =
ans =
ans =
Functions Usedsymvpa
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.