MATLAB Answers

Using double precision, find x for which exp(x) doesn't overflow.

1 view (last 30 days)
Shiksha Pandey
Shiksha Pandey on 24 Mar 2021
Commented: Rik on 24 Mar 2021
Using double precision, find x for which exp(x) doesn't overflow.
  4 Comments
Rik
Rik on 24 Mar 2021
I don't really understand what you're attempting to do with the while loop, but yes, there is a faster way. It requires you to think a bit more.
log2(realmax)
ans = 1024
OK, so we are looking for x where e^x is at most 2^1024.
With a little bit of algebra that should not be too hard to solve. Can you see how?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by