Average Error: 1.8 → 2.7
Time: 16.1s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.16895479299478677 \cdot 10^{-193}:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;t \le -2.16895479299478677 \cdot 10^{-193}:\\
\;\;\;\;\frac{z}{\frac{t}{y - x}} + x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r614232 = x;
        double r614233 = y;
        double r614234 = r614233 - r614232;
        double r614235 = z;
        double r614236 = t;
        double r614237 = r614235 / r614236;
        double r614238 = r614234 * r614237;
        double r614239 = r614232 + r614238;
        return r614239;
}

double f(double x, double y, double z, double t) {
        double r614240 = t;
        double r614241 = -2.1689547929947868e-193;
        bool r614242 = r614240 <= r614241;
        double r614243 = z;
        double r614244 = y;
        double r614245 = x;
        double r614246 = r614244 - r614245;
        double r614247 = r614240 / r614246;
        double r614248 = r614243 / r614247;
        double r614249 = r614248 + r614245;
        double r614250 = r614243 / r614240;
        double r614251 = fma(r614250, r614246, r614245);
        double r614252 = r614242 ? r614249 : r614251;
        return r614252;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.8
Target1.9
Herbie2.7
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.887:\\ \;\;\;\;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 t < -2.1689547929947868e-193

    1. Initial program 1.3

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Taylor expanded around 0 7.0

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

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

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

      \[\leadsto \color{blue}{\frac{z}{\frac{t}{y - x}}} + x\]

    if -2.1689547929947868e-193 < t

    1. Initial program 2.1

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Taylor expanded around 0 6.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.16895479299478677 \cdot 10^{-193}:\\ \;\;\;\;\frac{z}{\frac{t}{y - x}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.887) (+ 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))))