"lsqnonlin" constantly stopped for failing to integrate numerically
1 次查看(过去 30 天)
显示 更早的评论
I numerically solving a system of equations. Some have integral equations, for which I am using "integral", since there is no definite integral. My problem is that in some iterations "lsqnonlin" stops and returns the following message:
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.0e+03. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
After a while the iterations continue running, but returns quickly to stop, delivering the same message.
What am I doing wrong ?, there is any way to fix it, maybe changing my integration method?
0 个评论
回答(2 个)
Mike Hosea
2014-10-3
Is it possible that your problem is singular or highly oscillatory inside the interval of integration for some parameter values? I mean, well, this happens, and I'm not doing anything wrong:
> q = @(c)integral(@(x)cos(exp(c)*x),0,2*pi)
q =
@(c)integral(@(x)cos(exp(c)*x),0,2*pi)
>> q(5)
ans =
0.003496745772498
>> q(10)
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 3.6e-02. The integral may not
exist, or it may be difficult to approximate numerically to the requested accuracy.
> In funfun\private\integralCalc>iterateScalarValued at 372
In funfun\private\integralCalc>vadapt at 132
In funfun\private\integralCalc at 75
In integral at 88
In @(c)integral(@(x)cos(exp(c)*x),0,2*pi)
ans =
9.682301680398093e-06
The problem is just hard. It is difficult to advise you how to proceed without knowing more about the problem. Would it be possible to supply a condensed example of one of the problem integrals that I could play with to figure out what is hard about it?
0 个评论
Matt J
2014-10-3
编辑:Matt J
2014-10-3
Instead of trying to push
(integral(f,a,b))^2 --->0
to zero with lsqnonlin, maybe it would be enough to push samples of the integrand to zero on the interval [a,b]
sum([f(a), f(a+delta), f(a+2*delta),+...+f(b)]).^2 --->0
using some appropriate sampling interval length, delta. This way you circumvent the difficult integral altogether, or at least you effectively get a more direct hand in the sampling it uses.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!