[Math] Laplacian: error in the finite differences formulas#22809
[Math] Laplacian: error in the finite differences formulas#22809dpiparo wants to merge 3 commits into
Conversation
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
Test Results 23 files 23 suites 3d 15h 10m 44s ⏱️ Results for commit 03b8ecd. |
guitargeek
left a comment
There was a problem hiding this comment.
Thanks for the fixes! I'm unsure if they should go in like this though.
I think we should either:
- Also write a test
- Remove
TMath::Laplacian. If a function gave silently wrong results and nobody complained, it was apparently not important. This would also mitigate the risk that people get confused by getting silently different results from the same code (that alone also means that this change would have to be mentioned in the release notes).
Personally, I would just delete the code if it really gave wrong results, along with its sibling function TMath::Gradient for consistency. But I'd also be fine with keeping it, as long as a test is implemented and release notes mention the silent math change.
|
Sorry, I looked into the history only now and realized this function was only introduced 2 years ago, and requested by @ferdymercury: In that case, I'd give it more of a chance to stay in ROOT as long as we have a test. |
It seems the test is already there? math/mathcore/test/testTMath.cxx But maybe it's not running correctly? |
|
I think the test of |
But shouldn't then the test have started failing after 03b8ecd ? |
The test fails, but it doesn't signal any failure to the outside. It just prints errors and then |

Fix a few typos and a mistake in Laplacian calculation.
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