diff --git a/docs/src/lib/types.md b/docs/src/lib/types.md index 03169a05..cfd01daf 100644 --- a/docs/src/lib/types.md +++ b/docs/src/lib/types.md @@ -17,6 +17,7 @@ AbstractDirectRangeAlgorithm AbstractIterativeRangeAlgorithm BranchAndBoundEnclosure NaturalEnclosure +MeanValueEnclosure MooreSkelboeEnclosure SumOfSquaresEnclosure TaylorModelsEnclosure diff --git a/src/RangeEnclosures.jl b/src/RangeEnclosures.jl index 01ed6edb..2706ce21 100644 --- a/src/RangeEnclosures.jl +++ b/src/RangeEnclosures.jl @@ -25,7 +25,7 @@ API include("enclose.jl") export enclose, relative_precision, - NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure, + MeanValueEnclosure, NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure, TaylorModelsEnclosure, BranchAndBoundEnclosure, AbstractEnclosureAlgorithm, AbstractDirectRangeAlgorithm, AbstractIterativeRangeAlgorithm diff --git a/src/algorithms.jl b/src/algorithms.jl index 43f64774..aa6d36a5 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -36,6 +36,15 @@ julia> enclose(x -> 1 - x^4 + x^5, 0..1, NaturalEnclosure()) """ struct NaturalEnclosure <: AbstractDirectRangeAlgorithm end +""" + MeanValueEnclosure + +Data type to bound the range of `f` over `X` using the mean value form, that is the range +is bounded by the expression ``f(Xc) + f'(X) * (X - Xc)``, where `Xc` is the midpoint of `X` +and `f'` is the derivative of `f` (gradient in the multivariate case). +""" +struct MeanValueEnclosure <: AbstractDirectRangeAlgorithm end + """ MooreSkelboeEnclosure{T} <: AbstractIterativeRangeAlgorithm diff --git a/src/intervals.jl b/src/intervals.jl index 2564104c..3b849d14 100644 --- a/src/intervals.jl +++ b/src/intervals.jl @@ -5,3 +5,13 @@ Methods using Interval Arithmetic function _enclose(::NaturalEnclosure, f::Function, dom::Interval_or_IntervalBox; kwargs...) return f(dom...) end + +function _enclose(::MeanValueEnclosure, f::Function, dom::Interval; + df=Base.Fix1(ForwardDiff.derivative, f)) + return f(mid(dom)) + df(dom) * (dom - mid(dom)) +end + +function _enclose(::MeanValueEnclosure, f::Function, dom::IntervalBox; + df=t->ForwardDiff.gradient(w->f(w...), t.v)) + return f(mid.(dom)...) + dot(df(dom), dom - mid.(dom)) +end