Average Error: 16.2 → 8.6
Time: 35.5s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -9.865242998422085 \cdot 10^{154} \lor \neg \left(t \le 1.0302980953989481 \cdot 10^{108}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\left(a - t\right) \cdot \frac{1}{t - z}}, y, x + y\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -9.865242998422085 \cdot 10^{154} \lor \neg \left(t \le 1.0302980953989481 \cdot 10^{108}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r371734 = x;
        double r371735 = y;
        double r371736 = r371734 + r371735;
        double r371737 = z;
        double r371738 = t;
        double r371739 = r371737 - r371738;
        double r371740 = r371739 * r371735;
        double r371741 = a;
        double r371742 = r371741 - r371738;
        double r371743 = r371740 / r371742;
        double r371744 = r371736 - r371743;
        return r371744;
}

double f(double x, double y, double z, double t, double a) {
        double r371745 = t;
        double r371746 = -9.865242998422085e+154;
        bool r371747 = r371745 <= r371746;
        double r371748 = 1.0302980953989481e+108;
        bool r371749 = r371745 <= r371748;
        double r371750 = !r371749;
        bool r371751 = r371747 || r371750;
        double r371752 = z;
        double r371753 = r371752 / r371745;
        double r371754 = y;
        double r371755 = x;
        double r371756 = fma(r371753, r371754, r371755);
        double r371757 = 1.0;
        double r371758 = a;
        double r371759 = r371758 - r371745;
        double r371760 = r371745 - r371752;
        double r371761 = r371757 / r371760;
        double r371762 = r371759 * r371761;
        double r371763 = r371757 / r371762;
        double r371764 = r371755 + r371754;
        double r371765 = fma(r371763, r371754, r371764);
        double r371766 = r371751 ? r371756 : r371765;
        return r371766;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.2
Target8.2
Herbie8.6
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt 1.47542934445772333 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -9.865242998422085e+154 or 1.0302980953989481e+108 < t

    1. Initial program 30.6

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

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    4. Simplified11.7

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

    if -9.865242998422085e+154 < t < 1.0302980953989481e+108

    1. Initial program 9.8

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{\frac{a - t}{t - z}}}, y, x + y\right)\]
    5. Using strategy rm
    6. Applied div-inv7.2

      \[\leadsto \mathsf{fma}\left(\frac{1}{\color{blue}{\left(a - t\right) \cdot \frac{1}{t - z}}}, y, x + y\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -9.865242998422085 \cdot 10^{154} \lor \neg \left(t \le 1.0302980953989481 \cdot 10^{108}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\left(a - t\right) \cdot \frac{1}{t - z}}, y, x + y\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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