Average Error: 1.8 → 1.2
Time: 22.2s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r24624716 = x;
        double r24624717 = y;
        double r24624718 = r24624717 - r24624716;
        double r24624719 = z;
        double r24624720 = t;
        double r24624721 = r24624719 / r24624720;
        double r24624722 = r24624718 * r24624721;
        double r24624723 = r24624716 + r24624722;
        return r24624723;
}

double f(double x, double y, double z, double t) {
        double r24624724 = z;
        double r24624725 = t;
        double r24624726 = r24624724 / r24624725;
        double r24624727 = -inf.0;
        bool r24624728 = r24624726 <= r24624727;
        double r24624729 = 1.0;
        double r24624730 = y;
        double r24624731 = x;
        double r24624732 = r24624730 - r24624731;
        double r24624733 = r24624725 / r24624732;
        double r24624734 = r24624729 / r24624733;
        double r24624735 = fma(r24624734, r24624724, r24624731);
        double r24624736 = r24624726 * r24624732;
        double r24624737 = r24624731 + r24624736;
        double r24624738 = r24624728 ? r24624735 : r24624737;
        return r24624738;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.8
Target2.1
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.8867:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} \lt -0.0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ z t) < -inf.0

    1. Initial program 59.5

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

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

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

    if -inf.0 < (/ z t)

    1. Initial program 1.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z}{t} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{t}{y - x}}, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) -0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

  (+ x (* (- y x) (/ z t))))