Average Error: 2.2 → 0.3
Time: 29.4s
Precision: 64
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\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{expm1}\left(\mathsf{log1p}\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 r97742 = x;
        double r97743 = y;
        double r97744 = z;
        double r97745 = log(r97744);
        double r97746 = t;
        double r97747 = r97745 - r97746;
        double r97748 = r97743 * r97747;
        double r97749 = a;
        double r97750 = 1.0;
        double r97751 = r97750 - r97744;
        double r97752 = log(r97751);
        double r97753 = b;
        double r97754 = r97752 - r97753;
        double r97755 = r97749 * r97754;
        double r97756 = r97748 + r97755;
        double r97757 = exp(r97756);
        double r97758 = r97742 * r97757;
        return r97758;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r97759 = 1.0;
        double r97760 = log(r97759);
        double r97761 = 0.5;
        double r97762 = z;
        double r97763 = 2.0;
        double r97764 = pow(r97762, r97763);
        double r97765 = pow(r97759, r97763);
        double r97766 = r97764 / r97765;
        double r97767 = b;
        double r97768 = fma(r97759, r97762, r97767);
        double r97769 = fma(r97761, r97766, r97768);
        double r97770 = r97760 - r97769;
        double r97771 = a;
        double r97772 = log(r97762);
        double r97773 = t;
        double r97774 = r97772 - r97773;
        double r97775 = y;
        double r97776 = r97774 * r97775;
        double r97777 = fma(r97770, r97771, r97776);
        double r97778 = exp(r97777);
        double r97779 = log1p(r97778);
        double r97780 = expm1(r97779);
        double r97781 = x;
        double r97782 = r97780 * r97781;
        return r97782;
}

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.2

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

    \[\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.3

    \[\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.3

    \[\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 expm1-log1p-u0.3

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\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{expm1}\left(\color{blue}{\mathsf{log1p}\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. Final simplification0.3

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\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 2019325 +o rules:numerics
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
  :precision binary64
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1 z)) b))))))