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 Ansichten (letzte 30 Tage)
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 Kommentare
Torsten
Torsten am 10 Nov. 2024
Bearbeitet: Walter Roberson am 11 Nov. 2024
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 am 11 Nov. 2024
Thankyou sir, i understood how big mistake I did, Thankyou soo much for your explanation, I'm really with that

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 11 Nov. 2024
Bearbeitet: John D'Errico am 11 Nov. 2024
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 Kommentare
Steven Lord
Steven Lord am 11 Nov. 2024
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 am 11 Nov. 2024
Thankyou sir, i understood how big mistake I did, Thankyou soo much for your explanation, I'm really with that.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by