@@ -17,13 +17,13 @@ The following keyword parameters are accepted.
17
17
- `n₀::Int = 10`, the 'slack'. Must not be negative. When n₀ = 0 the worst-case is
18
18
identical to that of bisection, but increacing n₀ provides greater oppotunity for
19
19
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`.
21
21
Lower values produce tighter asymptotic behaviour, while higher values improve the
22
22
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
24
24
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.
27
27
28
28
### Worst Case Performance
29
29
@@ -35,19 +35,19 @@ n½ + `n₀` iterations, where n½ is the number of iterations using bisection
35
35
If `f` is twice differentiable and the root is simple, then with `n₀` > 0 the convergence
36
36
rate is √`κ₂`.
37
37
"""
38
- struct ITP{T} <: AbstractBracketingAlgorithm
39
- k1 :: T
40
- k2:: T
38
+ struct ITP{T₁, T₂ } <: AbstractBracketingAlgorithm
39
+ scaled_k1 :: T₁
40
+ k2:: T₂
41
41
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" )
44
45
n0 < 0 && error (" Hyper-parameter n₀ should not be negative" )
45
46
if k2 < 1 || k2 > (1.5 + sqrt (5 ) / 2 )
46
47
throw (ArgumentError (" Hyper-parameter κ₂ should be between 1 and 1 + ϕ where \
47
48
ϕ ≈ 1.618... is the golden ratio" ))
48
49
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)
51
51
end
52
52
end
53
53
@@ -72,7 +72,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP, args...;
72
72
end
73
73
ϵ = abstol
74
74
# defining variables/cache
75
- k1 = alg. k1
75
+ k1 = alg. scaled_k1 / abs (right - left)
76
76
k2 = alg. k2
77
77
n0 = alg. n0
78
78
n_h = ceil (log2 (abs (right - left) / (2 * ϵ)))
@@ -88,7 +88,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP, args...;
88
88
while i <= maxiters
89
89
span = abs (right - left)
90
90
r = ϵ_s - (span / 2 )
91
- δ = k1 * (span^ k2 )
91
+ δ = k1 * ((k2 == 2 ) ? span^ 2 : (span ^ k2) )
92
92
93
93
# # Interpolation step ##
94
94
x_f = left + (right - left) * (fl / (fl - fr))
0 commit comments