JuliaApproximation / JuliaApproximation/ApproxFun.jl
Division by Fun with root fails: `setdomain(::PiecewiseSpace,::ClosedInterval)` not implement
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 559
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
For a Fun with roots in its domain, division fails with the error message:
ERROR: MethodError: no method matching setdomain(::PiecewiseSpace{Tuple{Chebyshev{ChebyshevInterval{Float64}, Float64}, JacobiWeight{Chebyshev{IntervalSets.ClosedInterval{Float64}, Float64}, IntervalSets.ClosedInterval{Float64}, Float64, Int64}, JacobiWeight{Chebyshev{IntervalSets.ClosedInterval{Float64}, Float64}, IntervalSets.ClosedInterval{Float64}, Float64, Int64}}, DomainSets.UnionDomain{Float64, Tuple{ChebyshevInterval{Float64}, IntervalSets.ClosedInterval{Float64}, IntervalSets.ClosedInterval{Float64}}}, Float64}, ::IntervalSets.ClosedInterval{Int64})
Closest candidates are:
setdomain(!Matched::LogWeight, ::Domain)
@ ApproxFunSingularities ~/.julia/packages/ApproxFunSingularities/Qxudt/src/LogWeight.jl:26
setdomain(!Matched::Chebyshev, ::Domain)
@ ApproxFunOrthogonalPolynomials ~/.julia/packages/ApproxFunOrthogonalPolynomials/hVSG5/src/Spaces/Chebyshev/Chebyshev.jl:55
setdomain(!Matched::ApproxFunBase.ArraySpace, ::Domain)
@ ApproxFunBase ~/.julia/packages/ApproxFunBase/sNMxQ/src/Spaces/ArraySpace.jl:66
...
Stacktrace:
1. setdomain(f::Fun{PiecewiseSpace{Tuple{Chebyshev{ChebyshevInterval{Float64}, Float64}, JacobiWeight{Chebyshev{IntervalSets.ClosedInterval{Float64}, Float64}, IntervalSets.ClosedInterval{Float64}, Float64, Int64}, JacobiWeight{Chebyshev{IntervalSets.ClosedInterval{Float64}, Float64}, IntervalSets.ClosedInterval{Float64}, Float64, Int64}}, DomainSets.UnionDomain{Float64, Tuple{ChebyshevInterval{Float64}, IntervalSets.ClosedInterval{Float64}, IntervalSets.ClosedInterval{Float64}}}, Float64}, Float64, Vector{Float64}}, d::IntervalSets.ClosedInterval{Int64}) at
2. /(c::Fun{Chebyshev{IntervalSets.ClosedInterval{Int64}, Float64}, Float64, Vector{Float64}}, f::Fun{Chebyshev{IntervalSets.ClosedInterval{Int64}, Float64}, Float64, Vector{Float64}}) at
3. top-level scope
Here is a minimal example for reproducing the error
using ApproxFun
g = Fun(exp, Chebyshev(0..1))
f = Fun(x -> x-0.5, Chebyshev(0..1))
h = g/f
ApproxFun transforms the domain of f to the canonical domain of the space, splits the space domain at the roots and then attempts to call setdomain(space(f), d) where space(f) is a PiecewiseSpace and d the original domain. This is where the error occurs. It seems what is needed is a function which will map the PiecewiseSpace on the canonical domain to the original domain. While implementing such a transformation is not complicated, I currently lack the overview of the JuliaApproximation ecosystem and future plans to know where to best put this logic and which interfaces it needs to plug into. If you could point me into the right direction, I am happy to make a PR for this.
Remark: For the caseg = 1, the splitting of the domain of f is performed on the original domain without converting to the canonical space and no exception is thrown.
Temporary Fix
For anyone else encountering this issue: A temporary fix is to transform the problem to the canonical domain of your function space by hand.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal ApproxFun example in the issue and trace division through /(...) to setdomain(space(f), d). Read the existing setdomain methods and PiecewiseSpace interfaces to determine where the canonical-to-original domain transformation belongs. Done means dividing g = Fun(exp, Chebyshev(0..1)) by f = Fun(x -> x-0.5, Chebyshev(0..1)) no longer raises the reported MethodError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100