Average Error: 7.4 → 2.6
Time: 3.9s
Precision: 64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.74870111711383787 \cdot 10^{147}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;z \le -4.8179241856878477 \cdot 10^{-129}:\\ \;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}{x + 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;z \le 2.42397751568785456 \cdot 10^{-6}:\\ \;\;\;\;\frac{1}{\frac{x + 1}{x + \frac{y \cdot z - x}{t \cdot z - x}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}{x + 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\ \end{array}\]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;z \le -4.74870111711383787 \cdot 10^{147}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\

\mathbf{elif}\;z \le -4.8179241856878477 \cdot 10^{-129}:\\
\;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}{x + 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\

\mathbf{elif}\;z \le 2.42397751568785456 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{x + 1}{x + \frac{y \cdot z - x}{t \cdot z - x}}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r691334 = x;
        double r691335 = y;
        double r691336 = z;
        double r691337 = r691335 * r691336;
        double r691338 = r691337 - r691334;
        double r691339 = t;
        double r691340 = r691339 * r691336;
        double r691341 = r691340 - r691334;
        double r691342 = r691338 / r691341;
        double r691343 = r691334 + r691342;
        double r691344 = 1.0;
        double r691345 = r691334 + r691344;
        double r691346 = r691343 / r691345;
        return r691346;
}

double f(double x, double y, double z, double t) {
        double r691347 = z;
        double r691348 = -4.748701117113838e+147;
        bool r691349 = r691347 <= r691348;
        double r691350 = x;
        double r691351 = y;
        double r691352 = t;
        double r691353 = r691351 / r691352;
        double r691354 = r691350 + r691353;
        double r691355 = 1.0;
        double r691356 = r691350 + r691355;
        double r691357 = r691354 / r691356;
        double r691358 = -4.817924185687848e-129;
        bool r691359 = r691347 <= r691358;
        double r691360 = 1.0;
        double r691361 = r691352 * r691347;
        double r691362 = r691361 - r691350;
        double r691363 = r691351 / r691362;
        double r691364 = fma(r691363, r691347, r691350);
        double r691365 = r691364 / r691356;
        double r691366 = r691360 * r691365;
        double r691367 = r691350 / r691362;
        double r691368 = r691367 / r691356;
        double r691369 = r691366 - r691368;
        double r691370 = 2.4239775156878546e-06;
        bool r691371 = r691347 <= r691370;
        double r691372 = r691351 * r691347;
        double r691373 = r691372 - r691350;
        double r691374 = r691373 / r691362;
        double r691375 = r691350 + r691374;
        double r691376 = r691356 / r691375;
        double r691377 = r691360 / r691376;
        double r691378 = r691371 ? r691377 : r691369;
        double r691379 = r691359 ? r691369 : r691378;
        double r691380 = r691349 ? r691357 : r691379;
        return r691380;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.4
Target0.3
Herbie2.6
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -4.748701117113838e+147

    1. Initial program 20.6

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
    2. Taylor expanded around inf 6.5

      \[\leadsto \frac{x + \color{blue}{\frac{y}{t}}}{x + 1}\]

    if -4.748701117113838e+147 < z < -4.817924185687848e-129 or 2.4239775156878546e-06 < z

    1. Initial program 10.0

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

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

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z}{t \cdot z - x}}{x + 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}}\]
    6. Simplified3.7

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}{\left(x + 1\right) \cdot 1}} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity3.7

      \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}}{\left(x + 1\right) \cdot 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\]
    9. Applied times-frac3.7

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

      \[\leadsto \frac{1}{x + 1} \cdot \color{blue}{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity3.7

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{x + 1}\right)} \cdot \mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right) - \frac{\frac{x}{t \cdot z - x}}{x + 1}\]
    13. Applied associate-*l*3.7

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

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

    if -4.817924185687848e-129 < z < 2.4239775156878546e-06

    1. Initial program 0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.74870111711383787 \cdot 10^{147}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;z \le -4.8179241856878477 \cdot 10^{-129}:\\ \;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}{x + 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;z \le 2.42397751568785456 \cdot 10^{-6}:\\ \;\;\;\;\frac{1}{\frac{x + 1}{x + \frac{y \cdot z - x}{t \cdot z - x}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)}{x + 1} - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020024 +o rules:numerics
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"
  :precision binary64

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

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