Skip to content

Subtracting two simple, seemingly compatible functions (f - g) results in wrong answer upon evaluation (typeof(f) = Chebyshev ⨁ CosSpace ⨁ SinSpace and typeof(g) = Chebyshev) #646

@krsteffen

Description

@krsteffen
using ApproxFun
Dc = Chebyshev(Interval(0,1.))
Df = Fourier(Interval(0,1.))
rx = Fun(t -> cospi(2*t), Df)
ry = Fun(t -> sinpi(2*t), Df)
twoπx = Fun(x -> 2π*x, Dc)
ell = sqrt(differentiate(rx)^2 + differentiate(ry)^2)
L = cumsum(ell)
println(L(1) == twoπx(1)) # expected value: true
println((L - twoπx)(1) ≈ 0) # therefore, expected value: true
println((L - twoπx)(1) == L(1)) # expected value: false

Doing this on a chalkboard we would find L := 2πx and so (L - twoπx) ≡ 0. However, the actual results from this example are: true, false, true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions