HI, while doing a small calculation part, from my class note, in matlab, im getting the result as inf, can i know how to convert the inf value into realnumbers.

조회 수: 2 (최근 30일)
T = 3500*10^3
T = 3500000
tau = 50
tau = 50
k = 0.4
k = 0.4000
Do = 3^sqrt((16*T)/(tau*pi*((1-k)^4)))
Do = Inf
Di = D0*k
Unrecognized function or variable 'D0'.
  댓글 수: 2
Torsten
Torsten 2024년 11월 10일
편집: Walter Roberson 2024년 11월 11일
T = sym('3500e3')
tau = sym('50')
k = sym('0.4')
Do = vpa(3^sqrt((16*T)/(tau*pi*((1-k)^4))))
disp(char(Do))
2.162387380150843961067546696359e+791
Bharath
Bharath 2024년 11월 11일
Thankyou sir, i understood how big mistake I did, Thankyou soo much for your explanation, I'm really with that

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

답변 (1개)

John D'Errico
John D'Errico 2024년 11월 11일
편집: John D'Errico 2024년 11월 11일
Of course D0 is undefined. You created the variable Do. There is a difference between the number 0 and the letter o.
That Do is inf is another issue.
T = 3500*10^3
T = 3500000
tau = 50
tau = 50
k = 0.4
k = 0.4000
k = 0.4000
k = 0.4000
Do = 3^sqrt((16*T)/(tau*pi*((1-k)^4)))
Do = Inf
So you are trying to raise the number 3 to what power?
sqrt((16*T)/(tau*pi*((1-k)^4)))
ans = 1.6586e+03
What is 3^1658 power? A REALLY LARGE NUMBER. Do you understand just how large?
vpa(sym(3)^sqrt((16*T)/(tau*pi*((1-k)^4))))
Are you absolutely certain that you wanted to compute this? Vastly more than the number of elementary particles in the known universe.
Possibly your intent was to multiply that by 3, and not raise 3 to that power. We don't know, at least not until we can get the mind reading toolbox in working order. It is just such a buggy thing. ;-)
3*sqrt((16*T)/(tau*pi*((1-k)^4)))
ans = 4.9757e+03
  댓글 수: 2
Steven Lord
Steven Lord 2024년 11월 11일
What is 3^1658 power? A REALLY LARGE NUMBER. Do you understand just how large?
In case the original poster doesn't understand, let's look at how many digits would be required to write out that number.
numDigits1 = 1658*log10(3)
numDigits1 = 791.0670
How many would be required to write the largest finite double precision number?
numDigits2 = log10(realmax)
numDigits2 = 308.2547
So yes, this definitely overflows to infinity. Using Symbolic Math Toolbox would be one approach you could use to compute that number, but depending on what you're planning to do with it (dividing by another number of similar magnitude?) you may be able to avoid computing such large numbers. For example,
nchoosek(400, 5)
ans = 8.3219e+10
Now if we computed nchoosek naively, we'd be dividing Inf by Inf as two of the three factorials involved overflow.
factorial([400 395]) % nchoosek(n, k) = n!/(k!*(n-k)!)
ans = 1×2
Inf Inf
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
But we don't. Recognize that we could compute n!/(n-k)! without actually computing each of the factorials in full, the numerator in nckhelper below.
nckhelper = @(n, k) (n:-1:(n-k+1))./(k:-1:1);
nck = @(n, k) prod(nckhelper(n, k));
nckhelper(400, 5)
ans = 1×5
80.0000 99.7500 132.6667 198.5000 396.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
nck(400, 5)
ans = 8.3219e+10
If you describe how you're hoping to use this number we may be able to suggest an alternate way to reach your goal without using nearly 800-digit long numbers.
Bharath
Bharath 2024년 11월 11일
Thankyou sir, i understood how big mistake I did, Thankyou soo much for your explanation, I'm really with that.

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by