Average Error: 9.7 → 0.3
Time: 29.1s
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 r18552038 = x;
        double r18552039 = y;
        double r18552040 = log(r18552039);
        double r18552041 = r18552038 * r18552040;
        double r18552042 = z;
        double r18552043 = 1.0;
        double r18552044 = r18552043 - r18552039;
        double r18552045 = log(r18552044);
        double r18552046 = r18552042 * r18552045;
        double r18552047 = r18552041 + r18552046;
        double r18552048 = t;
        double r18552049 = r18552047 - r18552048;
        return r18552049;
}

double f(double x, double y, double z, double t) {
        double r18552050 = y;
        double r18552051 = 1.0;
        double r18552052 = r18552050 / r18552051;
        double r18552053 = r18552052 * r18552052;
        double r18552054 = -0.5;
        double r18552055 = log(r18552051);
        double r18552056 = r18552050 * r18552051;
        double r18552057 = r18552055 - r18552056;
        double r18552058 = fma(r18552053, r18552054, r18552057);
        double r18552059 = z;
        double r18552060 = log(r18552050);
        double r18552061 = x;
        double r18552062 = t;
        double r18552063 = -r18552062;
        double r18552064 = fma(r18552060, r18552061, r18552063);
        double r18552065 = fma(r18552058, r18552059, r18552064);
        return r18552065;
}

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))