Skip to content

Commit

Permalink
close issue JuliaMath#94
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani committed Dec 24, 2017
1 parent 659f22f commit 6907c03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/find_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ end
## frame the problem and the options
function derivative_free_setup(method::Any, fs, x0::Union{T, Tuple{T,T}, Vector{T}};
bracket=missing,
xabstol=zero(T), xreltol=zero(T),
xabstol=zero(T), xreltol=eps(T),
abstol=4*eps(T), reltol=4*eps(T),
maxevals=40, maxfnevals=typemax(Int),
verbose::Bool=false,
Expand Down
26 changes: 26 additions & 0 deletions test/test_find_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,29 @@ pathological = [
for (fn_, x0_) in pathological
find_zero(fn_, x0_, Order0())
end

## issue tests: put in tests to ensure closed issues don't reappear.

## issue #94; tolerances not matching documentation
test_94 = function(;kwargs...)
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))
I_sintan(x) = tan(x)/2cos(x) - atanh(tan(x/2))
I_sintan(x, y) = I_sintan(y) - I_sintan(x)
function lhs(θ)
tRem = (vy - T/α*(sec(θ1) - sec(θ))) / g
val = -yf + y + vy*tRem - 0.5g*tRem^2 - T/α^2*I_sintan(θ, θ1)
val
end

meth = Roots.FalsePosition()
prob, options = Roots.derivative_free_setup(meth, lhs, [atan*tf), atan*(tf-t1))])
state = Roots.init_state(meth, prob.fs, prob.x0, prob.bracket)
find_zero(meth, prob.fs, state, options)

@test state.steps <= 15
end
test_94()

0 comments on commit 6907c03

Please sign in to comment.