You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convergence logic sometimes fails to notice that no progress is being made. I don't have any idea why this particular test function triggers that behaviour.
module M1
import Roots
import ForwardDiff
function check_rootfinding(which; args...)
g, T = 1.62850, 14.60000
α, t1, tf = 0.00347, 40.91375, 131.86573
y, ya, yf = 0.0, 9000.0, 10000.0
vy = sqrt(2g*(ya-y))
θ0, θ1 = atan(α*tf), atan(α*(tf-t1))
nf = 0
I_sintan(x) = tan(x)/2cos(x) - atanh(tan(x/2))
I_sintan(x, y) = I_sintan(y) - I_sintan(x)
function lhs(θ)
nf += 1
tRem = (vy - T/α*(sec(θ1) - sec(θ))) / g
val = -yf + y + vy*tRem - 0.5g*tRem^2 - T/α^2*I_sintan(θ, θ1)
isa(θ, AbstractFloat) && @printf "[% 3d]: θ=% .18e val=% .18e\n" nf θ val
val
end
ans = Roots.find_zero(lhs, [atan(α*tf), atan(α*(tf-t1))], which; args...)
@show nf
ans_d = ForwardDiff.derivative(x -> lhs(x), ans)
@show ans
@show ans_d
abs(lhs(ans) / ans_d)
end
end
Notice that it keeps calling the function at exactly the same two points starting from iteration 10, making no progress:
This case is an interesting problem. The algorithm is set to stop when the f(x) values get close to 0, but not when subsequent x values get close (as xabstol=zero and not even eps()). It seems to suggest relaxing the bounds a tad is a good idea. (check_rootfinding(Roots.FalsePosition(), xabstol=eps()) takes 8 steps.
I'll make this change.
jverzani
added a commit
to jverzani/Roots.jl
that referenced
this issue
Dec 24, 2017
Convergence logic sometimes fails to notice that no progress is being made. I don't have any idea why this particular test function triggers that behaviour.
Notice that it keeps calling the function at exactly the same two points starting from iteration 10, making no progress:
This is with
Pkg.checkout("Roots")
:Here's a plot of that function, it doesn't look pathological: https://imgur.com/a/KWmTl
The text was updated successfully, but these errors were encountered: