JuliaApproximation / JuliaApproximation/ApproxFunOrthogonalPolynomials.jl

ApproxFun+IntervalArithmetic: Add support for constructor

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
4
Forks
11
Avg merge
5h 31m
Merged PRs (30d)
4

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with plan_transform in src/Spaces/Chebyshev/Chebyshev.jl and the constructor path through ApproxFunBase/src/constructors.jl shown in the stack trace. Review the existing generic transform implementations and the InfiniteArrays example in the issue. Done means Fun supports IntervalArithmetic values by producing the proposed finite-plus-infinite coefficient representation with Bernstein-ellipse bounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.