Skip to content

ApproxFun+IntervalArithmetic: Add support for constructor  #2

@dlfivefifty

Description

@dlfivefifty

The following would ideally work:

julia> using ApproxFun

julia> import IntervalArithmetic: @interval

julia> Base.sinpi(x::IntervalArithmetic.Interval) = sin*x)

julia> Fun(exp, @interval(0)..@interval(1))
ERROR: MethodError: no method matching plan_chebyshevtransform(::Array{IntervalArithmetic.Interval{Float64},1})
Closest candidates are:
  plan_chebyshevtransform(::Array{D<:DualNumbers.Dual,1}; kind) where D<:DualNumbers.Dual at /Users/solver/Projects/ApproxFun.jl/src/Extras/dualnumbers.jl:35
  plan_chebyshevtransform(::AbstractArray{T<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64},1}; kind) where T<:Union{Complex{Float32}, Complex{Float64}, Float32, Float64} at /Users/solver/.julia/packages/FastTransforms/vEjxF/src/chebyshevtransform.jl:29
  plan_chebyshevtransform(::AbstractArray{T<:Union{Complex{BigFloat}, BigFloat},1}; kind) where T<:Union{Complex{BigFloat}, BigFloat} at /Users/solver/Projects/ApproxFun.jl/src/Extras/fftGeneric.jl:49
Stacktrace:
 [1] plan_transform(::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}, ::Array{IntervalArithmetic.Interval{Float64},1}) at /Users/solver/Projects/ApproxFunOrthogonalPolynomials.jl/src/Spaces/Chebyshev/Chebyshev.jl:65
 [2] transform(::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}, ::Array{IntervalArithmetic.Interval{Float64},1}) at /Users/solver/Projects/ApproxFunBase.jl/src/Space.jl:427
 [3] default_Fun(::Type{IntervalArithmetic.Interval{Float64}}, ::Function, ::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}, ::Array{IntervalArithmetic.Interval{Float64},1}, ::Type{Val{false}}) at /Users/solver/Projects/ApproxFunBase.jl/src/constructors.jl:44
 [4] default_Fun(::ApproxFunBase.DFunction, ::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}, ::Int64, ::Type{Val{false}}) at /Users/solver/Projects/ApproxFunBase.jl/src/constructors.jl:57
 [5] default_Fun(::Function, ::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}, ::Int64) at /Users/solver/Projects/ApproxFunBase.jl/src/constructors.jl:72
 [6] default_Fun(::ApproxFunBase.DFunction, ::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}) at /Users/solver/Projects/ApproxFunBase.jl/src/constructors.jl:121
 [7] Fun(::Function, ::Chebyshev{Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}},IntervalArithmetic.Interval{Float64}}) at /Users/solver/Projects/ApproxFunBase.jl/src/constructors.jl:177
 [8] Fun(::Function, ::Interval{:closed,:closed,IntervalArithmetic.Interval{Float64}}) at /Users/solver/Projects/ApproxFunBase.jl/src/constructors.jl:173
 [9] top-level scope at none:0

Ideally, the transform would return a data structure representing an infinite vector with exponential decay. It's actually already possible to construct such a thing using InfiniteArrays.jl:

julia> BroadcastArray(IntervalArithmetic.Interval, -2.0 .^(-(1:∞)), 2.0 .^(-(1:∞)))
BroadcastArray{IntervalArithmetic.Interval{Float64},1,Base.Broadcast.Broadcasted{LazyArrays.LazyArrayStyle{1},Tuple{InfiniteArrays.OneToInf{Int64}},Type{IntervalArithmetic.Interval},Tuple{BroadcastArray{Float64,1,Base.Broadcast.Broadcasted{LazyArrays.LazyArrayStyle{1},Tuple{InfiniteArrays.OneToInf{Int64}},typeof(-),Tuple{BroadcastArray{Float64,1,Base.Broadcast.Broadcasted{LazyArrays.LazyArrayStyle{1},Tuple{InfiniteArrays.OneToInf{Int64}},typeof(^),Tuple{Float64,InfiniteArrays.InfStepRange{Int64,Int64}}}}}}},BroadcastArray{Float64,1,Base.Broadcast.Broadcasted{LazyArrays.LazyArrayStyle{1},Tuple{InfiniteArrays.OneToInf{Int64}},typeof(^),Tuple{Float64,InfiniteArrays.InfStepRange{Int64,Int64}}}}}}} with indices OneToInf():
 [-0.5, 0.5]                
 [-0.25, 0.25]              
 [-0.125, 0.125]            
 [-0.0625, 0.0625]          
 [-0.03125, 0.03125]        
 [-0.015625, 0.015625]      
 [-0.0078125, 0.0078125]    
 [-0.00390625, 0.00390625]  
 [-0.00195313, 0.00195313]  
 [-0.000976563, 0.000976563]
 [-0.000488282, 0.000488282]
 [-0.000244141, 0.000244141]
 [-0.000122071, 0.000122071]
 [-6.10352e-05, 6.10352e-05]
 [-3.05176e-05, 3.05176e-05]
 [-1.52588e-05, 1.52588e-05]
 [-7.6294e-06, 7.6294e-06]  
 [-3.8147e-06, 3.8147e-06]  
            

This would be combined with a finite vector of coefficients using Vcat. Some mathematical thought is needed on how to calculate this automatically, which would require bounding in a Bernstein ellipse.

@dpsanders FYI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions