Numerical Integration from -Inf to Inf
27 ビュー (過去 30 日間)
古いコメントを表示
Problem: I have the following integral which i need to evaluate numerically.
Now i have to do this for different values of c and γ, but for now let us say c=0.1 and
My attempt: After reading few already available answers and documentation, i tried the following
gamma =3;
fun = @(x) (x.*exp(-x.^2)).*(((x+0.1).^2) .* (exp(2.*(x+0.1).^2 .*gamma.^2)));
format long
q1 = integral(fun,-Inf,Inf,'RelTol',1e-8,'AbsTol',1e-13)
Result: The output i get is Nan
Any help or advice will be helpful to me.
Thanks.
0 件のコメント
回答 (1 件)
Birdman
2019 年 12 月 5 日
Try the symbolic approach and consider the problem as follows:
syms x
F(x)=x*(x+0.1)^2*exp(2*(x+0.1)^2*3^2)*exp(-x^2);
After this point, you need to break it down to two pieces while calculating integral:
INT1=int(F,x,-inf,0);
INT2=int(F,x,0,inf);
The sum of these two will give the correct result.
3 件のコメント
Birdman
2019 年 12 月 5 日
I think you don't miss anything. Just plot the function for some x values and see if -Inf and Inf outputs make sense or not:
x=-5:0.001:5;
plot(x,F(x))
参考
カテゴリ
Help Center および File Exchange で Get Started with MuPAD についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!