Skip to content

Add ModAB root finding algorithm#21535

Open
Proektsoftbg wants to merge 5 commits intoroot-project:masterfrom
Proektsoftbg:master
Open

Add ModAB root finding algorithm#21535
Proektsoftbg wants to merge 5 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   18h 7m 23s ⏱️
 5 327 tests  5 306 ✅ 21 💤 0 ❌
17 318 runs  17 309 ✅  9 💤 0 ❌

Results for commit f098eda.

@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
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.

3 participants