フィルターのクリア

NaN (not a number) in numerical integration

10 ビュー (過去 30 日間)
Muna Tageldin
Muna Tageldin 2021 年 11 月 3 日
回答済み: Walter Roberson 2021 年 11 月 3 日
I am trying to integrate the following expression over the variable alpha
ep=0.2;
u=0.2;
lam=0.7;
n=1000;
f=@(alpha) power((1-ep+ep*exp(u^(-1)*alpha)),n).*lam^(-1).*exp(-lam^(-1)*alpha);
out = quad(f,0,Inf)
When I try to solve this, I get NaN value. How can I solve this problem?
Thanks
  2 件のコメント
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 11 月 3 日
Could you ples show your equation written in math formulation format (not MATLAB embedded code)?
Muna Tageldin
Muna Tageldin 2021 年 11 月 3 日

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 3 日
ep=0.2;
u=0.2;
lam=0.7;
n=1000;
f=@(alpha) power((1-ep+ep*exp(u^(-1)*alpha)),n).*lam^(-1).*exp(-lam^(-1)*alpha);
out = quad(f,0,Inf)
Warning: Infinite or Not-a-Number function value encountered.
out = NaN
syms A
fa = f(A)
fa = 
limit(fa, A, 0)
ans = 
limit(fa, A, inf)
ans = 
Look at your expression. You have an exponential in alpha, being raised to 1000. With alpha starting from 0, the expression being raised to 1000 has a minimum value of 1, so raising the value to 1000 is going to increase rapidly.
If you ignore the +4/5 then you can see that you have exp(-10/7 alpha) * exp(5000 alpha), which combines to roughly exp(4999 alpha). Clearly that is going to give you an infinite integral when you go as far as alpha = infinity

その他の回答 (1 件)

the cyclist
the cyclist 2021 年 11 月 3 日
Looks like your function becomes infinite. Here's a plot zooming in where it happens
ep=0.2;
u=0.2;
lam=0.7;
n=1000;
f=@(alpha) power((1-ep+ep*exp(u.^(-1).*alpha)),n).*lam.^(-1).*exp(-lam.^(-1).*alpha);
out = quad(f,0,Inf)
Warning: Infinite or Not-a-Number function value encountered.
out = NaN
a = 0.36:1.e-6:0.37;
figure
plot(a,f(a))

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by