Average Error: 16.6 → 6.6
Time: 16.6s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -4.10283842005940777 \cdot 10^{-177} \lor \neg \left(a \le 1.5058790205676166 \cdot 10^{-193}\right):\\ \;\;\;\;x + \mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -4.10283842005940777 \cdot 10^{-177} \lor \neg \left(a \le 1.5058790205676166 \cdot 10^{-193}\right):\\
\;\;\;\;x + \mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r527976 = x;
        double r527977 = y;
        double r527978 = r527976 + r527977;
        double r527979 = z;
        double r527980 = t;
        double r527981 = r527979 - r527980;
        double r527982 = r527981 * r527977;
        double r527983 = a;
        double r527984 = r527983 - r527980;
        double r527985 = r527982 / r527984;
        double r527986 = r527978 - r527985;
        return r527986;
}

double f(double x, double y, double z, double t, double a) {
        double r527987 = a;
        double r527988 = -4.102838420059408e-177;
        bool r527989 = r527987 <= r527988;
        double r527990 = 1.5058790205676166e-193;
        bool r527991 = r527987 <= r527990;
        double r527992 = !r527991;
        bool r527993 = r527989 || r527992;
        double r527994 = x;
        double r527995 = t;
        double r527996 = z;
        double r527997 = r527995 - r527996;
        double r527998 = r527987 - r527995;
        double r527999 = r527997 / r527998;
        double r528000 = y;
        double r528001 = fma(r527999, r528000, r528000);
        double r528002 = r527994 + r528001;
        double r528003 = r527996 * r528000;
        double r528004 = r528003 / r527995;
        double r528005 = r527994 + r528004;
        double r528006 = r527993 ? r528002 : r528005;
        return r528006;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.6
Target8.2
Herbie6.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 a < -4.102838420059408e-177 or 1.5058790205676166e-193 < a

    1. Initial program 15.4

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

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

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

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

    if -4.102838420059408e-177 < a < 1.5058790205676166e-193

    1. Initial program 21.9

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

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

      \[\leadsto x + \color{blue}{\frac{z \cdot y}{t}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.6

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

Reproduce

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

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1 (- 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 (- a t))) y))))

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