numerical integration with quadgk, Matlab gives me a warning: Minimum step size reached near x = 3.67541e-008; singularity possible.
4 views (last 30 days)
Show older comments
Hello everyone,
When I use quadgk to integrate a function which has sugularity point是。
All I need is the value q2. I got the result from Matlab 0.6489. but the real result is 0.7070. So there is a significant difference between them. Could anybody help me to check the code and give me the advice which method do I need to use for the right result?
Thank you.
here is my code:
sigma = 0.31;
mu = -17.1043;
rc = 4e-8;
beta = 3.52e-9;
%Here are the intervals for integration
p1 = 0;
p2 = rc-beta;
p3 = rc;
p4 = rc+beta;
p5 = inf;
% Here is the integrand which has the singularity points inside
fun1=@(r)(1./(sigma.*sqrt(2.*pi))).*(1./r).*exp(-((log(r) - mu).^2)./(2.*sigma.^2));
q1=quad(fun1,p1,p2)% q1 works well
eps1=-0.0817e-7;
fun2=@(r)(1./(1+eps1.*(3/2).*(1./beta - ((2.*r+beta-2.*rc).^2)./(beta.^3))))...
.*(1./(sigma.*sqrt(2.*pi))).*(1./r).*exp(-((log(r) - mu).^2)./(2.*sigma.^2));
q2=q1+quadgk(fun2,p2,p3,'MaxIntervalCount',1e6)
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!