Average Error: 4.8 → 4.8
Time: 1.4m
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)
double f(double x, double y, double z, double t) {
        double r20063590 = x;
        double r20063591 = y;
        double r20063592 = z;
        double r20063593 = r20063591 / r20063592;
        double r20063594 = t;
        double r20063595 = 1.0;
        double r20063596 = r20063595 - r20063592;
        double r20063597 = r20063594 / r20063596;
        double r20063598 = r20063593 - r20063597;
        double r20063599 = r20063590 * r20063598;
        return r20063599;
}

double f(double x, double y, double z, double t) {
        double r20063600 = x;
        double r20063601 = y;
        double r20063602 = 1.0;
        double r20063603 = z;
        double r20063604 = r20063602 / r20063603;
        double r20063605 = t;
        double r20063606 = 1.0;
        double r20063607 = r20063606 - r20063603;
        double r20063608 = r20063605 / r20063607;
        double r20063609 = -r20063608;
        double r20063610 = fma(r20063601, r20063604, r20063609);
        double r20063611 = r20063600 * r20063610;
        return r20063611;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.8
Target4.3
Herbie4.8
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt -7.623226303312042442144691872793570510727 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt 1.413394492770230216018398633584271456447 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \end{array}\]

Derivation

  1. Initial program 4.8

    \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
  2. Using strategy rm
  3. Applied div-inv4.8

    \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \frac{t}{1 - z}\right)\]
  4. Applied fma-neg4.8

    \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)}\]
  5. Final simplification4.8

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

Reproduce

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

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

  (* x (- (/ y z) (/ t (- 1.0 z)))))