Average Error: 1.3 → 1.3
Time: 10.5s
Precision: 64
\[x + y \cdot \frac{z - t}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.12557260707599147 \cdot 10^{-177}:\\ \;\;\;\;x + y \cdot \left(\frac{z}{a - t} - \frac{t}{a - t}\right)\\ \mathbf{elif}\;t \le 5.18073089344095173 \cdot 10^{31}:\\ \;\;\;\;x + \frac{y}{a - t} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{1}{a - t}, -\frac{t}{a - t}\right), y, x\right) + y \cdot \mathsf{fma}\left(-\frac{t}{a - t}, 1, \frac{t}{a - t} \cdot 1\right)\\ \end{array}\]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -1.12557260707599147 \cdot 10^{-177}:\\
\;\;\;\;x + y \cdot \left(\frac{z}{a - t} - \frac{t}{a - t}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r562336 = x;
        double r562337 = y;
        double r562338 = z;
        double r562339 = t;
        double r562340 = r562338 - r562339;
        double r562341 = a;
        double r562342 = r562341 - r562339;
        double r562343 = r562340 / r562342;
        double r562344 = r562337 * r562343;
        double r562345 = r562336 + r562344;
        return r562345;
}

double f(double x, double y, double z, double t, double a) {
        double r562346 = t;
        double r562347 = -1.1255726070759915e-177;
        bool r562348 = r562346 <= r562347;
        double r562349 = x;
        double r562350 = y;
        double r562351 = z;
        double r562352 = a;
        double r562353 = r562352 - r562346;
        double r562354 = r562351 / r562353;
        double r562355 = r562346 / r562353;
        double r562356 = r562354 - r562355;
        double r562357 = r562350 * r562356;
        double r562358 = r562349 + r562357;
        double r562359 = 5.180730893440952e+31;
        bool r562360 = r562346 <= r562359;
        double r562361 = r562350 / r562353;
        double r562362 = r562351 - r562346;
        double r562363 = r562361 * r562362;
        double r562364 = r562349 + r562363;
        double r562365 = 1.0;
        double r562366 = r562365 / r562353;
        double r562367 = -r562355;
        double r562368 = fma(r562351, r562366, r562367);
        double r562369 = fma(r562368, r562350, r562349);
        double r562370 = r562355 * r562365;
        double r562371 = fma(r562367, r562365, r562370);
        double r562372 = r562350 * r562371;
        double r562373 = r562369 + r562372;
        double r562374 = r562360 ? r562364 : r562373;
        double r562375 = r562348 ? r562358 : r562374;
        return r562375;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.3
Target0.4
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;y \lt -8.50808486055124107 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -1.1255726070759915e-177

    1. Initial program 0.6

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Using strategy rm
    3. Applied div-sub0.6

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

    if -1.1255726070759915e-177 < t < 5.180730893440952e+31

    1. Initial program 2.9

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Using strategy rm
    3. Applied div-sub2.9

      \[\leadsto x + y \cdot \color{blue}{\left(\frac{z}{a - t} - \frac{t}{a - t}\right)}\]
    4. Using strategy rm
    5. Applied div-inv2.9

      \[\leadsto x + y \cdot \left(\frac{z}{a - t} - \color{blue}{t \cdot \frac{1}{a - t}}\right)\]
    6. Applied div-inv2.9

      \[\leadsto x + y \cdot \left(\color{blue}{z \cdot \frac{1}{a - t}} - t \cdot \frac{1}{a - t}\right)\]
    7. Applied distribute-rgt-out--2.9

      \[\leadsto x + y \cdot \color{blue}{\left(\frac{1}{a - t} \cdot \left(z - t\right)\right)}\]
    8. Applied associate-*r*3.0

      \[\leadsto x + \color{blue}{\left(y \cdot \frac{1}{a - t}\right) \cdot \left(z - t\right)}\]
    9. Simplified3.0

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

    if 5.180730893440952e+31 < t

    1. Initial program 0.1

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Using strategy rm
    3. Applied div-sub0.1

      \[\leadsto x + y \cdot \color{blue}{\left(\frac{z}{a - t} - \frac{t}{a - t}\right)}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.1

      \[\leadsto x + y \cdot \left(\frac{z}{a - t} - \color{blue}{1 \cdot \frac{t}{a - t}}\right)\]
    6. Applied div-inv0.1

      \[\leadsto x + y \cdot \left(\color{blue}{z \cdot \frac{1}{a - t}} - 1 \cdot \frac{t}{a - t}\right)\]
    7. Applied prod-diff0.1

      \[\leadsto x + y \cdot \color{blue}{\left(\mathsf{fma}\left(z, \frac{1}{a - t}, -\frac{t}{a - t} \cdot 1\right) + \mathsf{fma}\left(-\frac{t}{a - t}, 1, \frac{t}{a - t} \cdot 1\right)\right)}\]
    8. Applied distribute-lft-in0.1

      \[\leadsto x + \color{blue}{\left(y \cdot \mathsf{fma}\left(z, \frac{1}{a - t}, -\frac{t}{a - t} \cdot 1\right) + y \cdot \mathsf{fma}\left(-\frac{t}{a - t}, 1, \frac{t}{a - t} \cdot 1\right)\right)}\]
    9. Applied associate-+r+0.1

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

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

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

Reproduce

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

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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