Skip to content

Bit-burst algorithm version of BigMath.erf and BigMath.erfc - #458

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:bigmath_erf_bitburst
Aug 7, 2026
Merged

Bit-burst algorithm version of BigMath.erf and BigMath.erfc#458
tompng merged 1 commit into
ruby:masterfrom
tompng:bigmath_erf_bitburst

Conversation

@tompng

@tompngtompng commented Dec 1, 2025

Copy link
Copy Markdown
Member

Implement Bit-burst algorithm version of BigMath.erf and BigMath.erfc

Bit-burst algorithm implementation

Repeatedly apply Taylor expansion at increasing x.

  1. Split x into x0 + x1 + x2 + ...
  2. Calculate f(x0) by Taylor expansion(erf) or asymptotic expansion(erfc)
  3. Calculate f(x0 + x1) by Taylor expansion of f at x0
  4. Calculate f(x0 + x1 + x2) by Taylor expansion of f at x0 + x1
  5. So on...

Each Taylor expansion calculation uses binary-splitting method.
Details are described in source code comment.

Benchmark

# Erf of integerBigMath.erf(10,10000)# processing time: 0.324237s → 0.094490sBigMath.erf(10,100000)# processing time: 13.380194s → 1.044322s# Erf of full-precision numberBigMath.erf(BigDecimal(2).sqrt(10000),10000)# processing time: 0.501813s → 0.268420sBigMath.erf(BigDecimal(2).sqrt(100000),100000)# processing time: 21.532002s → 5.708505s# Erfc of integerBigMath.erfc(1234,10000)# processing time: 0.216168s → 0.094400sBigMath.erfc(1234,100000)# processing time: 19.402288s → 1.258311s# Erfc of full-precision numberBigMath.erfc(1234 + BigDecimal(4).div(7,10000),10000)# processing time: 4.616296s → 0.219974sBigMath.erfc(1234 + BigDecimal(4).div(7,20000),20000)# processing time: 23.335180s → 0.572202sBigMath.erfc(1234 + BigDecimal(4).div(7,100000),100000)# processing time: 1137.080714s → 5.270239s

@tompng
tompngforce-pushed the bigmath_erf_bitburst branch from 96e40ba to ace2d32CompareDecember 2, 2025 15:08
@mrknmrkn added this to the v4.1 milestone Dec 10, 2025
@tompng
tompngforce-pushed the bigmath_erf_bitburst branch 2 times, most recently from f60ba6f to ce7f6abCompareJanuary 30, 2026 17:16
@tompng
tompngforce-pushed the bigmath_erf_bitburst branch 4 times, most recently from c0f23ef to d035b6eCompareMay 8, 2026 19:28
@tompng
tompngforce-pushed the bigmath_erf_bitburst branch from d035b6e to 2b7d8dfCompareMay 17, 2026 07:58
@tompngtompng changed the title BigMath.erf/erfc with Bitburst algorithmBit-burst algorithm version of BigMath.erf and BigMath.erfcMay 17, 2026
@tompng
tompng marked this pull request as ready for review May 17, 2026 08:45
@tompng
tompngforce-pushed the bigmath_erf_bitburst branch from 2b7d8df to 7dc1b57CompareAugust 4, 2026 15:51
@tompng
tompngforce-pushed the bigmath_erf_bitburst branch from 7dc1b57 to 1931bacCompareAugust 4, 2026 16:51
@tompng
tompng merged commit 9099c24 into ruby:masterAug 7, 2026
83 checks passed
@tompng
tompng deleted the bigmath_erf_bitburst branch August 7, 2026 13:25
Sign up for freeto 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.

2 participants

@tompng@mrkn