Average Error: 2.3 → 2.3
Time: 3.1s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\]
x + \left(y - x\right) \cdot \frac{z}{t}
\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)
double f(double x, double y, double z, double t) {
        double r604807 = x;
        double r604808 = y;
        double r604809 = r604808 - r604807;
        double r604810 = z;
        double r604811 = t;
        double r604812 = r604810 / r604811;
        double r604813 = r604809 * r604812;
        double r604814 = r604807 + r604813;
        return r604814;
}

double f(double x, double y, double z, double t) {
        double r604815 = y;
        double r604816 = x;
        double r604817 = r604815 - r604816;
        double r604818 = z;
        double r604819 = t;
        double r604820 = r604818 / r604819;
        double r604821 = fma(r604817, r604820, r604816);
        return r604821;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.3
Target2.3
Herbie2.3
\[\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 2.3

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

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

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

Reproduce

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

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.887) (+ 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))))