Skip to content

Add initial Bessel rule support#109

Merged
ChrisRackauckas merged 1 commit into
JuliaSymbolics:mainfrom
AshtonSBradley:asb/add-bessel-symbolics
May 13, 2026
Merged

Add initial Bessel rule support#109
ChrisRackauckas merged 1 commit into
JuliaSymbolics:mainfrom
AshtonSBradley:asb/add-bessel-symbolics

Conversation

@AshtonSBradley
Copy link
Copy Markdown
Contributor

Summary

  • Adds initial rule-based support for Bessel integrals through SpecialFunctions.jl.
  • Teaches the Mathematica rule/test translators about Bessel, Hankel, and Airy function names.
  • Adds generic product distribution for algebraic sums multiplied by supported special functions.

Explanation

This adds a new Bessel rule file covering direct power-weighted Bessel integrals for besselj, bessely, besseli, and besselk, plus recurrence reductions for even positive order gaps such as x^3*besselj(0, a*x).

The implementation also makes special-function handling less Bessel-specific: products containing an x-dependent sum and a supported special-function factor are distributed before integration. That lets algebraic combinations like (x + x^3)*besselj(0, a*x) reuse the simpler Bessel rules, and it also applies to other known special functions such as Airy functions.

SpecialFunctions is added as a direct dependency because rule results now explicitly emit SpecialFunctions.besselj, bessely, besseli, besselk, Hankel, and Airy calls.

Tests

  • julia --project=@runic -m Runic --inplace src/methods/rule_based/rules2/8\ Special\ functions/8.1\ Bessel\ functions.jl test/methods/rule_based/test_special_functions.jl completed successfully.
  • julia --project=. test/methods/rule_based/test_special_functions.jl → 11 passed.
  • env TEST_GROUP=easy julia --project=. test/runtests.jl → 182 passed, 1 broken, 183 total.

Notes

  • This does not attempt the odd-gap Bessel cases that require broader special-function results such as Struve or hypergeometric forms.
  • No public API is changed beyond adding the direct SpecialFunctions dependency.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 13, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.51%. Comparing base (85a221a) to head (0f6cd70).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
...iscellaneous/0.1 Integrand simplification rules.jl 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #109       +/-   ##
===========================================
+ Coverage   13.91%   54.51%   +40.60%     
===========================================
  Files          22       22               
  Lines        4291     4309       +18     
===========================================
+ Hits          597     2349     +1752     
+ Misses       3694     1960     -1734     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisRackauckas ChrisRackauckas merged commit eabcec8 into JuliaSymbolics:main May 13, 2026
20 checks passed
@AshtonSBradley AshtonSBradley deleted the asb/add-bessel-symbolics branch May 13, 2026 04:11
@Bumblebee00
Copy link
Copy Markdown
Collaborator

This looks great, thank you for contributing and taking the time to add new rules @AshtonSBradley ! I am actually curious on why you added them, you use them in your research/work? did you create these rules manually yourself or you translated them from the Mathematica ones?

Some small notes:

  • in test/methods/rule_based/test_rule2.jl there is a testset called "special functions in rules" but is not meant to test the special functions form SpecialFunctions.jl, is meant to test only exp and sqrt. I called it special because they are shorthand notation for powers, and this complicates a bit the mathcing logic. So the test you added are not needded, i removed them and changed the name to a clearer one (here)
  • I dont really like the addition of rule 0_1_1 in the src/methods/rule_based/rules2/9 Miscellaneous/0.1 Integrand simplification rules.jl file, because those are rules executed for every expression and for most expressions this rule is useless. I moved it to src/methods/rule_based/rules2/8 Special functions/8.1 Bessel functions.jl with the index 8_1_0 so still before the other special functions rules (the tests still pass)
  • would be cool to also add rules for functions like besselj0 becasue this is whats happening now:
julia> integrate(x * SpecialFunctions.besselj(0, 2x))
(1//2)*x*besselj(1, 2x)

julia> integrate(x * SpecialFunctions.besselj0(2x))
∫(x*besselj0(2x), x)

but i actually dont know it that's really useful

  • test/methods/rule_based/test_special_functions.jl is ok for now because testing is a bit messy but the way to add tests is to insert them in a file in test/test_files add that filename to the list in test/rundifficulttests.jl

@Bumblebee00
Copy link
Copy Markdown
Collaborator

Also @ChrisRackauckas the next times please wait for also my review before merging into main 😃

@ChrisRackauckas
Copy link
Copy Markdown
Member

Okay yup, always happy to have other folks maintain. I didn't know if you were still around. But I also thought this was posted like weeks ago, and now I see it was just yesterday 😅 time is nebulous.

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