JuliaApproximation / JuliaApproximation/ApproxFun.jl

Integration of a function in default and Fourier spaces give incorrect results

Open
#746 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
559
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Integration in the default (Chebyshev between [-1,1], maybe?) and Fourier spaces gives incorrect results in the following code. Using Chebyshev with explicit bounds gives the correct result.

Sθ=PeriodicSegment(-π,π);
fn = Fun(θ -> sin(θ), Sθ);
D2 = Derivative(Sθ, 2);
L = -D2-10fn;
λ, v = ApproxFun.eigs(L, 500, tolerance=1E-10);

integrand = Fun(θ -> sin(θ)*v[1](θ)*v[2]'(θ) ); # seems to be Chebyshev, but somehow give incorrect result
integrand_fourier = Fun(θ -> sin(θ)*v[1](θ)*v[2]'(θ), Fourier(-π..π)); # incorrect
integrand_chebyshev = Fun(θ -> sin(θ)*v[1](θ)*v[2]'(θ), Chebyshev(-π..π)); # correct

println(integrate(integrand)(π)-integrate(integrand)(-π));
println(integrate(integrand_fourier)(π)-integrate(integrand_fourier)(-π));
println(integrate(integrand_chebyshev)(π)-integrate(integrand_chebyshev)(-π));

This outputs

0.0
0.0
2.42716878621213

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 by running the Julia reproducer in the issue and compare the three integration calls for the default, Fourier(-π..π), and Chebyshev(-π..π) spaces. Trace the integration behavior for the default and Fourier spaces; done means their results agree with the explicitly bounded Chebyshev result instead of returning 0.0.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.