Average Error: 2.0 → 2.0
Time: 22.0s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.820453902150181057567934077267084957509 \cdot 10^{-166}:\\ \;\;\;\;\frac{y - x}{\frac{t}{z}} + x\\ \mathbf{elif}\;x \le 1.170769649175920722112068593735604518759 \cdot 10^{-272}:\\ \;\;\;\;\frac{\left(y - x\right) \cdot z}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;x \le -2.820453902150181057567934077267084957509 \cdot 10^{-166}:\\
\;\;\;\;\frac{y - x}{\frac{t}{z}} + x\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r375563 = x;
        double r375564 = y;
        double r375565 = r375564 - r375563;
        double r375566 = z;
        double r375567 = t;
        double r375568 = r375566 / r375567;
        double r375569 = r375565 * r375568;
        double r375570 = r375563 + r375569;
        return r375570;
}

double f(double x, double y, double z, double t) {
        double r375571 = x;
        double r375572 = -2.820453902150181e-166;
        bool r375573 = r375571 <= r375572;
        double r375574 = y;
        double r375575 = r375574 - r375571;
        double r375576 = t;
        double r375577 = z;
        double r375578 = r375576 / r375577;
        double r375579 = r375575 / r375578;
        double r375580 = r375579 + r375571;
        double r375581 = 1.1707696491759207e-272;
        bool r375582 = r375571 <= r375581;
        double r375583 = r375575 * r375577;
        double r375584 = r375583 / r375576;
        double r375585 = r375584 + r375571;
        double r375586 = r375577 / r375576;
        double r375587 = fma(r375575, r375586, r375571);
        double r375588 = r375582 ? r375585 : r375587;
        double r375589 = r375573 ? r375580 : r375588;
        return r375589;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.0
Target2.1
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.88671875:\\ \;\;\;\;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 3 regimes
  2. if x < -2.820453902150181e-166

    1. Initial program 0.9

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

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

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

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

    if -2.820453902150181e-166 < x < 1.1707696491759207e-272

    1. Initial program 5.3

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{\frac{t}{z}}} + x\]
    6. Taylor expanded around 0 5.8

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

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

    if 1.1707696491759207e-272 < x

    1. Initial program 1.7

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

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

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

Reproduce

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