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

Unreasonable number of Chebyshev coefficients required to approximate certain Gaussians #777

Open
johnbcoughlin opened this issue Jun 6, 2022 · 2 comments

Comments

@johnbcoughlin
Copy link

The following function requires north of 2 million Chebyshev coefficients to represent: Fun(x -> exp(-12(x + 4.9)^2), Chebyshev(-12..12))

This is in contrast to the function's "neighbors", see as follows:

for x0 in 4.7:0.05:5.1
    fun = Fun(x -> exp(-(x + x0)^2 / (1 / 12.0)), Chebyshev(-12..12))
    @show x0, length(fun.coefficients)
end

(x0, length(fun.coefficients)) = (4.7, 144)
(x0, length(fun.coefficients)) = (4.75, 144)
(x0, length(fun.coefficients)) = (4.8, 142)
(x0, length(fun.coefficients)) = (4.85, 143)
(x0, length(fun.coefficients)) = (4.9, 2097152)
(x0, length(fun.coefficients)) = (4.95, 141)
(x0, length(fun.coefficients)) = (5.0, 142)
(x0, length(fun.coefficients)) = (5.05, 142)
(x0, length(fun.coefficients)) = (5.1, 142)
@jishnub
Copy link
Member

jishnub commented Sep 26, 2022

julia> 2^21
2097152

This indicates that the approximation didn't converge (not entirely sure why). I'll try to look into this.

@macd
Copy link
Contributor

macd commented Aug 18, 2023

I have noticed similar behavior with abs if you try to use the constructor by passing in a function. If , instead you create a Fun for x on your domain and then write your desired Fun in terms of x, all is well. This should help to narrow down the problem? Here is an example:

julia @v1.11> x = Fun()
Fun(Chebyshev(), [0.0, 1.0])

julia @v1.11> x = Fun(Chebyshev(-12..12))
Fun(Chebyshev(-12 .. 12), [0.0, 12.0])

julia @v1.11> for x0 in 4.7:0.05:5.1
                  fun = exp(-(x + x0)^2 / (1 / 12.0))
                  @show x0, length(fun.coefficients)
              end

(x0, length(fun.coefficients)) = (4.7, 487)
(x0, length(fun.coefficients)) = (4.75, 487)
(x0, length(fun.coefficients)) = (4.8, 486)
(x0, length(fun.coefficients)) = (4.85, 485)
(x0, length(fun.coefficients)) = (4.9, 484)
(x0, length(fun.coefficients)) = (4.95, 483)
(x0, length(fun.coefficients)) = (5.0, 481)
(x0, length(fun.coefficients)) = (5.05, 480)
(x0, length(fun.coefficients)) = (5.1, 479)

julia @v1.11> 

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

3 participants