I have some values which are close to zero (such as e^(-800) ) , and when i run my code, MATLAB rounds off these values to zero.How to prevent this from happening
Past the epsilon of the datatype, it becomes an approximation. It's approximately zero. Also, the path to zero probably has some very large errors at the end. Matlab seems to have arbitrary-precision support in their Symbolic Math Toolbox.
Past the epsilon of the datatype, it becomes an approximation. It's approximately zero. Also, the path to zero probably has some very large errors at the end. Matlab seems to have arbitrary-precision support in their Symbolic Math Toolbox.
Bjorn is totally right. If all your values are in that range you can just multiply them by 1e800 to prevent the rounding. Otherwise, if the values you are interested in are somewhere near 1 or higher do you really think that it matters if the value is 0 or 1e-800? So, I would advice to normalize your values to one. In any case, if you compute numeric values there is always a limit on the number of digits that are correctly reproduced.
Bjorn is right and when it comes to number crunching, what Sascha has written makes sense. However, you can use variable precision accuracy while doing symbolic computation. Take a look at the following:
Since you are in Electrical Engineering, I wonder if you are perhaps performing a calculation something like y = x - W(exp(x)) where W() is the Lambert W function ?
If so, then I can suggest an alternative formula (procedure) which will possibly avoid the underflow in your calculation.