Average Error: 13.8 → 13.8
Time: 7.4s
Precision: 64
\[1 - \left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(0.25482959199999999 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(-0.284496735999999972 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(1.42141374100000006 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(-1.45315202700000001 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot 1.0614054289999999\right)\right)\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}\]
\[\frac{\frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)} \cdot \left(\mathsf{fma}\left(1.42141374100000006, \log \left(e^{\frac{1}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{2}}}\right), 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)\right)}{e^{{\left(\left|x\right|\right)}^{2}}} + 1\]
1 - \left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(0.25482959199999999 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(-0.284496735999999972 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(1.42141374100000006 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(-1.45315202700000001 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot 1.0614054289999999\right)\right)\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}
\frac{\frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)} \cdot \left(\mathsf{fma}\left(1.42141374100000006, \log \left(e^{\frac{1}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{2}}}\right), 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)\right)}{e^{{\left(\left|x\right|\right)}^{2}}} + 1
double f(double x) {
        double r126602 = 1.0;
        double r126603 = 0.3275911;
        double r126604 = x;
        double r126605 = fabs(r126604);
        double r126606 = r126603 * r126605;
        double r126607 = r126602 + r126606;
        double r126608 = r126602 / r126607;
        double r126609 = 0.254829592;
        double r126610 = -0.284496736;
        double r126611 = 1.421413741;
        double r126612 = -1.453152027;
        double r126613 = 1.061405429;
        double r126614 = r126608 * r126613;
        double r126615 = r126612 + r126614;
        double r126616 = r126608 * r126615;
        double r126617 = r126611 + r126616;
        double r126618 = r126608 * r126617;
        double r126619 = r126610 + r126618;
        double r126620 = r126608 * r126619;
        double r126621 = r126609 + r126620;
        double r126622 = r126608 * r126621;
        double r126623 = r126605 * r126605;
        double r126624 = -r126623;
        double r126625 = exp(r126624);
        double r126626 = r126622 * r126625;
        double r126627 = r126602 - r126626;
        return r126627;
}

double f(double x) {
        double r126628 = 1.0;
        double r126629 = -r126628;
        double r126630 = x;
        double r126631 = fabs(r126630);
        double r126632 = 0.3275911;
        double r126633 = fma(r126631, r126632, r126628);
        double r126634 = r126629 / r126633;
        double r126635 = 1.421413741;
        double r126636 = 1.0;
        double r126637 = fma(r126632, r126631, r126628);
        double r126638 = 2.0;
        double r126639 = pow(r126637, r126638);
        double r126640 = r126636 / r126639;
        double r126641 = exp(r126640);
        double r126642 = log(r126641);
        double r126643 = 0.254829592;
        double r126644 = fma(r126635, r126642, r126643);
        double r126645 = 0.284496736;
        double r126646 = r126636 / r126637;
        double r126647 = 1.453152027;
        double r126648 = r126636 * r126647;
        double r126649 = 3.0;
        double r126650 = pow(r126637, r126649);
        double r126651 = r126648 / r126650;
        double r126652 = fma(r126645, r126646, r126651);
        double r126653 = 1.061405429;
        double r126654 = r126636 * r126653;
        double r126655 = 4.0;
        double r126656 = pow(r126637, r126655);
        double r126657 = r126654 / r126656;
        double r126658 = r126652 - r126657;
        double r126659 = r126644 - r126658;
        double r126660 = r126634 * r126659;
        double r126661 = pow(r126631, r126638);
        double r126662 = exp(r126661);
        double r126663 = r126660 / r126662;
        double r126664 = r126663 + r126628;
        return r126664;
}

Error

Bits error versus x

Derivation

  1. Initial program 13.8

    \[1 - \left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(0.25482959199999999 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(-0.284496735999999972 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(1.42141374100000006 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot \left(-1.45315202700000001 + \frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|} \cdot 1.0614054289999999\right)\right)\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}\]
  2. Simplified13.8

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|}, \mathsf{fma}\left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|}, \mathsf{fma}\left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|}, \mathsf{fma}\left(\frac{1}{1 + 0.32759110000000002 \cdot \left|x\right|}, 1.0614054289999999, -1.45315202700000001\right), 1.42141374100000006\right), -0.284496735999999972\right), 0.25482959199999999\right)}{e^{\left|x\right| \cdot \left|x\right|}}, \frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)}, 1\right)}\]
  3. Taylor expanded around 0 14.5

    \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\left(1.0614054289999999 \cdot \frac{1}{{\left(0.32759110000000002 \cdot \left|x\right| + 1\right)}^{4}} + \left(1.42141374100000006 \cdot \frac{1}{{\left(0.32759110000000002 \cdot \left|x\right| + 1\right)}^{2}} + 0.25482959199999999\right)\right) - \left(1.45315202700000001 \cdot \frac{1}{{\left(0.32759110000000002 \cdot \left|x\right| + 1\right)}^{3}} + 0.284496735999999972 \cdot \frac{1}{0.32759110000000002 \cdot \left|x\right| + 1}\right)}}{e^{\left|x\right| \cdot \left|x\right|}}, \frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)}, 1\right)\]
  4. Simplified13.8

    \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\mathsf{fma}\left(1.42141374100000006, \frac{1}{{\left(0.32759110000000002 \cdot \left|x\right| + 1\right)}^{2}}, 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)}}{e^{\left|x\right| \cdot \left|x\right|}}, \frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)}, 1\right)\]
  5. Using strategy rm
  6. Applied add-log-exp13.8

    \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(1.42141374100000006, \color{blue}{\log \left(e^{\frac{1}{{\left(0.32759110000000002 \cdot \left|x\right| + 1\right)}^{2}}}\right)}, 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)}{e^{\left|x\right| \cdot \left|x\right|}}, \frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)}, 1\right)\]
  7. Simplified13.8

    \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(1.42141374100000006, \log \color{blue}{\left(e^{\frac{1}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{2}}}\right)}, 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)}{e^{\left|x\right| \cdot \left|x\right|}}, \frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)}, 1\right)\]
  8. Using strategy rm
  9. Applied fma-udef13.8

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(1.42141374100000006, \log \left(e^{\frac{1}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{2}}}\right), 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)}{e^{\left|x\right| \cdot \left|x\right|}} \cdot \frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)} + 1}\]
  10. Simplified13.8

    \[\leadsto \color{blue}{\frac{\frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)} \cdot \left(\mathsf{fma}\left(1.42141374100000006, \log \left(e^{\frac{1}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{2}}}\right), 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)\right)}{e^{{\left(\left|x\right|\right)}^{2}}}} + 1\]
  11. Final simplification13.8

    \[\leadsto \frac{\frac{-1}{\mathsf{fma}\left(\left|x\right|, 0.32759110000000002, 1\right)} \cdot \left(\mathsf{fma}\left(1.42141374100000006, \log \left(e^{\frac{1}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{2}}}\right), 0.25482959199999999\right) - \left(\mathsf{fma}\left(0.284496735999999972, \frac{1}{\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)}, \frac{1 \cdot 1.45315202700000001}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{3}}\right) - \frac{1 \cdot 1.0614054289999999}{{\left(\mathsf{fma}\left(0.32759110000000002, \left|x\right|, 1\right)\right)}^{4}}\right)\right)}{e^{{\left(\left|x\right|\right)}^{2}}} + 1\]

Reproduce

herbie shell --seed 2020036 +o rules:numerics
(FPCore (x)
  :name "Jmat.Real.erf"
  :precision binary64
  (- 1 (* (* (/ 1 (+ 1 (* 0.3275911 (fabs x)))) (+ 0.254829592 (* (/ 1 (+ 1 (* 0.3275911 (fabs x)))) (+ -0.284496736 (* (/ 1 (+ 1 (* 0.3275911 (fabs x)))) (+ 1.421413741 (* (/ 1 (+ 1 (* 0.3275911 (fabs x)))) (+ -1.453152027 (* (/ 1 (+ 1 (* 0.3275911 (fabs x)))) 1.061405429))))))))) (exp (- (* (fabs x) (fabs x)))))))