I am trying to plot a function
T = (exp(x) + 1)/(exp(x) - 1)
where x ranges from say -10000 to 10000. Since exp(x) will be very large, the MATLAB is giving NaN instead of actual values. How to overcome this?
Thank you.
MATLABnan
T = (exp(x) + 1)/(exp(x) - 1)
Best Answer
You can use an alternate formula for the large values:
Note that once x gets large enough (19), the ratio calculation becomes equivalent to the "first order" approximation 1 + 2/exp(x) because of the limits of double precision arithmetic.