Is the speed of Variable Precision always faster than a Double Precision?
1 view (last 30 days)
Show older comments
I am reading the link below:
Is the speed of Variable Precision always faster than a Double Precision?
a=sym(pi);
b=vpa(pi, 3);
c=double(pi);
whos
Based on the code above, it seems that vpa always return a symbol. Does a symbol number always take on more memory space than a double number, which only takes on 64 digits?
2 Comments
Stephen23
on 13 Aug 2017
"a double number, which only takes on 64 digits?"
A double uses 64 bits. It does not have anywhere close to 64 decimal digits.
Answers (2)
John D'Errico
on 13 Aug 2017
Huh? What are you asking here? Your title asks one thing, but then your description asks something completely different.
ALMOST always, a variable precision operation will be seriously slower than double precision.
And a double does NOT comprise 64 digits. So you are seriously confused. A double uses 64 BITS of storage, which is something wildly different than the number of digits.
0 Comments
Walter Roberson
on 14 Aug 2017
Yes, a symbolic number always takes more space than a double.
Symbolic numbers are stored has handles to objects at the MATLAB level, so that requires 64 bits to store the handle alone. Then you have to add to that however-much space is used inside the symbolic engine to represent the value, and you have to add in the size of the character string that is the internal sym property that is used to tie together the MATLAB level and the symbolic engine level. Symbolic expressions can share storage inside the symbolic engine, so it is difficult to define how exactly much storage space is internally required for an expression at the symbolic engine level, and the storage details inside the symbolic engine are not documented.
However, considering that the handle alone takes 64 bits, you can be sure that every sym rational and every variable precision number requires more storage than a double requires.
For small numbers, on the order of 5 and 1, addition of symbolic numbers is about 40000 to 80000 times slower than addition for doubles.
2 Comments
Jan
on 14 Aug 2017
Internally a scalar uses 8 bytes plus about 100 bytes in the header, as well as the symbolic variable. I do not think, that this matters the problem of the OP Lisa Lee.
Walter Roberson
on 14 Aug 2017
The headers for scalar double and for sym should be the same size, I think.
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!