Average Error: 11.1 → 0.5
Time: 4.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.5640024657887547 \cdot 10^{-61} \lor \neg \left(t \le 2.24875974073024007 \cdot 10^{-92}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \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}\;t \le -4.5640024657887547 \cdot 10^{-61} \lor \neg \left(t \le 2.24875974073024007 \cdot 10^{-92}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, t, x\right)\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \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 r658585 = x;
        double r658586 = y;
        double r658587 = z;
        double r658588 = r658586 - r658587;
        double r658589 = t;
        double r658590 = r658588 * r658589;
        double r658591 = a;
        double r658592 = r658591 - r658587;
        double r658593 = r658590 / r658592;
        double r658594 = r658585 + r658593;
        return r658594;
}

double f(double x, double y, double z, double t, double a) {
        double r658595 = t;
        double r658596 = -4.564002465788755e-61;
        bool r658597 = r658595 <= r658596;
        double r658598 = 2.24875974073024e-92;
        bool r658599 = r658595 <= r658598;
        double r658600 = !r658599;
        bool r658601 = r658597 || r658600;
        double r658602 = 1.0;
        double r658603 = a;
        double r658604 = z;
        double r658605 = r658603 - r658604;
        double r658606 = y;
        double r658607 = r658606 - r658604;
        double r658608 = r658605 / r658607;
        double r658609 = r658602 / r658608;
        double r658610 = x;
        double r658611 = fma(r658609, r658595, r658610);
        double r658612 = r658607 * r658595;
        double r658613 = r658612 / r658605;
        double r658614 = r658602 * r658613;
        double r658615 = r658614 + r658610;
        double r658616 = r658601 ? r658611 : r658615;
        return r658616;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original11.1
Target0.5
Herbie0.5
\[\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 < -4.564002465788755e-61 or 2.24875974073024e-92 < t

    1. Initial program 18.6

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

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

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

    if -4.564002465788755e-61 < t < 2.24875974073024e-92

    1. Initial program 0.3

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

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

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

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

      \[\leadsto \color{blue}{\frac{t}{a - z} \cdot \left(y - z\right)} + x\]
    8. Using strategy rm
    9. Applied *-un-lft-identity4.0

      \[\leadsto \color{blue}{\left(1 \cdot \frac{t}{a - z}\right)} \cdot \left(y - z\right) + x\]
    10. Applied associate-*l*4.0

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

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

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

Reproduce

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