Skip to content

Evaluating TaylorModel1 over interval doesn't work over the definition interval. #210

Open

Description

@freemin7

The issue is with iscontained. I would expect this assert to not fail.

using TaylorModels

a =  -0.5 .. 1.0
x0 = mid(a)

@assert  TaylorModels.iscontained(a,TaylorModel1(2, interval(x0), a))

This causes this not to work:

f(x) = x*(x-1.1)*(x+2)*(x+2.2)*(x+2.5)*(x+3)*sin(1.7*x+0.5)

tm6f = f(TaylorModel1(6, interval(x0)));
tm6f(a)
ERROR: AssertionError: iscontained(a, tm)
Stacktrace:
 [1] evaluate(tm::TaylorModel1{Interval{Float64}, Float64}, a::Interval{Float64})
   @ TaylorModels C:\Users\user\.julia\packages\TaylorModels\uhtsT\src\evaluate.jl:18
 [2] (::TaylorModel1{Interval{Float64}, Float64})(a::Interval{Float64})
   @ TaylorModels C:\Users\user\.julia\packages\TaylorModels\uhtsT\src\evaluate.jl:44
 [3] top-level scope
   @ REPL[10]:1

Activity

  1. lbenet commented on Oct 30, 2026

    @lbenet
    Member

    Thanks for reporting, I'll have a look at this on the weekend

  2. lbenet commented on Oct 31, 2026

    @lbenet
    Member

    I guess I should begin apologizing for the poor documentation of the package, which I think is at the core of the issue.

    Let me begin on what you expect it worked, the second part of the code. TaylorModel1(6, interval(x0)) creates a Taylor Model of order 6, whose domain is interval(x0), i.e., interval(0.25, 0.25), around its mid point (which is x0 itself). Then, if you evaluate that Taylor Model (or any function on it, which shares domain and expansion point) on the wider interval a, a is not contained in the centered domain of the Taylor Model (centered_dom = domain - expansion_point), and thus the error; I think the package behaves correctly here. The reason we check against the centered domain, is because the expansion is around x0, so the displayed (independent) variable, below "t", is actually the deviations around x0; sorry for not documenting this (and most of the package).

    If you want to create a Taylor Model of order 6, whose domain is a = interval(-0.5, 1.0), expanded around its mid point x0, and then use that Taylor Model to estimate the range of the function $f(x)$, you should do the following:

    julia> using TaylorModels
    
    julia> a =  -0.5 .. 1.0; x0 = mid(a);
    
    julia> x = TaylorModel1(6, a) # same as `TaylorModel1(2, interval(x0), a)`; t represents deviations from x0
     [0.25, 0.25]_com + [1.0, 1.0]_com t + [0.0, 0.0]_com
    
    julia> domain(x), expansion_point(x)  # This is to check the domain and the expansion point
    ([-0.5, 1.0]_com, [0.25, 0.25]_com)
    
    julia> f(x) = x*(x-1.1)*(x+2)*(x+2.2)*(x+2.5)*(x+3)*sin(1.7*x+0.5)
    f (generic function with 1 method)
    
    julia> fx = f(x) # get the Taylor Model of f, expanded around `x0` valid for the domain `a` (centered at x0)
     [-8.36112, -8.36111]_com_NG + [-47.0612, -47.0611]_com_NG t + [-38.3545, -38.3544]_com_NG t² + [90.4376, 90.4377]_com_NG t³ + [102.183, 102.184]_com_NG t⁴ + [-20.5814, -20.5813]_com_NG t⁵ + [-58.0084, -58.0083]_com_NG t⁶ + [-1.97165, 2.71142]_com_NG
    
    julia> fx(centered_dom(x)) # evaluate fx at the (whole) centered domain, equivalent to fx(a-mid(a)) or fTM(a-x0)
    [-67.203, 40.4034]_com_NG
    
    julia> f(a) # Naive interval evaluation
    [-215.041, 107.521]_com_NG

    I evaluated at the centered domain because we used the mid point of a as expansion point.

    Now we do the same, estimate the range, but using 0 as the expansion point, so the variable "t" below actually represents what you expect (center is "0").

    julia> y = TaylorModel1(6, interval(0.0), a)
     [1.0, 1.0]_com t + [0.0, 0.0]_com
    
    julia> fy = f(y)
     [-17.4032, -17.4031]_com_NG t + [-67.709, -67.7089]_com_NG t² + [-8.78208, -8.78207]_com_NG t³ + [82.9944, 82.9945]_com_NG t⁴ + [42.7633, 42.7634]_com_NG t⁵ + [-24.3912, -24.3911]_com_NG t⁶ + [-22.3141, 11.3373]_com_NG
    
    julia> fy(a)
    [-116.209, 43.201]_com_NG
    
    julia> fy(centered_dom(y)) # same as above, because centered_dom = domain - expansion_point == domain
    [-116.209, 43.201]_com_NG

    I hope this explains why the error is thrown, and it was actually ok to be thrown.

  3. freemin7 commented on Nov 4, 2026

    @freemin7
    Author

    I am still confused why the "center point" is an singleton interval and why one would define a taylor model over the point and an interval or just an interval but not via just a point.

  4. lbenet commented on Nov 4, 2026

    @lbenet
    Member

    I am still confused why the "center point" is an singleton interval and why one would define a taylor model over the point and an interval or just an interval but not via just a point.

    I guess you refer to TaylorModel1(6, interval(x0)) above, right? There is an external constructor TaylorModel(ord::Int, dom::Interval) which creates a Taylor model independent variable of a given order (ord), over the domain dom, using the expansion point mid(dom). That is the method you used in the second code snippet above (#210 (comment)). Since x0 is an exact floating point, interval(x0) is a singleton interval. In your example, you should have used TaylorModel(6, a) or TaylorModel(6, interval(x0), a).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions