Skip to content

Commit 6907c03

Browse files
committed
close issue JuliaMath#94
1 parent 659f22f commit 6907c03

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/find_zero.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ end
131131
## frame the problem and the options
132132
function derivative_free_setup(method::Any, fs, x0::Union{T, Tuple{T,T}, Vector{T}};
133133
bracket=missing,
134-
xabstol=zero(T), xreltol=zero(T),
134+
xabstol=zero(T), xreltol=eps(T),
135135
abstol=4*eps(T), reltol=4*eps(T),
136136
maxevals=40, maxfnevals=typemax(Int),
137137
verbose::Bool=false,

test/test_find_zero.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,29 @@ pathological = [
249249
for (fn_, x0_) in pathological
250250
find_zero(fn_, x0_, Order0())
251251
end
252+
253+
## issue tests: put in tests to ensure closed issues don't reappear.
254+
255+
## issue #94; tolerances not matching documentation
256+
test_94 = function(;kwargs...)
257+
g, T = 1.62850, 14.60000
258+
α, t1, tf = 0.00347, 40.91375, 131.86573
259+
y, ya, yf = 0.0, 9000.0, 10000.0
260+
vy = sqrt(2g*(ya-y))
261+
θ0, θ1 = atan*tf), atan*(tf-t1))
262+
I_sintan(x) = tan(x)/2cos(x) - atanh(tan(x/2))
263+
I_sintan(x, y) = I_sintan(y) - I_sintan(x)
264+
function lhs(θ)
265+
tRem = (vy - T/α*(sec(θ1) - sec(θ))) / g
266+
val = -yf + y + vy*tRem - 0.5g*tRem^2 - T/α^2*I_sintan(θ, θ1)
267+
val
268+
end
269+
270+
meth = Roots.FalsePosition()
271+
prob, options = Roots.derivative_free_setup(meth, lhs, [atan*tf), atan*(tf-t1))])
272+
state = Roots.init_state(meth, prob.fs, prob.x0, prob.bracket)
273+
find_zero(meth, prob.fs, state, options)
274+
275+
@test state.steps <= 15
276+
end
277+
test_94()

0 commit comments

Comments
 (0)