Why do I get a complex number of this integral?
12 views (last 30 days)
Show older comments
fun = @(y) y.^-0.5.*exp(-(y-0.01).^2./0.5);
theta = integral(fun,-Inf,Inf)
theta1 = quadgk(fun,-Inf,Inf)
theta =
1.5388 - 1.5097i
theta1 =
1.5388 - 1.5097i
0 Comments
Answers (2)
Torsten
on 30 Nov 2015
Your function "fun" is complex-valued if y < 0 because of the y^(-0.5) term.
Best wishes
Torsten.
0 Comments
Walter Roberson
on 30 Nov 2015
You have y.^-0.5 as a component of the expression. When y is negative, that is going to be an imaginary value. None of the other components are imaginary so there is nothing to "cancel" the imaginary component.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!