Average Error: 10.5 → 0.9
Time: 12.0s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 1.7358601241401339 \cdot 10^{-12} \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 6.9223637105495411 \cdot 10^{251}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 1.7358601241401339 \cdot 10^{-12} \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 6.9223637105495411 \cdot 10^{251}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\

\mathbf{else}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r714612 = x;
        double r714613 = y;
        double r714614 = z;
        double r714615 = r714613 - r714614;
        double r714616 = t;
        double r714617 = r714615 * r714616;
        double r714618 = a;
        double r714619 = r714618 - r714614;
        double r714620 = r714617 / r714619;
        double r714621 = r714612 + r714620;
        return r714621;
}

double f(double x, double y, double z, double t, double a) {
        double r714622 = y;
        double r714623 = z;
        double r714624 = r714622 - r714623;
        double r714625 = t;
        double r714626 = r714624 * r714625;
        double r714627 = a;
        double r714628 = r714627 - r714623;
        double r714629 = r714626 / r714628;
        double r714630 = 1.735860124140134e-12;
        bool r714631 = r714629 <= r714630;
        double r714632 = 6.922363710549541e+251;
        bool r714633 = r714629 <= r714632;
        double r714634 = !r714633;
        bool r714635 = r714631 || r714634;
        double r714636 = r714624 / r714628;
        double r714637 = x;
        double r714638 = fma(r714636, r714625, r714637);
        double r714639 = r714637 + r714629;
        double r714640 = r714635 ? r714638 : r714639;
        return r714640;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.5
Target0.5
Herbie0.9
\[\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. Split input into 2 regimes
  2. if (/ (* (- y z) t) (- a z)) < 1.735860124140134e-12 or 6.922363710549541e+251 < (/ (* (- y z) t) (- a z))

    1. Initial program 12.2

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

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

    if 1.735860124140134e-12 < (/ (* (- y z) t) (- a z)) < 6.922363710549541e+251

    1. Initial program 0.2

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 1.7358601241401339 \cdot 10^{-12} \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 6.9223637105495411 \cdot 10^{251}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \end{array}\]

Reproduce

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