Average Error: 1.3 → 1.4
Time: 19.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 r24420617 = x;
        double r24420618 = y;
        double r24420619 = z;
        double r24420620 = t;
        double r24420621 = r24420619 - r24420620;
        double r24420622 = a;
        double r24420623 = r24420619 - r24420622;
        double r24420624 = r24420621 / r24420623;
        double r24420625 = r24420618 * r24420624;
        double r24420626 = r24420617 + r24420625;
        return r24420626;
}

double f(double x, double y, double z, double t, double a) {
        double r24420627 = t;
        double r24420628 = -8.018870300280201e+70;
        bool r24420629 = r24420627 <= r24420628;
        double r24420630 = z;
        double r24420631 = r24420630 - r24420627;
        double r24420632 = y;
        double r24420633 = a;
        double r24420634 = r24420630 - r24420633;
        double r24420635 = r24420632 / r24420634;
        double r24420636 = x;
        double r24420637 = fma(r24420631, r24420635, r24420636);
        double r24420638 = r24420631 / r24420634;
        double r24420639 = r24420632 * r24420638;
        double r24420640 = r24420639 + r24420636;
        double r24420641 = r24420629 ? r24420637 : r24420640;
        return r24420641;
}

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)))))