scikit-hep / scikit-hep/vector
Numerically stable computation of invariant mass
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 99
- Forks
- 42
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 6
Description
I recently developed a formula to compute the invariant mass for a two-body decay in a numerically stable way from the momenta of the daughters and their assumed masses. The algorithm is described and benchmarked here:
https://github.com/HDembinski/essays/blob/master/Numerically%20stable%20calculation%20of%20invariant%20mass.ipynb
The numerical instability arises from the subtractive cancellation in this formula

for m1,m2 << |p1|, |p2|.
I am not sure whether this fits in here, but I wanted to advertise it. As you can see in my notebook, my formula improves the accuracy dramatically over the naive formula. It further allows one to perform the whole calculation in single precision instead of double precision, which frees CPU registers and should accelerate code that benefits from SIMD instructions. Single precision is sufficiently accurate to describe the resolution of experimental data, we only habitually convert to double precision because we usually do not use numerically stable formulas.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading and running the linked Numerically stable calculation of invariant mass notebook, including its formula and benchmarks. Compare the proposed method with the repository's current invariant-mass computation, then determine the integration scope and validation needed; the work is done when the approach and its accuracy and performance impact are established in the project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100