Average Error: 2.0 → 2.0
Time: 23.8s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.007379862259038223700121580907401945548 \cdot 10^{-291}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\ \mathbf{elif}\;x \le 2.752399409548236242802367488693487823511 \cdot 10^{-30}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \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}\;x \le -3.007379862259038223700121580907401945548 \cdot 10^{-291}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\

\mathbf{elif}\;x \le 2.752399409548236242802367488693487823511 \cdot 10^{-30}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\

\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 r31269752 = x;
        double r31269753 = y;
        double r31269754 = r31269753 - r31269752;
        double r31269755 = z;
        double r31269756 = t;
        double r31269757 = r31269755 / r31269756;
        double r31269758 = r31269754 * r31269757;
        double r31269759 = r31269752 + r31269758;
        return r31269759;
}

double f(double x, double y, double z, double t) {
        double r31269760 = x;
        double r31269761 = -3.0073798622590382e-291;
        bool r31269762 = r31269760 <= r31269761;
        double r31269763 = z;
        double r31269764 = t;
        double r31269765 = r31269763 / r31269764;
        double r31269766 = y;
        double r31269767 = r31269766 - r31269760;
        double r31269768 = fma(r31269765, r31269767, r31269760);
        double r31269769 = 2.7523994095482362e-30;
        bool r31269770 = r31269760 <= r31269769;
        double r31269771 = r31269767 / r31269764;
        double r31269772 = fma(r31269771, r31269763, r31269760);
        double r31269773 = r31269770 ? r31269772 : r31269768;
        double r31269774 = r31269762 ? r31269768 : r31269773;
        return r31269774;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.0
Target2.2
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 2 regimes
  2. if x < -3.0073798622590382e-291 or 2.7523994095482362e-30 < x

    1. Initial program 1.2

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

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

    if -3.0073798622590382e-291 < x < 2.7523994095482362e-30

    1. Initial program 4.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)}\]
    3. Taylor expanded around 0 5.1

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

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

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

Reproduce

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