Average Error: 2.0 → 1.7
Time: 24.3s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le 4.8223933496405281555179001633191059513 \cdot 10^{-297}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x}{\frac{t}{z}}\right)\\ \mathbf{elif}\;t \le 3.712966372187300483564386948237676348205 \cdot 10^{-146}:\\ \;\;\;\;x + \left(\frac{z \cdot y}{t} - \frac{z \cdot x}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x}{\frac{t}{z}}\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;t \le 4.8223933496405281555179001633191059513 \cdot 10^{-297}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x}{\frac{t}{z}}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r26219758 = x;
        double r26219759 = y;
        double r26219760 = r26219759 - r26219758;
        double r26219761 = z;
        double r26219762 = t;
        double r26219763 = r26219761 / r26219762;
        double r26219764 = r26219760 * r26219763;
        double r26219765 = r26219758 + r26219764;
        return r26219765;
}

double f(double x, double y, double z, double t) {
        double r26219766 = t;
        double r26219767 = 4.822393349640528e-297;
        bool r26219768 = r26219766 <= r26219767;
        double r26219769 = z;
        double r26219770 = r26219769 / r26219766;
        double r26219771 = y;
        double r26219772 = x;
        double r26219773 = r26219766 / r26219769;
        double r26219774 = r26219772 / r26219773;
        double r26219775 = r26219772 - r26219774;
        double r26219776 = fma(r26219770, r26219771, r26219775);
        double r26219777 = 3.7129663721873005e-146;
        bool r26219778 = r26219766 <= r26219777;
        double r26219779 = r26219769 * r26219771;
        double r26219780 = r26219779 / r26219766;
        double r26219781 = r26219769 * r26219772;
        double r26219782 = r26219781 / r26219766;
        double r26219783 = r26219780 - r26219782;
        double r26219784 = r26219772 + r26219783;
        double r26219785 = r26219778 ? r26219784 : r26219776;
        double r26219786 = r26219768 ? r26219776 : r26219785;
        return r26219786;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.0
Target2.1
Herbie1.7
\[\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 t < 4.822393349640528e-297 or 3.7129663721873005e-146 < t

    1. Initial program 1.7

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

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

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

    if 4.822393349640528e-297 < t < 3.7129663721873005e-146

    1. Initial program 5.9

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

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

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

Reproduce

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