Average Error: 10.6 → 1.3
Time: 4.4s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)
double f(double x, double y, double z, double t, double a) {
        double r580522 = x;
        double r580523 = y;
        double r580524 = z;
        double r580525 = r580523 - r580524;
        double r580526 = t;
        double r580527 = r580525 * r580526;
        double r580528 = a;
        double r580529 = r580528 - r580524;
        double r580530 = r580527 / r580529;
        double r580531 = r580522 + r580530;
        return r580531;
}

double f(double x, double y, double z, double t, double a) {
        double r580532 = y;
        double r580533 = z;
        double r580534 = r580532 - r580533;
        double r580535 = a;
        double r580536 = r580535 - r580533;
        double r580537 = r580534 / r580536;
        double r580538 = t;
        double r580539 = x;
        double r580540 = fma(r580537, r580538, r580539);
        return r580540;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.6
Target0.6
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;t \lt -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.9110949887586375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Initial program 10.6

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

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

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

Reproduce

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

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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