Average Error: 10.6 → 0.6
Time: 4.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.43291389633853575 \cdot 10^{32}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{elif}\;t \le 8.70690080533521418 \cdot 10^{-48}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{1}{\frac{y - z}{a - z}}}, t, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;t \le -4.43291389633853575 \cdot 10^{32}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r584609 = x;
        double r584610 = y;
        double r584611 = z;
        double r584612 = r584610 - r584611;
        double r584613 = t;
        double r584614 = r584612 * r584613;
        double r584615 = a;
        double r584616 = r584615 - r584611;
        double r584617 = r584614 / r584616;
        double r584618 = r584609 + r584617;
        return r584618;
}

double f(double x, double y, double z, double t, double a) {
        double r584619 = t;
        double r584620 = -4.432913896338536e+32;
        bool r584621 = r584619 <= r584620;
        double r584622 = 1.0;
        double r584623 = y;
        double r584624 = z;
        double r584625 = r584623 - r584624;
        double r584626 = a;
        double r584627 = r584626 - r584624;
        double r584628 = r584625 / r584627;
        double r584629 = x;
        double r584630 = fma(r584628, r584619, r584629);
        double r584631 = r584622 * r584630;
        double r584632 = 8.706900805335214e-48;
        bool r584633 = r584619 <= r584632;
        double r584634 = r584625 * r584619;
        double r584635 = r584634 / r584627;
        double r584636 = r584629 + r584635;
        double r584637 = r584622 / r584628;
        double r584638 = r584622 / r584637;
        double r584639 = fma(r584638, r584619, r584629);
        double r584640 = r584633 ? r584636 : r584639;
        double r584641 = r584621 ? r584631 : r584640;
        return r584641;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.6
Target0.6
Herbie0.6
\[\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 t < -4.432913896338536e+32

    1. Initial program 25.3

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

      \[\leadsto x + \color{blue}{1 \cdot \frac{\left(y - z\right) \cdot t}{a - z}}\]
    4. Applied *-un-lft-identity25.3

      \[\leadsto \color{blue}{1 \cdot x} + 1 \cdot \frac{\left(y - z\right) \cdot t}{a - z}\]
    5. Applied distribute-lft-out25.3

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

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

    if -4.432913896338536e+32 < t < 8.706900805335214e-48

    1. Initial program 0.5

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

    if 8.706900805335214e-48 < t

    1. Initial program 19.2

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

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

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

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

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

Reproduce

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