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

Division by Fun with root fails: setdomain(::PiecewiseSpace,::ClosedInterval) not implement #912

Open
LucasAschenbach opened this issue Aug 28, 2023 · 0 comments

Comments

@LucasAschenbach
Copy link
Contributor

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.

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

1 participant