Average Error: 10.1 → 0.4
Time: 16.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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 1.8696604680231408 \cdot 10^{+251}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{t}{a - z} + x\\ \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} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\

\mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 1.8696604680231408 \cdot 10^{+251}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r14082461 = x;
        double r14082462 = y;
        double r14082463 = z;
        double r14082464 = r14082462 - r14082463;
        double r14082465 = t;
        double r14082466 = r14082464 * r14082465;
        double r14082467 = a;
        double r14082468 = r14082467 - r14082463;
        double r14082469 = r14082466 / r14082468;
        double r14082470 = r14082461 + r14082469;
        return r14082470;
}

double f(double x, double y, double z, double t, double a) {
        double r14082471 = y;
        double r14082472 = z;
        double r14082473 = r14082471 - r14082472;
        double r14082474 = t;
        double r14082475 = r14082473 * r14082474;
        double r14082476 = a;
        double r14082477 = r14082476 - r14082472;
        double r14082478 = r14082475 / r14082477;
        double r14082479 = -inf.0;
        bool r14082480 = r14082478 <= r14082479;
        double r14082481 = r14082473 / r14082477;
        double r14082482 = x;
        double r14082483 = fma(r14082474, r14082481, r14082482);
        double r14082484 = 1.8696604680231408e+251;
        bool r14082485 = r14082478 <= r14082484;
        double r14082486 = r14082482 + r14082478;
        double r14082487 = r14082474 / r14082477;
        double r14082488 = r14082473 * r14082487;
        double r14082489 = r14082488 + r14082482;
        double r14082490 = r14082485 ? r14082486 : r14082489;
        double r14082491 = r14082480 ? r14082483 : r14082490;
        return r14082491;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.1
Target0.6
Herbie0.4
\[\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 3 regimes
  2. if (/ (* (- y z) t) (- a z)) < -inf.0

    1. Initial program 60.3

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

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

    if -inf.0 < (/ (* (- y z) t) (- a z)) < 1.8696604680231408e+251

    1. Initial program 0.2

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

    if 1.8696604680231408e+251 < (/ (* (- y z) t) (- a z))

    1. Initial program 51.9

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity51.9

      \[\leadsto x + \frac{\left(y - z\right) \cdot t}{\color{blue}{1 \cdot \left(a - z\right)}}\]
    4. Applied times-frac2.2

      \[\leadsto x + \color{blue}{\frac{y - z}{1} \cdot \frac{t}{a - z}}\]
    5. Simplified2.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 1.8696604680231408 \cdot 10^{+251}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{t}{a - z} + x\\ \end{array}\]

Reproduce

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

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