Average Error: 10.6 → 0.9
Time: 10.8s
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 4.5977456110666884 \cdot 10^{-7} \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 3.5007108546600527 \cdot 10^{236}\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 4.5977456110666884 \cdot 10^{-7} \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 3.5007108546600527 \cdot 10^{236}\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 r617550 = x;
        double r617551 = y;
        double r617552 = z;
        double r617553 = r617551 - r617552;
        double r617554 = t;
        double r617555 = r617553 * r617554;
        double r617556 = a;
        double r617557 = r617556 - r617552;
        double r617558 = r617555 / r617557;
        double r617559 = r617550 + r617558;
        return r617559;
}

double f(double x, double y, double z, double t, double a) {
        double r617560 = y;
        double r617561 = z;
        double r617562 = r617560 - r617561;
        double r617563 = t;
        double r617564 = r617562 * r617563;
        double r617565 = a;
        double r617566 = r617565 - r617561;
        double r617567 = r617564 / r617566;
        double r617568 = 4.5977456110666884e-07;
        bool r617569 = r617567 <= r617568;
        double r617570 = 3.5007108546600527e+236;
        bool r617571 = r617567 <= r617570;
        double r617572 = !r617571;
        bool r617573 = r617569 || r617572;
        double r617574 = r617562 / r617566;
        double r617575 = x;
        double r617576 = fma(r617574, r617563, r617575);
        double r617577 = r617575 + r617567;
        double r617578 = r617573 ? r617576 : r617577;
        return r617578;
}

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.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)) < 4.5977456110666884e-07 or 3.5007108546600527e+236 < (/ (* (- y z) t) (- a z))

    1. Initial program 12.2

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

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

    if 4.5977456110666884e-07 < (/ (* (- y z) t) (- a z)) < 3.5007108546600527e+236

    1. Initial program 0.1

      \[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 4.5977456110666884 \cdot 10^{-7} \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 3.5007108546600527 \cdot 10^{236}\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 2020046 +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))))