digits
Sets or reports the precision, in decimal digits, used by vpa.
Category: Mathematics > Numbers and Precision
Syntax
digits
Prints the current precision (32 by default).
digits(d)
Sets the precision to d decimal digits.
d = digits
Returns the current precision as a double.
Description
digits controls how many significant digits vpa uses for variable-precision arithmetic. The setting is global for the session, so changing it affects every later vpa call that does not give its own precision. A larger value gives more accurate results at the cost of speed.
The precision of vpa(x, d) with an explicit d overrides the global value for that call only. An argument that is not a positive integer is an error.
Input arguments
d- Positive integer number of significant decimal digits.
Output arguments
d- The current number of digits, as a double.
Example
Change the precision
digits(10);
vpa(sym(pi))
d = digits
digits(32);
vpa(sym(pi))
Output
ans = 3.141592654
d = 10
ans = 3.1415926535897932384626433832795