MATLAB: NAN+inf

in my paper i need to calculate exp()…here in my code i got exp(4096) but due to this i am getting NAN+inf in all larger value areas..what to do for this?whether tis indicates any error or this NAN+inf for some values are acceptable?

Best Answer

Which MATLAB version are you using?
Please use size() and iscomplex() on the result variable to see if it is perhaps a complex number.
If you are contemplating using values that large, you should check to see if you can find a way to rewrite the calculation using the log of the values instead. That will not always be possible but when values that large are being discussed, it is not uncommon for there to be a log transformation of the problem.
exp(4096) is, by the way, approximately 7.416480782e1778
If you must use such large values and it is not possible to do a log transformation, then you probably need to use the symbolic toolbox, possibly with a large Digits setting.