Average Error: 2.0 → 0.3
Time: 28.9s
Precision: 64
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}\]
\[\mathsf{log1p}\left(\sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)} \cdot \sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)}\right) \cdot x\]
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
\mathsf{log1p}\left(\sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)} \cdot \sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)}\right) \cdot x
double f(double x, double y, double z, double t, double a, double b) {
        double r98669 = x;
        double r98670 = y;
        double r98671 = z;
        double r98672 = log(r98671);
        double r98673 = t;
        double r98674 = r98672 - r98673;
        double r98675 = r98670 * r98674;
        double r98676 = a;
        double r98677 = 1.0;
        double r98678 = r98677 - r98671;
        double r98679 = log(r98678);
        double r98680 = b;
        double r98681 = r98679 - r98680;
        double r98682 = r98676 * r98681;
        double r98683 = r98675 + r98682;
        double r98684 = exp(r98683);
        double r98685 = r98669 * r98684;
        return r98685;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r98686 = 1.0;
        double r98687 = log(r98686);
        double r98688 = 0.5;
        double r98689 = z;
        double r98690 = 2.0;
        double r98691 = pow(r98689, r98690);
        double r98692 = pow(r98686, r98690);
        double r98693 = r98691 / r98692;
        double r98694 = b;
        double r98695 = fma(r98686, r98689, r98694);
        double r98696 = fma(r98688, r98693, r98695);
        double r98697 = r98687 - r98696;
        double r98698 = a;
        double r98699 = log(r98689);
        double r98700 = t;
        double r98701 = r98699 - r98700;
        double r98702 = y;
        double r98703 = r98701 * r98702;
        double r98704 = fma(r98697, r98698, r98703);
        double r98705 = exp(r98704);
        double r98706 = expm1(r98705);
        double r98707 = sqrt(r98706);
        double r98708 = r98707 * r98707;
        double r98709 = log1p(r98708);
        double r98710 = x;
        double r98711 = r98709 * r98710;
        return r98711;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 2.0

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}\]
  2. Simplified1.8

    \[\leadsto \color{blue}{e^{\mathsf{fma}\left(y, \log z - t, a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \cdot x}\]
  3. Taylor expanded around 0 0.2

    \[\leadsto e^{\mathsf{fma}\left(y, \log z - t, a \cdot \left(\color{blue}{\left(\log 1 - \left(\frac{1}{2} \cdot \frac{{z}^{2}}{{1}^{2}} + 1 \cdot z\right)\right)} - b\right)\right)} \cdot x\]
  4. Simplified0.2

    \[\leadsto e^{\mathsf{fma}\left(y, \log z - t, a \cdot \left(\color{blue}{\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, 1 \cdot z\right)\right)} - b\right)\right)} \cdot x\]
  5. Using strategy rm
  6. Applied log1p-expm1-u0.3

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(e^{\mathsf{fma}\left(y, \log z - t, a \cdot \left(\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, 1 \cdot z\right)\right) - b\right)\right)}\right)\right)} \cdot x\]
  7. Simplified0.3

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)}\right) \cdot x\]
  8. Using strategy rm
  9. Applied add-sqr-sqrt0.3

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)} \cdot \sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)}}\right) \cdot x\]
  10. Final simplification0.3

    \[\leadsto \mathsf{log1p}\left(\sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)} \cdot \sqrt{\mathsf{expm1}\left(e^{\mathsf{fma}\left(\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{{z}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, z, b\right)\right), a, \left(\log z - t\right) \cdot y\right)}\right)}\right) \cdot x\]

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))