JuliaIntervals / TaylorModels.jl

Rigorous function approximation using Taylor models in Julia
Other
63 stars 14 forks source link

Assert (or warn) if evaluation is computed in the proper domain #73

Closed lbenet closed 4 years ago

lbenet commented 4 years ago

Currently, evaluate does not check if the evaluation point (or interval) is contained within the domain defining the Taylor model.

julia> using TaylorModels

julia> tm = TaylorModel1(5, 0.0, -0.5 .. 0.5)
 1.0 t + [0, 0]

julia> em = exp(tm)
 1.0 + 1.0 t + 0.5 t² + 0.16666666666666666 t³ + 0.041666666666666664 t⁴ + 0.008333333333333333 t⁵ + [-0, 2.33541e-05]

julia> domain(em)
[-0.5, 0.5]

julia> evaluate(em, 1.5)
[4.46171, 4.46175]

There is no assertion nor warning about evaluating outside the domain; the result in this case is actually wrong. The problem is that this happens silently.

We should use @assert, or at least @warn when the point (or interval) used in the evaluation is not completely contained within the domain of the Taylor model.

cc: @dpsanders, @UzielLinares

dpsanders commented 4 years ago

Good catch. I think this should just throw an error.