Skip to content

Commit 86da8b3

Browse files
committed
New default values
1 parent b186343 commit 86da8b3

File tree

1 file changed

+13
-13
lines changed
  • lib/SimpleNonlinearSolve/src/bracketing

1 file changed

+13
-13
lines changed

lib/SimpleNonlinearSolve/src/bracketing/itp.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ The following keyword parameters are accepted.
1717
- `n₀::Int = 10`, the 'slack'. Must not be negative. When n₀ = 0 the worst-case is
1818
identical to that of bisection, but increacing n₀ provides greater oppotunity for
1919
superlinearity.
20-
- `κ₁::Float64 = 0.007`. Must not be negative. The recomended value is `0.2/(x₂ - x₁)`.
20+
- `scaled_κ₁::Float64 = 0.2`. Must not be negative. The recomended value is `0.2`.
2121
Lower values produce tighter asymptotic behaviour, while higher values improve the
2222
steady-state behaviour when truncation is not helpful.
23-
- `κ₂::Real = 1.5`. Must lie in [1, 1+ϕ ≈ 2.62). Higher values allow for a greater
23+
- `κ₂::Real = 2`. Must lie in [1, 1+ϕ ≈ 2.62). Higher values allow for a greater
2424
convergence rate, but also make the method more succeptable to worst-case performance.
25-
In practice, κ=1,2 seems to work well due to the computational simplicity, as κ₂ is used
26-
as an exponent in the method.
25+
In practice, κ=1, 2 seems to work well due to the computational simplicity, as κ₂ is
26+
used as an exponent in the method.
2727
2828
### Worst Case Performance
2929
@@ -35,19 +35,19 @@ n½ + `n₀` iterations, where n½ is the number of iterations using bisection
3535
If `f` is twice differentiable and the root is simple, then with `n₀` > 0 the convergence
3636
rate is √`κ₂`.
3737
"""
38-
struct ITP{T} <: AbstractBracketingAlgorithm
39-
k1::T
40-
k2::T
38+
struct ITP{T₁, T₂} <: AbstractBracketingAlgorithm
39+
scaled_k1::T
40+
k2::T
4141
n0::Int
42-
function ITP(; k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10)
43-
k1 < 0 && error("Hyper-parameter κ₁ should not be negative")
42+
function ITP(;
43+
scaled_k1::T₁ = 0.2, k2::T₂ = 2, n0::Int = 10) where {T₁ <: Real, T₂ <: Real}
44+
scaled_k1 < 0 && error("Hyper-parameter κ₁ should not be negative")
4445
n0 < 0 && error("Hyper-parameter n₀ should not be negative")
4546
if k2 < 1 || k2 > (1.5 + sqrt(5) / 2)
4647
throw(ArgumentError("Hyper-parameter κ₂ should be between 1 and 1 + ϕ where \
4748
ϕ ≈ 1.618... is the golden ratio"))
4849
end
49-
T = promote_type(eltype(k1), eltype(k2))
50-
return new{T}(k1, k2, n0)
50+
return new{T₁, T₂}(scaled_k1, k2, n0)
5151
end
5252
end
5353

@@ -72,7 +72,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP, args...;
7272
end
7373
ϵ = abstol
7474
#defining variables/cache
75-
k1 = alg.k1
75+
k1 = alg.scaled_k1 / abs(right - left)
7676
k2 = alg.k2
7777
n0 = alg.n0
7878
n_h = ceil(log2(abs(right - left) / (2 * ϵ)))
@@ -88,7 +88,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP, args...;
8888
while i <= maxiters
8989
span = abs(right - left)
9090
r = ϵ_s - (span / 2)
91-
δ = k1 * (span^k2)
91+
δ = k1 * ((k2 == 2) ? span^2 : (span^k2))
9292

9393
## Interpolation step ##
9494
x_f = left + (right - left) * (fl / (fl - fr))

0 commit comments

Comments
 (0)