# Numerical Integration from -Inf to Inf

36 views (last 30 days)
Vira Roy on 5 Dec 2019
Commented: Vira Roy on 5 Dec 2019
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
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
Thanks.

Birdman on 5 Dec 2019
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.
Vira Roy on 5 Dec 2019
Birdman,
The graph is coming out to be fine, but what i was looking for was some specific value for the integral so that i can later plot that obtained result for varying values of gamma(which i have taken to be 3 here but plan to obtain a continous graph for all possible values of gamma)
Is there someway to do that from what you sugggested above.
Thank you, and sorry for being bit blunt here. You help is dearly appreciated.

### Categories

Find more on Getting Started with MuPAD in Help Center and File Exchange

R2016a

### Community Treasure Hunt

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

Start Hunting!