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

Unexpected evaluate behavior with non-Float64 numbers #158

Open
schillic opened this issue Jan 25, 2024 · 4 comments
Open

Unexpected evaluate behavior with non-Float64 numbers #158

schillic opened this issue Jan 25, 2024 · 4 comments

Comments

@schillic
Copy link
Contributor

Is it expected that evaluate gives vastly different results when using non-Float64 numbers?

julia> using TaylorModels

julia> function eval(N)
    t = TaylorModels.Taylor1(3)
    q₁ = 1 + 2 * t + 2 * t^2
    I = interval(N(0), N(0))
    D = interval(N(-1), N(1))
    x0 = mid(D)
    TM = TaylorModels.TaylorModel1(q₁, I, x0, D)
    return evaluate(TM, domain(TM))
end;

julia> eval(Float64)
[-1, 5]

julia> eval(Float32)
[-3, 5]

julia> eval(Rational{Int})
[-3, 5]
@lbenet
Copy link
Member

lbenet commented Jan 25, 2024

Thanks for reporting; that is indeed weird. I'll have a look, and I'll get back here.

Note that since lot is going on in IntervalArithmetic, and that has consequences in TaylorSeries, lots of changes will occur here...

@lbenet
Copy link
Member

lbenet commented Jan 25, 2024

The problem seems to be in TaylorSeries:

julia> D32 = interval(-1f0, 1f0)
[-1f0, 1f0]

julia> D = interval(-1.0, 1.0)
[-1, 1]

julia> t = Taylor1(3)
 1.0 t + 𝒪(t⁴)

julia> q₁ =  1 + 2*t + 2*t^2
 1.0 + 2.0 t + 2.0+ 𝒪(t⁴)

julia> q₁(D)
[-1, 5]

julia> q₁(D32)
[-3, 5]

julia> evaluate(t^2, D)
[0, 1]

julia> evaluate(t^2, D32)
[-1, 1]

@lbenet
Copy link
Member

lbenet commented Jan 25, 2024

The problem seems to be in TaylorSeries:

Noup, the problem is in IntervalArithmetic v0.20.9: somehow, squaring doesn't work for Interval{Float32}

julia> D^2
[0, 1]

julia> D32^2
[-1f0, 1f0]

julia> @which D32^2
^(x::Number, p::Integer)
     @ Base intfuncs.jl:311

The problem is solved in current master of IntervalArithmetic.

@schillic
Copy link
Contributor Author

Thanks for working this out! Then there is nothing we can do for now and this should eventually get resolved when the new version is supported.
I leave it to you to keep this issue open as a reminder or close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants