From c3752b10e864385dda79091e96db440336923402 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Wed, 21 Jun 2023 23:49:30 +0200 Subject: [PATCH 01/16] itp method begin --- src/SimpleNonlinearSolve.jl | 1 + src/itp.jl | 0 2 files changed, 1 insertion(+) create mode 100644 src/itp.jl diff --git a/src/SimpleNonlinearSolve.jl b/src/SimpleNonlinearSolve.jl index 8749aa7..5074d44 100644 --- a/src/SimpleNonlinearSolve.jl +++ b/src/SimpleNonlinearSolve.jl @@ -41,6 +41,7 @@ include("dfsane.jl") include("ad.jl") include("halley.jl") include("alefeld.jl") +include("itp.jl") import PrecompileTools diff --git a/src/itp.jl b/src/itp.jl new file mode 100644 index 0000000..e69de29 From 356602f5b673a773b79617fc96defe14ff6d24cc Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Fri, 23 Jun 2023 02:10:44 +0200 Subject: [PATCH 02/16] ipt alg --- src/itp.jl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/itp.jl b/src/itp.jl index e69de29..49a5656 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -0,0 +1,31 @@ +""" +```julia +Itp(; k1 = Val{1}(), k2 = Val{2}(), n0 = Val{1}()) +``` +ITP (Interpolate Truncate & Project) + + +""" + +struct Itp <: AbstractBracketingAlgorithm + k1::Real + k2::Real + n0::Int +end + +function Itp(k1::Real = Val{1}(), k2::Real = Val{2}(), n0::Int = Val{1}()) + if k1 < 0 + ArgumentError("Hyper-parameter κ₁ should not be negative") + end + if !isa(n0, Int) + ArgumentError("Hyper-parameter n₀ should be an Integer") + end + Itp(k1, k2, n0) +end + +function SciMLBase.__solve(prob::NonlinearProblem, alg::Itp, + args..., abstol = nothing, reltol = nothing, + maxiters = 1000, kwargs...) + + +end \ No newline at end of file From fa82128a9734f781bc7ed92e6b8dc487bfe88ec2 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Tue, 27 Jun 2023 01:26:46 +0200 Subject: [PATCH 03/16] minor fix --- src/SimpleNonlinearSolve.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SimpleNonlinearSolve.jl b/src/SimpleNonlinearSolve.jl index 5074d44..8177dd2 100644 --- a/src/SimpleNonlinearSolve.jl +++ b/src/SimpleNonlinearSolve.jl @@ -74,6 +74,6 @@ end # DiffEq styled algorithms export Bisection, Brent, Broyden, LBroyden, SimpleDFSane, Falsi, Halley, Klement, - Ridder, SimpleNewtonRaphson, SimpleTrustRegion, Alefeld + Ridder, SimpleNewtonRaphson, SimpleTrustRegion, Alefeld, Itp end # module From 2e7d41a2f4919e2f6b0d12e6493aabe8be73d6f7 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Tue, 27 Jun 2023 02:33:25 +0200 Subject: [PATCH 04/16] defined cache --- src/itp.jl | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/itp.jl b/src/itp.jl index 49a5656..ff84848 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -23,9 +23,38 @@ function Itp(k1::Real = Val{1}(), k2::Real = Val{2}(), n0::Int = Val{1}()) Itp(k1, k2, n0) end -function SciMLBase.__solve(prob::NonlinearProblem, alg::Itp, +function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, args..., abstol = nothing, reltol = nothing, maxiters = 1000, kwargs...) + f = Base.Fix2(prob.f, prob.p) + left, right = prob.tspan # a and b + fl, fr = f(left), f(right) + ϵ = abstol + if iszero(fl) + return SciMLBase.build_solution(prob, alg, left, fl; + retcode = ReturnCode.ExactSolutionLeft, left = left, + right = right) + end + + if iszero(fr) + end + #defining variables/cache + k1 = alg.k1 + k2 = alg.k2 + n0 = alg.k3 + n_h = ceil(log2((right - left) / (2 * ϵ))) + n_max = n_h + n0 + mid = (left + right) / 2 + x_f = (fr * left - fl * right) / (fr - fl) + r = zero(left) + δ = zero(left) + σ = sign(mid - x_f) + i = 0 #iteration + while i <= maxiters + mid = (left + right) / 2 + r = ϵ * 2 ^ (n_max - i) - ((right - left) / 2) + δ = k1 * (right - left) ^ k2 + end end \ No newline at end of file From 98be6834b96ff7e4a61e8f638d03fc6095a338ff Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Tue, 27 Jun 2023 03:01:21 +0200 Subject: [PATCH 05/16] complete alg --- src/itp.jl | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index ff84848..2df125a 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -47,14 +47,57 @@ function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, n_max = n_h + n0 mid = (left + right) / 2 x_f = (fr * left - fl * right) / (fr - fl) - r = zero(left) - δ = zero(left) - σ = sign(mid - x_f) + xt = left + xp = left + r = zero(left) #minmax radius + δ = zero(left) # truncation error + σ = 1.0 i = 0 #iteration while i <= maxiters - mid = (left + right) / 2 + #mid = (left + right) / 2 r = ϵ * 2 ^ (n_max - i) - ((right - left) / 2) δ = k1 * (right - left) ^ k2 + + ## Interpolation step ## + x_f = (fr * left - fl * right) / (fr - fl) + + ## Truncation step ## + σ = sign(mid - x_f) + if δ <= abs(mid - x_f) + xt = x_f + (σ * δ) + else + xt = mid + end + + ## Projection step ## + if abs(xt - mid) <= r + xp = xt + else + xp = mid - (σ * r) + end + + ## Update ## + yp = f(xp) + if yp > 0 + right = xp + fr = yp + elseif yp < 0 + left = xp + fl = yp + else + left = xp + right = xp + end + i += 1 + mid = (left + right) / 2 + + if (right - left < 2 * ϵ) + return SciMLBase.build_solution(prob, alg, mid, fl; + retcode = ReturnCode.Success, left = left, + right = right) + end end + return SciMLBase.build_solution(prob, alg, left, fl; retcode = ReturnCode.MaxIters, + left = left, right = right) end \ No newline at end of file From 8308ee9be16b997c7fbbae1b478b977b87bd5b0d Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Tue, 27 Jun 2023 03:09:56 +0200 Subject: [PATCH 06/16] hyperparams checks --- src/itp.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/itp.jl b/src/itp.jl index 2df125a..853c3aa 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -20,7 +20,13 @@ function Itp(k1::Real = Val{1}(), k2::Real = Val{2}(), n0::Int = Val{1}()) if !isa(n0, Int) ArgumentError("Hyper-parameter n₀ should be an Integer") end - Itp(k1, k2, n0) + if n0 < 0 + ArgumentError("Hyper-parameter n₀ should not be negative") + end + if k2 < 1 || k2 > (1.5 + sqrt(5) / 2) + ArgumentError("Hyper-parameter κ₂ should be between 1 and 1 + ϕ where ϕ ≈ 1.618... is the golden ratio") + end + return Itp(k1, k2, n0) end function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, From b1c611476fff0bac8ce1b2143ae2b48353c8c40c Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Tue, 27 Jun 2023 03:16:58 +0200 Subject: [PATCH 07/16] abstol fix --- src/itp.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/itp.jl b/src/itp.jl index 853c3aa..8eed6d9 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -30,7 +30,7 @@ function Itp(k1::Real = Val{1}(), k2::Real = Val{2}(), n0::Int = Val{1}()) end function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, - args..., abstol = nothing, reltol = nothing, + args..., abstol = 1e-8, reltol = nothing, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b From fb139fee61e36bad637d2ea6a4b9b38cb59b6e6d Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Tue, 27 Jun 2023 03:24:00 +0200 Subject: [PATCH 08/16] right retcode --- src/itp.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index 8eed6d9..014e321 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -40,10 +40,10 @@ function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, return SciMLBase.build_solution(prob, alg, left, fl; retcode = ReturnCode.ExactSolutionLeft, left = left, right = right) - end - - if iszero(fr) - + elseif iszero(fr) + return SciMLBase.build_solution(prob, alg, right, fr; + retcode = ReturnCode.ExactSolutionRight, left = left, + right = right) end #defining variables/cache k1 = alg.k1 From 195dd58d1d7b9e18ec716e7d8a01ae7788bdc3e6 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Wed, 28 Jun 2023 03:25:27 +0200 Subject: [PATCH 09/16] update SimpleNonlinearSolve.jl --- src/SimpleNonlinearSolve.jl | 2 +- src/itp.jl | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/SimpleNonlinearSolve.jl b/src/SimpleNonlinearSolve.jl index 8177dd2..ca787c2 100644 --- a/src/SimpleNonlinearSolve.jl +++ b/src/SimpleNonlinearSolve.jl @@ -66,7 +66,7 @@ PrecompileTools.@compile_workload begin prob_brack = IntervalNonlinearProblem{false}((u, p) -> u * u - p, T.((0.0, 2.0)), T(2)) - for alg in (Bisection, Falsi, Ridder, Brent, Alefeld) + for alg in (Bisection, Falsi, Ridder, Brent, Alefeld, Itp) solve(prob_brack, alg(), abstol = T(1e-2)) end end diff --git a/src/itp.jl b/src/itp.jl index 014e321..085f80f 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -11,26 +11,25 @@ struct Itp <: AbstractBracketingAlgorithm k1::Real k2::Real n0::Int -end - -function Itp(k1::Real = Val{1}(), k2::Real = Val{2}(), n0::Int = Val{1}()) - if k1 < 0 - ArgumentError("Hyper-parameter κ₁ should not be negative") - end - if !isa(n0, Int) - ArgumentError("Hyper-parameter n₀ should be an Integer") - end - if n0 < 0 - ArgumentError("Hyper-parameter n₀ should not be negative") - end - if k2 < 1 || k2 > (1.5 + sqrt(5) / 2) - ArgumentError("Hyper-parameter κ₂ should be between 1 and 1 + ϕ where ϕ ≈ 1.618... is the golden ratio") + function Itp(;k1::Real = 0.1, k2::Real = 2.0, n0::Int = 1) + if k1 < 0 + ArgumentError("Hyper-parameter κ₁ should not be negative") + end + if !isa(n0, Int) + ArgumentError("Hyper-parameter n₀ should be an Integer") + end + if n0 < 0 + ArgumentError("Hyper-parameter n₀ should not be negative") + end + if k2 < 1 || k2 > (1.5 + sqrt(5) / 2) + ArgumentError("Hyper-parameter κ₂ should be between 1 and 1 + ϕ where ϕ ≈ 1.618... is the golden ratio") + end + return new(k1, k2, n0) end - return Itp(k1, k2, n0) end function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, - args..., abstol = 1e-8, reltol = nothing, + args...; abstol = nothing, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b From d7a70bcd5486e7385971ea6f14a6c55c79c08a55 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 28 Jun 2023 09:00:35 -0400 Subject: [PATCH 10/16] Update src/itp.jl --- src/itp.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/itp.jl b/src/itp.jl index 085f80f..bd5f888 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -28,7 +28,7 @@ struct Itp <: AbstractBracketingAlgorithm end end -function SciMLBase.__solve(prob::IntervalNonlinearProblem, alg::Itp, +function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, args...; abstol = nothing, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) From 195c5aa49129dbef6d43bfb84dbff3cf8c61edfd Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Wed, 28 Jun 2023 21:31:34 +0200 Subject: [PATCH 11/16] final fixes --- src/itp.jl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index bd5f888..b233c4f 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -13,13 +13,10 @@ struct Itp <: AbstractBracketingAlgorithm n0::Int function Itp(;k1::Real = 0.1, k2::Real = 2.0, n0::Int = 1) if k1 < 0 - ArgumentError("Hyper-parameter κ₁ should not be negative") - end - if !isa(n0, Int) - ArgumentError("Hyper-parameter n₀ should be an Integer") + error("Hyper-parameter κ₁ should not be negative") end if n0 < 0 - ArgumentError("Hyper-parameter n₀ should not be negative") + error("Hyper-parameter n₀ should not be negative") end if k2 < 1 || k2 > (1.5 + sqrt(5) / 2) ArgumentError("Hyper-parameter κ₂ should be between 1 and 1 + ϕ where ϕ ≈ 1.618... is the golden ratio") @@ -29,7 +26,7 @@ struct Itp <: AbstractBracketingAlgorithm end function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, - args...; abstol = nothing, + args...; abstol = 1.0e-8, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b @@ -47,7 +44,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, #defining variables/cache k1 = alg.k1 k2 = alg.k2 - n0 = alg.k3 + n0 = alg.n0 n_h = ceil(log2((right - left) / (2 * ϵ))) n_max = n_h + n0 mid = (left + right) / 2 From 17942d3ef55b644a2390bfeea49b89685040a0f8 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Thu, 29 Jun 2023 01:59:30 +0200 Subject: [PATCH 12/16] added itp tests --- src/itp.jl | 4 ++-- test/basictests.jl | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index b233c4f..c0d69f5 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -26,7 +26,7 @@ struct Itp <: AbstractBracketingAlgorithm end function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, - args...; abstol = 1.0e-8, + args...; abstol = 1.0e-10, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b @@ -94,7 +94,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, mid = (left + right) / 2 if (right - left < 2 * ϵ) - return SciMLBase.build_solution(prob, alg, mid, fl; + return SciMLBase.build_solution(prob, alg, mid, f(mid); retcode = ReturnCode.Success, left = left, right = right) end diff --git a/test/basictests.jl b/test/basictests.jl index aea1731..34ef709 100644 --- a/test/basictests.jl +++ b/test/basictests.jl @@ -215,6 +215,18 @@ for p in 1.1:0.1:100.0 @test ForwardDiff.derivative(g, p) ≈ 1 / (2 * sqrt(p)) end +# ITP +g = function (p) + probN = IntervalNonlinearProblem{false}(f, typeof(p).(tspan), p) + sol = solve(probN, Itp()) + return sol.u +end + +for p in 1.1:0.1:100.0 + @test g(p) ≈ sqrt(p) + @test ForwardDiff.derivative(g, p) ≈ 1 / (2 * sqrt(p)) +end + # Alefeld g = function (p) probN = IntervalNonlinearProblem{false}(f, typeof(p).(tspan), p) @@ -242,7 +254,7 @@ end f, tspan = (u, p) -> p[1] * u * u - p[2], (1.0, 100.0) t = (p) -> [sqrt(p[2] / p[1])] p = [0.9, 50.0] -for alg in [Bisection(), Falsi(), Ridder(), Brent()] +for alg in [Bisection(), Falsi(), Ridder(), Brent(), Itp()] global g, p g = function (p) probN = IntervalNonlinearProblem{false}(f, tspan, p) From 2018f4176c4b70e0c214254bae61c8089b77a835 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Fri, 30 Jun 2023 14:55:58 +0200 Subject: [PATCH 13/16] hyper param change --- src/itp.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index c0d69f5..568bb71 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -11,7 +11,7 @@ struct Itp <: AbstractBracketingAlgorithm k1::Real k2::Real n0::Int - function Itp(;k1::Real = 0.1, k2::Real = 2.0, n0::Int = 1) + function Itp(;k1::Real = 0.3, k2::Real = 2.0, n0::Int = 1) if k1 < 0 error("Hyper-parameter κ₁ should not be negative") end @@ -26,7 +26,7 @@ struct Itp <: AbstractBracketingAlgorithm end function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, - args...; abstol = 1.0e-10, + args...; abstol = 1.0e-8, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b From 071fd44ffcc8a5800bf0c57ee9f6fd57ec66cbbf Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Fri, 7 Jul 2023 02:26:37 +0200 Subject: [PATCH 14/16] final hyper params, tol and some modifications --- src/itp.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index 568bb71..5a91df0 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -11,7 +11,7 @@ struct Itp <: AbstractBracketingAlgorithm k1::Real k2::Real n0::Int - function Itp(;k1::Real = 0.3, k2::Real = 2.0, n0::Int = 1) + function Itp(;k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10) if k1 < 0 error("Hyper-parameter κ₁ should not be negative") end @@ -26,7 +26,7 @@ struct Itp <: AbstractBracketingAlgorithm end function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, - args...; abstol = 1.0e-8, + args...; abstol = 1.0e-15, maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b @@ -46,7 +46,6 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, k2 = alg.k2 n0 = alg.n0 n_h = ceil(log2((right - left) / (2 * ϵ))) - n_max = n_h + n0 mid = (left + right) / 2 x_f = (fr * left - fl * right) / (fr - fl) xt = left @@ -54,11 +53,12 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, r = zero(left) #minmax radius δ = zero(left) # truncation error σ = 1.0 + ϵ_s = ϵ * 2^(n_h + n0) i = 0 #iteration while i <= maxiters #mid = (left + right) / 2 - r = ϵ * 2 ^ (n_max - i) - ((right - left) / 2) - δ = k1 * (right - left) ^ k2 + r = ϵ_s - ((right - left) / 2) + δ = k1 * ((right - left) ^ k2) ## Interpolation step ## x_f = (fr * left - fl * right) / (fr - fl) @@ -92,6 +92,7 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, end i += 1 mid = (left + right) / 2 + ϵ_s /= 2 if (right - left < 2 * ϵ) return SciMLBase.build_solution(prob, alg, mid, f(mid); From 7cccd62e609b7e350ffd79731e8805e233d5ac72 Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Fri, 7 Jul 2023 02:26:51 +0200 Subject: [PATCH 15/16] error check tests --- test/basictests.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/basictests.jl b/test/basictests.jl index 34ef709..1515360 100644 --- a/test/basictests.jl +++ b/test/basictests.jl @@ -357,6 +357,18 @@ probB = IntervalNonlinearProblem(f, tspan) sol = solve(probB, Alefeld()) @test sol.u ≈ sqrt(2.0) +# Itp +sol = solve(probB, Itp()) +@test sol.u ≈ sqrt(2.0) +tspan = (sqrt(2.0), 10.0) +probB = IntervalNonlinearProblem(f, tspan) +sol = solve(probB, Itp()) +@test sol.u ≈ sqrt(2.0) +tspan = (0.0, sqrt(2.0)) +probB = IntervalNonlinearProblem(f, tspan) +sol = solve(probB, Itp()) +@test sol.u ≈ sqrt(2.0) + # Garuntee Tests for Bisection f = function (u, p) if u < 2.0 From 6a1a40f7903c0451f108b931f8cebf4a79ae88dd Mon Sep 17 00:00:00 2001 From: Yash Raj Singh Date: Fri, 7 Jul 2023 02:35:09 +0200 Subject: [PATCH 16/16] format --- src/itp.jl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/itp.jl b/src/itp.jl index 5a91df0..9968cba 100644 --- a/src/itp.jl +++ b/src/itp.jl @@ -11,7 +11,7 @@ struct Itp <: AbstractBracketingAlgorithm k1::Real k2::Real n0::Int - function Itp(;k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10) + function Itp(; k1::Real = 0.007, k2::Real = 1.5, n0::Int = 10) if k1 < 0 error("Hyper-parameter κ₁ should not be negative") end @@ -26,8 +26,8 @@ struct Itp <: AbstractBracketingAlgorithm end function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, - args...; abstol = 1.0e-15, - maxiters = 1000, kwargs...) + args...; abstol = 1.0e-15, + maxiters = 1000, kwargs...) f = Base.Fix2(prob.f, prob.p) left, right = prob.tspan # a and b fl, fr = f(left), f(right) @@ -58,10 +58,10 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, while i <= maxiters #mid = (left + right) / 2 r = ϵ_s - ((right - left) / 2) - δ = k1 * ((right - left) ^ k2) + δ = k1 * ((right - left)^k2) ## Interpolation step ## - x_f = (fr * left - fl * right) / (fr - fl) + x_f = (fr * left - fl * right) / (fr - fl) ## Truncation step ## σ = sign(mid - x_f) @@ -96,11 +96,10 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Itp, if (right - left < 2 * ϵ) return SciMLBase.build_solution(prob, alg, mid, f(mid); - retcode = ReturnCode.Success, left = left, - right = right) + retcode = ReturnCode.Success, left = left, + right = right) end end return SciMLBase.build_solution(prob, alg, left, fl; retcode = ReturnCode.MaxIters, left = left, right = right) - -end \ No newline at end of file +end