Average Error: 1.9 → 1.9
Time: 21.3s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\]
x + \left(y - x\right) \cdot \frac{z}{t}
\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)
double f(double x, double y, double z, double t) {
        double r24061059 = x;
        double r24061060 = y;
        double r24061061 = r24061060 - r24061059;
        double r24061062 = z;
        double r24061063 = t;
        double r24061064 = r24061062 / r24061063;
        double r24061065 = r24061061 * r24061064;
        double r24061066 = r24061059 + r24061065;
        return r24061066;
}

double f(double x, double y, double z, double t) {
        double r24061067 = z;
        double r24061068 = t;
        double r24061069 = r24061067 / r24061068;
        double r24061070 = y;
        double r24061071 = x;
        double r24061072 = r24061070 - r24061071;
        double r24061073 = fma(r24061069, r24061072, r24061071);
        return r24061073;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.9
Target2.1
Herbie1.9
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.88671875:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} \lt -0.0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Initial program 1.9

    \[x + \left(y - x\right) \cdot \frac{z}{t}\]
  2. Simplified1.9

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)}\]
  3. Final simplification1.9

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

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) -0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

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