Average Error: 2.1 → 2.1
Time: 2.7s
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 r478331 = x;
        double r478332 = y;
        double r478333 = r478332 - r478331;
        double r478334 = z;
        double r478335 = t;
        double r478336 = r478334 / r478335;
        double r478337 = r478333 * r478336;
        double r478338 = r478331 + r478337;
        return r478338;
}

double f(double x, double y, double z, double t) {
        double r478339 = y;
        double r478340 = x;
        double r478341 = r478339 - r478340;
        double r478342 = z;
        double r478343 = t;
        double r478344 = r478342 / r478343;
        double r478345 = fma(r478341, r478344, r478340);
        return r478345;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.1
Target2.2
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.887:\\ \;\;\;\;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.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)}\]
  3. Using strategy rm
  4. Applied fma-udef2.1

    \[\leadsto \color{blue}{\left(y - x\right) \cdot \frac{z}{t} + x}\]
  5. Using strategy rm
  6. Applied fma-def2.1

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

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

Reproduce

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