Average Error: 9.3 → 0.4
Time: 8.3s
Precision: 64
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t\]
\[\log y \cdot x + \mathsf{fma}\left(z, \log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right), -t\right)\]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\log y \cdot x + \mathsf{fma}\left(z, \log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right), -t\right)
double f(double x, double y, double z, double t) {
        double r470290 = x;
        double r470291 = y;
        double r470292 = log(r470291);
        double r470293 = r470290 * r470292;
        double r470294 = z;
        double r470295 = 1.0;
        double r470296 = r470295 - r470291;
        double r470297 = log(r470296);
        double r470298 = r470294 * r470297;
        double r470299 = r470293 + r470298;
        double r470300 = t;
        double r470301 = r470299 - r470300;
        return r470301;
}

double f(double x, double y, double z, double t) {
        double r470302 = y;
        double r470303 = log(r470302);
        double r470304 = x;
        double r470305 = r470303 * r470304;
        double r470306 = z;
        double r470307 = 1.0;
        double r470308 = log(r470307);
        double r470309 = r470307 * r470302;
        double r470310 = 0.5;
        double r470311 = 2.0;
        double r470312 = pow(r470302, r470311);
        double r470313 = pow(r470307, r470311);
        double r470314 = r470312 / r470313;
        double r470315 = r470310 * r470314;
        double r470316 = r470309 + r470315;
        double r470317 = r470308 - r470316;
        double r470318 = t;
        double r470319 = -r470318;
        double r470320 = fma(r470306, r470317, r470319);
        double r470321 = r470305 + r470320;
        return r470321;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.3
Target0.3
Herbie0.4
\[\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.3

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

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

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

    \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{fma}\left(z, \log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right), -t\right)}\right)\]
  6. Using strategy rm
  7. Applied fma-udef0.4

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

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

Reproduce

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

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

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