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

조회 수: 7(최근 30일)
Shiksha Pandey
Shiksha Pandey 2021년 3월 24일
댓글: Rik 2021년 3월 24일
Using double precision, find x for which exp(x) doesn't overflow.
  댓글 수: 4
Rik
Rik 2021년 3월 24일
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?

댓글을 달려면 로그인하십시오.

답변(1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 24일
편집: KALYAN ACHARJYA 2021년 3월 24일
All data creates in MATLAB are douple precision (Standard /By Default)
More:
e^x = 1 + (x ^ 1 / 1!) + (x ^ 2 / 2!) ......

Community Treasure Hunt

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

Start Hunting!

Translated by