Average Error: 1.3 → 1.4
Time: 17.7s
Precision: 64
\[x + y \cdot \frac{z - t}{z - a}\]
\[\begin{array}{l} \mathbf{if}\;t \le -8.018870300280200753529295591444470153158 \cdot 10^{70}:\\ \;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{z - a}, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - t}{z - a} + x\\ \end{array}\]
x + y \cdot \frac{z - t}{z - a}
\begin{array}{l}
\mathbf{if}\;t \le -8.018870300280200753529295591444470153158 \cdot 10^{70}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{z - a}, x\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - t}{z - a} + x\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r394980 = x;
        double r394981 = y;
        double r394982 = z;
        double r394983 = t;
        double r394984 = r394982 - r394983;
        double r394985 = a;
        double r394986 = r394982 - r394985;
        double r394987 = r394984 / r394986;
        double r394988 = r394981 * r394987;
        double r394989 = r394980 + r394988;
        return r394989;
}

double f(double x, double y, double z, double t, double a) {
        double r394990 = t;
        double r394991 = -8.018870300280201e+70;
        bool r394992 = r394990 <= r394991;
        double r394993 = z;
        double r394994 = r394993 - r394990;
        double r394995 = y;
        double r394996 = a;
        double r394997 = r394993 - r394996;
        double r394998 = r394995 / r394997;
        double r394999 = x;
        double r395000 = fma(r394994, r394998, r394999);
        double r395001 = r394994 / r394997;
        double r395002 = r394995 * r395001;
        double r395003 = r395002 + r394999;
        double r395004 = r394992 ? r395000 : r395003;
        return r395004;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.3
Target1.2
Herbie1.4
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -8.018870300280201e+70

    1. Initial program 3.3

      \[x + y \cdot \frac{z - t}{z - a}\]
    2. Simplified3.4

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

    if -8.018870300280201e+70 < t

    1. Initial program 0.9

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"

  :herbie-target
  (+ x (/ y (/ (- z a) (- z t))))

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