Average Error: 9.7 → 0.3
Time: 28.8s
Precision: 64
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t\]
\[\mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{1} \cdot \frac{y}{1}, \frac{-1}{2}, \log 1 - y \cdot 1\right), z, \mathsf{fma}\left(\log y, x, -t\right)\right)\]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{1} \cdot \frac{y}{1}, \frac{-1}{2}, \log 1 - y \cdot 1\right), z, \mathsf{fma}\left(\log y, x, -t\right)\right)
double f(double x, double y, double z, double t) {
        double r14027873 = x;
        double r14027874 = y;
        double r14027875 = log(r14027874);
        double r14027876 = r14027873 * r14027875;
        double r14027877 = z;
        double r14027878 = 1.0;
        double r14027879 = r14027878 - r14027874;
        double r14027880 = log(r14027879);
        double r14027881 = r14027877 * r14027880;
        double r14027882 = r14027876 + r14027881;
        double r14027883 = t;
        double r14027884 = r14027882 - r14027883;
        return r14027884;
}

double f(double x, double y, double z, double t) {
        double r14027885 = y;
        double r14027886 = 1.0;
        double r14027887 = r14027885 / r14027886;
        double r14027888 = r14027887 * r14027887;
        double r14027889 = -0.5;
        double r14027890 = log(r14027886);
        double r14027891 = r14027885 * r14027886;
        double r14027892 = r14027890 - r14027891;
        double r14027893 = fma(r14027888, r14027889, r14027892);
        double r14027894 = z;
        double r14027895 = log(r14027885);
        double r14027896 = x;
        double r14027897 = t;
        double r14027898 = -r14027897;
        double r14027899 = fma(r14027895, r14027896, r14027898);
        double r14027900 = fma(r14027893, r14027894, r14027899);
        return r14027900;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 9.7

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{y}{1} \cdot \frac{y}{1}, \frac{-1}{2}, \log 1 - 1 \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{y}{1} \cdot \frac{y}{1}, \frac{-1}{2}, \log 1 - 1 \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{y}{1} \cdot \frac{y}{1}, \frac{-1}{2}, \log 1 - y \cdot 1\right), z, \mathsf{fma}\left(\log y, x, -t\right)\right)\]

Reproduce

herbie shell --seed 2019172 +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) (* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))

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