I have a handful of UDF's that use iterative algorithms to numerically arrive at a solution (usually either a Newton-Raphson type algorithm or successive approximations). I like to put a check on the number of iterations, to prevent getting stuck in an infinite loop should the problem diverge. Generic function looks something like:
function myudf(arglist, optional init)
if ismissing(init) then init= some reasonable initial guess for generic problems of this sort
code setting up initial values for the iteration
it=0
do
it=it+1
iteration code to find next value from old value
loop until convergeance criteria or it>=100
myudf=result
end function
What I would like to add is something to let me know when the convergeance criteria hasn't been met, but rather the function has ended because we've reached the maximum number of iterations. I'm just looking for ideas. How would you inform me that the function reached maxiterations without converging? message box? have the function return an error? other possibility?
Thanks in advance.
Bookmarks