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

Completely Wrong Evaluation at Point Near Zero for Fourier Series #947

Closed
cdstephens opened this issue Nov 18, 2024 · 3 comments
Closed

Comments

@cdstephens
Copy link

I am trying to use Optim.jl for univariate functions in tandem with ApproxFun.jl. However, there is a catastrophic bug that requires an awkward workaround. When I evaluate a Fourier series at a point close to zero, ApproxFun gives a completely incorrect result. Below is the minimal code that demonstrates this.

Input:

using ApproxFun
dF = Fourier(-pi..pi)
example = Fun(x -> cos(x), dF)
val_correct = example(0)
val_correct_2 =  example(2*pi + 1e-09)
val_wrong = example(1e-09)

Result:

Fourier(【-3.141592653589793,3.141592653589793❫)
Fun(Fourier(【-3.141592653589793,3.141592653589793❫), [5.62263e-17, -2.77556e-17, -1.0])
1.0
1.0
2.775556218710621e-26

This has also occurred for more complicated functions. Essentially, if I evaluate a Fourier series at some very small x, then the output will be close to zero. Here, 1e-09 is not particularly close to machine precision, so I can't see why this should be happening.

@jishnub
Copy link
Member

jishnub commented Nov 20, 2024

The issue seems to be that

julia> 1e-9  domain(example)
false

This should be true

@jishnub
Copy link
Member

jishnub commented Nov 26, 2024

This should be fixed by the version bump in JuliaApproximation/ApproxFunFourier.jl#130

@jishnub
Copy link
Member

jishnub commented Nov 26, 2024

The original issue appears to be resolved now. Please reopen if you can reproduce this for other values.

@jishnub jishnub closed this as completed Nov 26, 2024
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

2 participants