Skip to content

Incorrect integrals calculated when data is modified.Β #504

@densmojd

Description

@densmojd

Describe the bug 🐞

Output of integral is incorrect when the underlying data is modified.

Expected behavior

integral should return the same results if the underlying data is modified or a new interpolation is constructed with the modified data. At least, that is my understanding from the description of the cache_parameters keyword argument.

Minimal Reproducible Example πŸ‘‡

import DataInterpolations: CubicSpline, integral
t = [1.0, 2.0, 3.0 4.0]
u = t .^ 2 
spline = CubicSpline(u, t)
integral(spline, 1.0, 4.0) # 21.099999999999998

u .*= 2.0
integral(spline, 1.0, 4.0) # 42.599999999999994, which is not 2 * 21.099999999999998

spline = CubicSpline(u, t)
integral(spline, 1.0, 4.0) # 42.199999999999996, which is 2 * 21.099999999999998

Error & Stacktrace ⚠️

N/A

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
Status `~/projects/Project.toml`
  [82cc6244] DataInterpolations v8.9.0
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Status `~/projects/Manifest.toml`
  [bbf7d656] CommonSubexpressions v0.3.1
  [a8cc5b0e] Crayons v4.1.1
  [9a962f9c] DataAPI v1.16.0
  [82cc6244] DataInterpolations v8.9.0
  [e2d170a0] DataValueInterfaces v1.0.0
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.15.1
  [ffbed154] DocStringExtensions v0.9.5
  [4e289a0a] EnumX v1.0.6
  [64ca27bc] FindFirstFunctions v1.8.0
  [f6369f11] ForwardDiff v1.3.2
  [92d709cd] IrrationalConstants v0.2.6
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.7.1
  [b964fa9f] LaTeXStrings v1.4.0
  [2ab3a3ac] LogExpFunctions v0.3.29
  [1914dd2f] MacroTools v0.5.16
  [77ba4419] NaNMath v1.1.3
  [bac558e1] OrderedCollections v1.8.1
βŒ… [aea7be01] PrecompileTools v1.2.1
  [21216c6a] Preferences v1.5.1
  [08abe8d2] PrettyTables v3.2.3
  [3cdcf5f2] RecipesBase v1.3.4
  [189a3867] Reexport v1.2.2
  [276daf66] SpecialFunctions v2.7.1
  [1e83bf80] StaticArraysCore v1.4.4
  [892a3eda] StringManipulation v0.4.2
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.12.1
  [efe28fd5] OpenSpecFun_jll v0.5.6+0
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [b77e0a4c] InteractiveUtils v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [d6f4376e] Markdown v1.11.0
  [de0858da] Printf v1.11.0
  [3fa0cd96] REPL v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [6462fe0b] Sockets v1.11.0
  [f489334b] StyledStrings v1.11.0
  [fa267f1f] TOML v1.0.3
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [4536629a] OpenBLAS_jll v0.3.27+1
  [05823500] OpenLibm_jll v0.8.5+0
  [8e850b90] libblastrampoline_jll v5.11.0+0
Info Packages marked with βŒ… have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
  • Output of versioninfo()
Julia Version 1.11.7
Commit f2b3dbda30a (2025-09-08 12:10 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 28 Γ— Intel(R) Core(TM) i7-14700HX
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 28 virtual cores)

Additional context

  • I have only tried this using CubicSpline; I don't know if other interpolations have the same issue.
  • I see similar behavior when using extrapolation = ExtrapolationType.Extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions