Average Error: 10.7 → 0.8
Time: 21.9s
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(y - z, t \cdot \frac{1}{a - z}, x\right)\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 2.783388043504143278756198818458054740702 \cdot 10^{134}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - z, t \cdot \frac{1}{a - z}, x\right)\\ \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(y - z, t \cdot \frac{1}{a - z}, x\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, t \cdot \frac{1}{a - z}, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r19584671 = x;
        double r19584672 = y;
        double r19584673 = z;
        double r19584674 = r19584672 - r19584673;
        double r19584675 = t;
        double r19584676 = r19584674 * r19584675;
        double r19584677 = a;
        double r19584678 = r19584677 - r19584673;
        double r19584679 = r19584676 / r19584678;
        double r19584680 = r19584671 + r19584679;
        return r19584680;
}

double f(double x, double y, double z, double t, double a) {
        double r19584681 = y;
        double r19584682 = z;
        double r19584683 = r19584681 - r19584682;
        double r19584684 = t;
        double r19584685 = r19584683 * r19584684;
        double r19584686 = a;
        double r19584687 = r19584686 - r19584682;
        double r19584688 = r19584685 / r19584687;
        double r19584689 = -inf.0;
        bool r19584690 = r19584688 <= r19584689;
        double r19584691 = 1.0;
        double r19584692 = r19584691 / r19584687;
        double r19584693 = r19584684 * r19584692;
        double r19584694 = x;
        double r19584695 = fma(r19584683, r19584693, r19584694);
        double r19584696 = 2.7833880435041433e+134;
        bool r19584697 = r19584688 <= r19584696;
        double r19584698 = r19584694 + r19584688;
        double r19584699 = r19584697 ? r19584698 : r19584695;
        double r19584700 = r19584690 ? r19584695 : r19584699;
        return r19584700;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.7
Target0.6
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;t \lt -1.068297449017406694366747246993994850729 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.911094988758637497591020599238553861375 \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)) < -inf.0 or 2.7833880435041433e+134 < (/ (* (- y z) t) (- a z))

    1. Initial program 46.8

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

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

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

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

    1. Initial program 0.3

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

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

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

      \[\leadsto \color{blue}{\left(y - z\right) \cdot \left(t \cdot \frac{1}{a - z}\right) + x}\]
    7. Simplified0.3

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

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

Reproduce

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