Average Error: 1.8 → 1.8
Time: 20.2s
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 r20271668 = x;
        double r20271669 = y;
        double r20271670 = r20271669 - r20271668;
        double r20271671 = z;
        double r20271672 = t;
        double r20271673 = r20271671 / r20271672;
        double r20271674 = r20271670 * r20271673;
        double r20271675 = r20271668 + r20271674;
        return r20271675;
}

double f(double x, double y, double z, double t) {
        double r20271676 = z;
        double r20271677 = t;
        double r20271678 = r20271676 / r20271677;
        double r20271679 = y;
        double r20271680 = x;
        double r20271681 = r20271679 - r20271680;
        double r20271682 = fma(r20271678, r20271681, r20271680);
        return r20271682;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.8
Target2.0
Herbie1.8
\[\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.8

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

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

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

Reproduce

herbie shell --seed 2019171 +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))))