Average Error: 10.1 → 0.8
Time: 16.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.988139439039141 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\ \mathbf{elif}\;t \le 3.0072207939681947 \cdot 10^{+72}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;t \le -1.988139439039141 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r22925341 = x;
        double r22925342 = y;
        double r22925343 = z;
        double r22925344 = r22925342 - r22925343;
        double r22925345 = t;
        double r22925346 = r22925344 * r22925345;
        double r22925347 = a;
        double r22925348 = r22925347 - r22925343;
        double r22925349 = r22925346 / r22925348;
        double r22925350 = r22925341 + r22925349;
        return r22925350;
}

double f(double x, double y, double z, double t, double a) {
        double r22925351 = t;
        double r22925352 = -1.988139439039141e-20;
        bool r22925353 = r22925351 <= r22925352;
        double r22925354 = y;
        double r22925355 = z;
        double r22925356 = r22925354 - r22925355;
        double r22925357 = a;
        double r22925358 = r22925357 - r22925355;
        double r22925359 = r22925356 / r22925358;
        double r22925360 = x;
        double r22925361 = fma(r22925351, r22925359, r22925360);
        double r22925362 = 3.0072207939681947e+72;
        bool r22925363 = r22925351 <= r22925362;
        double r22925364 = r22925356 * r22925351;
        double r22925365 = r22925364 / r22925358;
        double r22925366 = r22925360 + r22925365;
        double r22925367 = r22925363 ? r22925366 : r22925361;
        double r22925368 = r22925353 ? r22925361 : r22925367;
        return r22925368;
}

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.8
\[\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 t < -1.988139439039141e-20 or 3.0072207939681947e+72 < t

    1. Initial program 22.5

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

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

      \[\leadsto \color{blue}{\left(y - z\right) \cdot \frac{t}{a - z} + x}\]
    5. Using strategy rm
    6. Applied div-inv2.6

      \[\leadsto \left(y - z\right) \cdot \color{blue}{\left(t \cdot \frac{1}{a - z}\right)} + x\]
    7. Using strategy rm
    8. Applied associate-*r/2.5

      \[\leadsto \left(y - z\right) \cdot \color{blue}{\frac{t \cdot 1}{a - z}} + x\]
    9. Applied associate-*r/22.5

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

      \[\leadsto \frac{\color{blue}{t \cdot \left(y - z\right)}}{a - z} + x\]
    11. Using strategy rm
    12. Applied *-un-lft-identity22.5

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

      \[\leadsto \color{blue}{\frac{t}{1} \cdot \frac{y - z}{a - z}} + x\]
    14. Applied fma-def0.7

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

    if -1.988139439039141e-20 < t < 3.0072207939681947e+72

    1. Initial program 0.9

      \[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 fma-udef3.3

      \[\leadsto \color{blue}{\left(y - z\right) \cdot \frac{t}{a - z} + x}\]
    5. Using strategy rm
    6. Applied div-inv3.3

      \[\leadsto \left(y - z\right) \cdot \color{blue}{\left(t \cdot \frac{1}{a - z}\right)} + x\]
    7. Using strategy rm
    8. Applied associate-*r/3.3

      \[\leadsto \left(y - z\right) \cdot \color{blue}{\frac{t \cdot 1}{a - z}} + x\]
    9. Applied associate-*r/0.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.988139439039141 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\ \mathbf{elif}\;t \le 3.0072207939681947 \cdot 10^{+72}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a - z}, x\right)\\ \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))))