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 r536400 = x;
        double r536401 = y;
        double r536402 = r536401 - r536400;
        double r536403 = z;
        double r536404 = t;
        double r536405 = r536403 / r536404;
        double r536406 = r536402 * r536405;
        double r536407 = r536400 + r536406;
        return r536407;
}

double f(double x, double y, double z, double t) {
        double r536408 = y;
        double r536409 = x;
        double r536410 = r536408 - r536409;
        double r536411 = z;
        double r536412 = t;
        double r536413 = r536411 / r536412;
        double r536414 = fma(r536410, r536413, r536409);
        return r536414;
}

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))))