MATLAB: How to get compute large numbers

digits limitationMATLAB

How can I get Matlab to compute
x = (8866128975287528)^3 + (-8778405442862239)^3 + (-2736111468807040)^3
and get the correct answer of x = 33?

Best Answer

x = sym(8866128975287528)^3 + sym(-8778405442862239)^3 + sym(-2736111468807040)^3
However, when you start working with numbers that large, you should start using,
x = sym('8866128975287528')^3 + sym('-8778405442862239')^3 + sym('-2736111468807040')^3
Note that this requires the Symbolic Toolbox.
You could also look in the File Exchange for John D'Errico's VPI toolbox.