Skip to content

[math] Fix TMath::Laplacian, add test and improve doxygen of finite difference methods#22823

Merged
hageboeck merged 5 commits into
root-project:masterfrom
hageboeck:tmath_fixes
Jul 17, 2026
Merged

[math] Fix TMath::Laplacian, add test and improve doxygen of finite difference methods#22823
hageboeck merged 5 commits into
root-project:masterfrom
hageboeck:tmath_fixes

Conversation

@hageboeck

@hageboeck hageboeck commented Jul 15, 2026

Copy link
Copy Markdown
Member

Note: Contains commits of #22809.

Here, the tests are added.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 3h 14m 47s ⏱️
 3 851 tests  3 850 ✅ 0 💤 1 ❌
71 774 runs  71 773 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 8b399e5.

♻️ This comment has been updated with latest results.

@ferdymercury ferdymercury left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!
I'd suggest

  • adding in the RelNotes of 6.38.x and 6.40.2 that using Laplacian lead to incorrect results.
  • fix preexisting TMathTests to not exit 0 and multiply by four refvalues

dpiparo and others added 3 commits July 16, 2026 13:53
The standard second-order central, backward and forward differences
contained a mistake: a factor-of-4 error.
See finite different coefficients here: https://en.wikipedia.org/wiki/Finite_difference_coefficient
Use a polynomial and its known derivatives to check the correctness of
the finite difference methods.
The test failed without any consequences because it was always returning
0. Other "tests" in this file will need to be updated to check their
   outputs in the future.

Furthermore:
- The second derivatives are unstable with short, so remove it from the
  test.
- The targets for the second derivatives were wrong by a factor 4; fix.
- Due to rounding, finite differences on integers don't exactly hit the
  target. Allow a delta of 1.
@hageboeck hageboeck added the clean build Ask CI to do non-incremental build on PR label Jul 16, 2026
@hageboeck
hageboeck merged commit f3d03cb into root-project:master Jul 17, 2026
58 of 61 checks passed
@hageboeck
hageboeck deleted the tmath_fixes branch July 17, 2026 09:46
@hageboeck

Copy link
Copy Markdown
Member Author

/backport to 6.40, 6.38

@root-project-bot

Copy link
Copy Markdown

Preparing to backport PR #22823 to branches 6.40 and 6.38 requested by hageboeck

@root-project-bot

Copy link
Copy Markdown

Something went wrong when assigning the PR or setting labels @hageboeck please see the logs

@root-project-bot

Copy link
Copy Markdown

Something went wrong when assigning the PR or setting labels @hageboeck please see the logs

@root-project-bot

Copy link
Copy Markdown

@hageboeck hageboeck changed the title [math] Add test and improve doxygen of finite difference methods [math] Fix TMath::Laplacian, add test and improve doxygen of finite difference methods Jul 17, 2026
@dpiparo

dpiparo commented Jul 17, 2026

Copy link
Copy Markdown
Member

/backport to 6.36

@root-project-bot

Copy link
Copy Markdown

Preparing to backport PR #22823 to branch 6.36 requested by dpiparo

@root-project-bot

Copy link
Copy Markdown

Something went wrong with the creation of the PR to backport to 6.36: @dpiparo please see the logs

@hageboeck hageboeck linked an issue Jul 17, 2026 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Assisted clean build Ask CI to do non-incremental build on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TMath::Laplacian computes wrong finite differences

4 participants