Minimums step size reached, while integrating.
Show older comments
Hello everyone, so I ran this piece of code and I got multiple warnings on reaching the minimum step size. I get a very dubious output. So i tried changing the sample size, but irrespective of me increasing or decreasing, I get the same warnings and get the same unsure output.
Here is the code I'm running -
f=15e8:(20e9-10e8)/100:16e9;
s=length(f);
epso = 8.8 *10.^-12;
epsr=5.7;
ro=3.63*(10.^-3);
epsl = 2.5;
ri=1.13*(10.^-3);
copen = (epso/sqrt(epsr)*log(ro/ri));
cload= (epsl/sqrt(epsr)*log(ro/ri));
t = zeros(1,s);
for i = 1:length(f)
fun = @(x)((((((besselj(0,(2*pi*f(i))/(3e8))*x*ro)-besselj(0,(2*pi*f(i))/(3e8))*x*ri)).^2)./x).*freload(x,f(i)));
y(i) = copen*abs(integral(fun,0,Inf,'arrayvalued',true));
t(i)=(1-y(i))/(1+y(i));
end
plot(f,abs(t));
The function called is as follows -
function f = freload(x,q)
epsl=3.4-0.004j;
f=(1./sqrt(epsl-(x.^2))).*(1+exp(-2*1i*2*pi*q/(3e8).*sqrt(epsl-(x.^2))))./((1-exp(-2*1i*2*pi*q/(3e8).*sqrt(epsl-(x.^2)))));
end
The full warning I get is as follows -
Warning: Minimum step size reached near x = 1.75484e+22. There may be a singularity, or the tolerances
may be too tight for this problem.
> In integralCalc/checkSpacing (line 456)
In integralCalc/iterateScalarValued (line 319)
In integralCalc/vadapt (line 132)
In integralCalc (line 83)
In integral (line 88)
In trial (line 14)
And the number of times I get this depends on the number of samples taken. Does anyone know why this problem occurs, or how I could go about overcoming this ? Any help or suggestion would be greatly appreciated.
Thanks.
Answers (1)
Walter Roberson
on 21 Sep 2017
On your first iteration, i = 1, if you switch to the symbolic toolbox
syms x
g = fun(x)
then limit(imag(g), x, inf) is non-zero . Therefore if the imaginary component is convergent it is infinite anyhow, so the solution for the integral is going to have to be either non-convergent or a complex number involving infinity.
Categories
Find more on Functional Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!