Average Error: 9.1 → 0.3
Time: 25.7s
Precision: 64
\[\left(x \cdot \log y + z \cdot \log \left(1.0 - y\right)\right) - t\]
\[\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, \frac{y}{1.0} \cdot \frac{y}{1.0}, \log 1.0 - 1.0 \cdot y\right), z, \mathsf{fma}\left(\log y, x, -t\right)\right)\]
\left(x \cdot \log y + z \cdot \log \left(1.0 - y\right)\right) - t
\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, \frac{y}{1.0} \cdot \frac{y}{1.0}, \log 1.0 - 1.0 \cdot y\right), z, \mathsf{fma}\left(\log y, x, -t\right)\right)
double f(double x, double y, double z, double t) {
        double r15864964 = x;
        double r15864965 = y;
        double r15864966 = log(r15864965);
        double r15864967 = r15864964 * r15864966;
        double r15864968 = z;
        double r15864969 = 1.0;
        double r15864970 = r15864969 - r15864965;
        double r15864971 = log(r15864970);
        double r15864972 = r15864968 * r15864971;
        double r15864973 = r15864967 + r15864972;
        double r15864974 = t;
        double r15864975 = r15864973 - r15864974;
        return r15864975;
}

double f(double x, double y, double z, double t) {
        double r15864976 = -0.5;
        double r15864977 = y;
        double r15864978 = 1.0;
        double r15864979 = r15864977 / r15864978;
        double r15864980 = r15864979 * r15864979;
        double r15864981 = log(r15864978);
        double r15864982 = r15864978 * r15864977;
        double r15864983 = r15864981 - r15864982;
        double r15864984 = fma(r15864976, r15864980, r15864983);
        double r15864985 = z;
        double r15864986 = log(r15864977);
        double r15864987 = x;
        double r15864988 = t;
        double r15864989 = -r15864988;
        double r15864990 = fma(r15864986, r15864987, r15864989);
        double r15864991 = fma(r15864984, r15864985, r15864990);
        return r15864991;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.1
Target0.3
Herbie0.3
\[\left(-z\right) \cdot \left(\left(0.5 \cdot \left(y \cdot y\right) + y\right) + \frac{\frac{1}{3}}{1.0 \cdot \left(1.0 \cdot 1.0\right)} \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - \left(t - x \cdot \log y\right)\]

Derivation

  1. Initial program 9.1

    \[\left(x \cdot \log y + z \cdot \log \left(1.0 - y\right)\right) - t\]
  2. Simplified9.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log \left(1.0 - y\right), z, \log y \cdot x - t\right)}\]
  3. Taylor expanded around 0 0.3

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \frac{y}{1.0} \cdot \frac{y}{1.0}, \log 1.0 - 1.0 \cdot y\right)}, z, \log y \cdot x - t\right)\]
  5. Using strategy rm
  6. Applied fma-neg0.3

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, \frac{y}{1.0} \cdot \frac{y}{1.0}, \log 1.0 - 1.0 \cdot y\right), z, \color{blue}{\mathsf{fma}\left(\log y, x, -t\right)}\right)\]
  7. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2}, \frac{y}{1.0} \cdot \frac{y}{1.0}, \log 1.0 - 1.0 \cdot y\right), z, \mathsf{fma}\left(\log y, x, -t\right)\right)\]

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"

  :herbie-target
  (- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 1/3 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))

  (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))