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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r502105 = x;
        double r502106 = y;
        double r502107 = z;
        double r502108 = r502106 - r502107;
        double r502109 = t;
        double r502110 = r502108 * r502109;
        double r502111 = a;
        double r502112 = r502111 - r502107;
        double r502113 = r502110 / r502112;
        double r502114 = r502105 + r502113;
        return r502114;
}

double f(double x, double y, double z, double t, double a) {
        double r502115 = y;
        double r502116 = z;
        double r502117 = r502115 - r502116;
        double r502118 = t;
        double r502119 = r502117 * r502118;
        double r502120 = a;
        double r502121 = r502120 - r502116;
        double r502122 = r502119 / r502121;
        double r502123 = -inf.0;
        bool r502124 = r502122 <= r502123;
        double r502125 = r502118 / r502121;
        double r502126 = r502125 * r502117;
        double r502127 = x;
        double r502128 = r502126 + r502127;
        double r502129 = 5.508227135249915e+243;
        bool r502130 = r502122 <= r502129;
        double r502131 = r502127 + r502122;
        double r502132 = 1.0;
        double r502133 = r502121 / r502117;
        double r502134 = r502132 / r502133;
        double r502135 = fma(r502134, r502118, r502127);
        double r502136 = r502130 ? r502131 : r502135;
        double r502137 = r502124 ? r502128 : r502136;
        return r502137;
}

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.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 64.0

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

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

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

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

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

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

    1. Initial program 0.3

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

    if 5.508227135249915e+243 < (/ (* (- y z) t) (- a z))

    1. Initial program 54.4

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{\frac{a - z}{y - z}}}, t, x\right)\]
  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:\\ \;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right) + x\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 5.5082271352499151 \cdot 10^{243}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, t, x\right)\\ \end{array}\]

Reproduce

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