Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mean value form #82

Merged
merged 4 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/lib/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AbstractDirectRangeAlgorithm
AbstractIterativeRangeAlgorithm
BranchAndBoundEnclosure
NaturalEnclosure
MeanValueEnclosure
MooreSkelboeEnclosure
SumOfSquaresEnclosure
TaylorModelsEnclosure
Expand Down
2 changes: 1 addition & 1 deletion src/RangeEnclosures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ API
include("enclose.jl")

export enclose, relative_precision,
NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure,
MeanValueEnclosure, NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure,
TaylorModelsEnclosure, BranchAndBoundEnclosure,
AbstractEnclosureAlgorithm, AbstractDirectRangeAlgorithm, AbstractIterativeRangeAlgorithm

Expand Down
9 changes: 9 additions & 0 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 / gradient of `f`.
lucaferranti marked this conversation as resolved.
Show resolved Hide resolved
"""
struct MeanValueEnclosure <: AbstractDirectRangeAlgorithm end

"""
MooreSkelboeEnclosure{T} <: AbstractIterativeRangeAlgorithm

Expand Down
10 changes: 10 additions & 0 deletions src/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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