Average Error: 10.8 → 0.3
Time: 21.6s
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 \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 2.000545096431892508463371922368326298808 \cdot 10^{285}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y - z\right) \cdot 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 \lor \neg \left(\frac{\left(y - z\right) \cdot t}{a - z} \le 2.000545096431892508463371922368326298808 \cdot 10^{285}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r456628 = x;
        double r456629 = y;
        double r456630 = z;
        double r456631 = r456629 - r456630;
        double r456632 = t;
        double r456633 = r456631 * r456632;
        double r456634 = a;
        double r456635 = r456634 - r456630;
        double r456636 = r456633 / r456635;
        double r456637 = r456628 + r456636;
        return r456637;
}

double f(double x, double y, double z, double t, double a) {
        double r456638 = y;
        double r456639 = z;
        double r456640 = r456638 - r456639;
        double r456641 = t;
        double r456642 = r456640 * r456641;
        double r456643 = a;
        double r456644 = r456643 - r456639;
        double r456645 = r456642 / r456644;
        double r456646 = -inf.0;
        bool r456647 = r456645 <= r456646;
        double r456648 = 2.0005450964318925e+285;
        bool r456649 = r456645 <= r456648;
        double r456650 = !r456649;
        bool r456651 = r456647 || r456650;
        double r456652 = r456640 / r456644;
        double r456653 = x;
        double r456654 = fma(r456652, r456641, r456653);
        double r456655 = r456645 + r456653;
        double r456656 = r456651 ? r456654 : r456655;
        return r456656;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.8
Target0.6
Herbie0.3
\[\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.0005450964318925e+285 < (/ (* (- y z) t) (- a z))

    1. Initial program 62.5

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

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

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

    1. Initial program 0.3

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

      \[\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)\]
    5. Using strategy rm
    6. Applied fma-udef1.6

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

      \[\leadsto \color{blue}{\frac{t}{\frac{a - z}{y - z}}} + x\]
    8. Using strategy rm
    9. Applied div-sub1.3

      \[\leadsto \frac{t}{\color{blue}{\frac{a}{y - z} - \frac{z}{y - z}}} + x\]
    10. Using strategy rm
    11. Applied div-inv1.4

      \[\leadsto \frac{t}{\frac{a}{y - z} - \color{blue}{z \cdot \frac{1}{y - z}}} + x\]
    12. Applied div-inv1.4

      \[\leadsto \frac{t}{\color{blue}{a \cdot \frac{1}{y - z}} - z \cdot \frac{1}{y - z}} + x\]
    13. Applied distribute-rgt-out--1.4

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

      \[\leadsto \color{blue}{\frac{\frac{t}{\frac{1}{y - z}}}{a - z}} + x\]
    15. Simplified0.3

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

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

Reproduce

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