Azzera filtri
Azzera filtri

Can I trust the quad integration results with a warning of "minimum step size reached"?

3 visualizzazioni (ultimi 30 giorni)
I have two different codes to calculate the integration. The first one uses int, the second one uses quad. The first one is calculated by int, and didn't give me any error message, so it should be the right answer. the second one give me warning ' Minimum step size reached; singularity possible.' and then give me a result, but diffent from the first one. so what does this warning mean? Does this warning mean I shouldnt trust its results when it appears? and why does the calculation reaches its minimum step size , I am quite confused with this process? if anybody can help, thank you very much.
the first code is:
for j=1:151
x(j)= -15+((j/150)*2*15);
syms y;
f =1- exp(-y^2/12.5);
a(j)=int('f',-x(j),3);
end;
a=a(:)
the second code is :
for j=1:151
x(j)= -15+((j/150)*2*15);
f =@(y) 1- exp(-y.^2/12.5);
a(j)=quadl(f,-x(j),3);
end;
a=vpa(a(:),4)

Risposta accettata

Walter Roberson
Walter Roberson il 8 Ott 2011
int('f',-x(j),3)
is going to return
f*(3+x(j))
except with the current value of x(j) substituted in.
int() is part of the symbolic toolbox, and it only operates on values that are passed as parameters or which have been imported via subs() or which have been assigned by MuPAD assignment statements.
You should instead be using
int(f, -x(j), 3)
I do not see anything obvious in the expression that should lead to a small step size for quadl()
  2 Commenti
Lin LI
Lin LI il 8 Ott 2011
thank you very much, Walter. why does a 'minimum step size reached' means? why does it occur sometimes?
Lin LI
Lin LI il 8 Ott 2011
when I run the second code, it does give me that warning, I run that code again just a second ago.

Accedi per commentare.

Più risposte (1)

Andrei Bobrov
Andrei Bobrov il 8 Ott 2011
Hi friends!
@Lin LI: use quad or quadgk:
a1 = arrayfun(@(j1) quad(@(x) 1- exp(-x.^2/12.5),15-j1/10*2,3), (1:151)')

Community Treasure Hunt

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

Start Hunting!

Translated by