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

roots sometimes cannot find the correct root(s) #89

Open
islent opened this issue Feb 16, 2022 · 0 comments
Open

roots sometimes cannot find the correct root(s) #89

islent opened this issue Feb 16, 2022 · 0 comments

Comments

@islent
Copy link

islent commented Feb 16, 2022

MWE:

using Dierckx
x = [
    -7.800000000000001,
    -7.7,
    -7.6000000000000005,
    -7.5,
    -7.4,
    -7.300000000000001,
];

y = [
    -0.02749549159389436,
    -0.01838389014507258,
    -0.00921755334192842,
     1.1102230246251565e-16,
     0.009265146320801443,
     0.018574158954026365,
];

spline = Spline1D(x,y)
roots(spline) #! No root

spline = Spline1D(x,y,s=1.0)
roots(spline) # correct


y2 = [
    -0.02749549159389436,
    -0.01838389014507258,
    -0.00921755334192842,
     0.0,
     0.009265146320801443,
     0.018574158954026365,
];

spline = Spline1D(x,y2)
roots(spline) # correct


y3 = [
    -0.02749549159389436,
    -0.01838389014507258,
    -0.00921755334192842,
    1.1102230246251565e-14,
     0.009265146320801443,
     0.018574158954026365,
];

spline = Spline1D(x,y3)
roots(spline) #! No root


y4 = [
    -0.02749549159389436,
    -0.01838389014507258,
    -0.00921755334192842,
    1.1102230246251565e-13,
     0.009265146320801443,
     0.018574158954026365,
];

spline = Spline1D(x,y4)
roots(spline) # correct

Output:

julia> using Dierckx

julia> x = [                                                                                                                                              
           -7.800000000000001,                                                                                                                            
           -7.7,                                                                                                                                          
           -7.6000000000000005,                                                                                                                           
           -7.5,                                                                                                                                          
           -7.4,                                                                                                                                          
           -7.300000000000001,                                                                                                                            
       ];

julia> 

julia> y = [                                                                                                                                              
           -0.02749549159389436,                                                                                                                          
               -0.01838389014507258,                                                                                                                      
           -0.00921755334192842,                                                                                                                          
            1.1102230246251565e-16,                                                                                                                       
            0.009265146320801443,                                                                                                                         
            0.018574158954026365,                                                                                                                         
       ];

julia> 

julia> spline = Spline1D(x,y)
Spline1D(knots=[-7.800000000000001, -7.6000000000000005, -7.5, -7.300000000000001], k=3, extrapolation="nearest", residual=0.0)

julia> roots(spline) #! No root
Float64[]

julia> 

julia> spline = Spline1D(x,y,s=1.0)
Spline1D(knots=[-7.800000000000001, -7.300000000000001], k=3, extrapolation="nearest", residual=1.5429392612813467e-15)

julia> y4 = [
           -0.02749549159389436,
           -0.01838389014507258,
           -0.00921755334192842,
           1.1102230246251565e-13,
            0.009265146320801443,
            0.018574158954026365,
       ];

julia>

julia> spline = Spline1D(x,y4)
Spline1D(knots=[-7.800000000000001, -7.6000000000000005, -7.5, -7.300000000000001], k=3, extrapolation="nearest", residual=0.0)

julia> roots(spline) # correct
1-element Vector{Float64}:
 -7.500000000000101

Environment:

julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) W-10885M CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
  JULIA_DEPOT_PATH = E:\.julia
  JULIA_NUM_THREADS = 8
  JULIA_EDITOR = code

(@v1.7) pkg> st Dierckx
      Status `E:\.julia\environments\v1.7\Project.toml`
  [39dd38d3] Dierckx v0.5.2
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