Skip to content

Add ModAB root finding algorithm#21535

Closed
Proektsoftbg wants to merge 7 commits intoroot-project:masterfrom
Proektsoftbg:master
Closed

Add ModAB root finding algorithm#21535
Proektsoftbg wants to merge 7 commits intoroot-project:masterfrom
Proektsoftbg:master

Conversation

@Proektsoftbg
Copy link

@Proektsoftbg Proektsoftbg commented Mar 7, 2026

Also include in testRootFindier. All tests passed! Make minor changes to BrentRootFinder.

This Pull request:

Adds ModAB root finding algorithm.

Changes or fixes:

  1. Added ModAB root finding algorithm (ModABRootFinder.cxx and ModABRootFinder.h).
  2. It was included in RootFinder.cxx, RootFinder.h and CMakeLists.txt.
  3. Also includеd in testRootFinder. All tests have passed!
  4. Made minor fixes to BrentRootFinder:
  • FIxed spelling errors in comments.
  • Removed redundant swap of input bounds when xlow > xup but rather assign directly to the proper fXMin and fXMax.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

Also include in testRootFindier. All tests passed!
Make minor chages to BrentRootFinder.
@Proektsoftbg
Copy link
Author

Here is what I get from ROOT tests:

Summary

Parabola f(x) = x^2 - 5

Function Time Average Number of calls
TF1::GetX() 4.99725e-06 87.435
BrentRootFinder 4.99725e-06 87.435
ModABRootFinder 5.00679e-06 10.595

Log parabola f(x) = (logx)^2 - 5

Function Time Average Number of calls
TF1::GetX() 5.00679e-06 80.43
BrentRootFinder fail fail
ModABRootFinder 0 15.68

GammaCDF

Function Time Average Number of calls
TF1::GetX() 0 35
BrentRootFinder 0 35
ModABRootFinder 0 5.5

Full

[==========] Running 9 tests from 3 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from Parabola
[ RUN      ] Parabola.TF1GetX
*************************************************************
Test for parabola function f(x) = x^2 - 5
         TF1::GetX()
*************************************************************
Average Time: 4.99725e-06
Average Number of calls to function: 87.435
[       OK ] Parabola.TF1GetX (3232 ms)
[ RUN      ] Parabola.BrentRootFinder
*************************************************************
Test for parabola function f(x) = x^2 + C
         RootFinder : BrentRootFinder
*************************************************************
Average Time: 4.99725e-06
Average Number of calls to function: 87.435
[       OK ] Parabola.BrentRootFinder (7 ms)
[ RUN      ] Parabola.ModABRootFinder
*************************************************************
Test for parabola function f(x) = x^2 + C
         RootFinder : ModABRootFinder
*************************************************************
Average Time: 5.00679e-06
Average Number of calls to function: 10.595
[       OK ] Parabola.ModABRootFinder (1 ms)
[----------] 3 tests from Parabola (3245 ms total)

[----------] 3 tests from LogParabola
[ RUN      ] LogParabola.TF1GetX
*************************************************************
Test for parabola log function f(x) = (logx)^2 - 5
         TF1::GetX()
*************************************************************
Average Time: 5.00679e-06
Average Number of calls to function: 80.43
[       OK ] LogParabola.TF1GetX (2 ms)
[ RUN      ] LogParabola.BrentRootFinder
*************************************************************
Test for parabola function f(x) = x^2 + C
         RootFinder : BrentRootFinder
*************************************************************
Average Time: 0
Average Number of calls to function: 87.435
[       OK ] LogParabola.BrentRootFinder (1 ms)
[ RUN      ] LogParabola.ModABRootFinder
*************************************************************
Test for parabola log function f(x) = (logx)^2 - 5
         RootFinder : ModABRootFinder
*************************************************************
Average Time: 0
Average Number of calls to function: 15.68
[       OK ] LogParabola.ModABRootFinder (4 ms)
[----------] 3 tests from LogParabola (10 ms total)

[----------] 3 tests from GammaCDF
[ RUN      ] GammaCDF.TF1GetX
*************************************************************
Test for  f(x) = gamma_cdf
         TF1::GetX()
*************************************************************
Average Time: 0
Average Number of calls to function: 35
[       OK ] GammaCDF.TF1GetX (1 ms)
[ RUN      ] GammaCDF.BrentRootFinder
*************************************************************
Test for  f(x) = gamma_cdf
         RootFinder : BrentRootFinder
*************************************************************
Average Time: 0
Average Number of calls to function: 35
[       OK ] GammaCDF.BrentRootFinder (0 ms)
[ RUN      ] GammaCDF.ModABRootFinder
*************************************************************
Test for  f(x) = gamma_cdf
         RootFinder : ModABRootFinder
*************************************************************
Average Time: 0
Average Number of calls to function: 5.5
[       OK ] GammaCDF.ModABRootFinder (0 ms)
[----------] 3 tests from GammaCDF (3 ms total)

[----------] Global test environment tear-down
[==========] 9 tests from 3 test suites ran. (3263 ms total)
[  PASSED  ] 9 tests.

Here are my isolated tests with 92 functions:
https://github.com/Proektsoftbg/Numerical/blob/main/Numerical-ROOT-CPP/root_benchmark_results.txt

@dpiparo dpiparo requested a review from hageboeck March 8, 2026 09:43
@dpiparo
Copy link
Member

dpiparo commented Mar 8, 2026

Thanks. I added @hageboeck, our math expert, in the set of reviewers. Meanwhile, I am letting the CI run.

@github-actions
Copy link

github-actions bot commented Mar 8, 2026

Test Results

     6 files       6 suites   19h 52m 4s ⏱️
 5 359 tests  5 355 ✅ 4 💤 0 ❌
18 511 runs  18 505 ✅ 6 💤 0 ❌

Results for commit 5fa2fbf.

♻️ This comment has been updated with latest results.

@Proektsoftbg
Copy link
Author

Great! If anything else is needed, I will be happy to assist.

Assign also y values when clamping x3 to avoid redundant re-evaluation
@Proektsoftbg
Copy link
Author

Hi!

Any updates on the review? Next week we will submit with the MIT Julia Lab guys an article about the ModAB algorithm in ACM TOMS. If we manage with the ROOT implementation until then I will like to add a reference.

@silverweed
Copy link
Contributor

The change is fine from my side but it needs to be approved by someone more familiar with the math package, like @hageboeck or perhaps @guitargeek

@silverweed
Copy link
Contributor

silverweed commented Mar 16, 2026

@Proektsoftbg the CI is failing because your branch is called master and this is unsupported by our github actions. Could you please reopen this PR with a different branch name?

@Proektsoftbg
Copy link
Author

OK. Thank you. I will post it later as a different branch.

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

Successfully merging this pull request may close these issues.

4 participants