Average Error: 7.7 → 3.2
Time: 4.4s
Precision: 64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.3088357711862659 \cdot 10^{63}:\\ \;\;\;\;\frac{1}{x + 1} \cdot \mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right) - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;z \le 4.56682903308585354 \cdot 10^{76}:\\ \;\;\;\;\frac{x + \frac{1}{\frac{t \cdot z - x}{y \cdot z - x}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array}\]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;z \le -6.3088357711862659 \cdot 10^{63}:\\
\;\;\;\;\frac{1}{x + 1} \cdot \mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right) - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r789778 = x;
        double r789779 = y;
        double r789780 = z;
        double r789781 = r789779 * r789780;
        double r789782 = r789781 - r789778;
        double r789783 = t;
        double r789784 = r789783 * r789780;
        double r789785 = r789784 - r789778;
        double r789786 = r789782 / r789785;
        double r789787 = r789778 + r789786;
        double r789788 = 1.0;
        double r789789 = r789778 + r789788;
        double r789790 = r789787 / r789789;
        return r789790;
}

double f(double x, double y, double z, double t) {
        double r789791 = z;
        double r789792 = -6.308835771186266e+63;
        bool r789793 = r789791 <= r789792;
        double r789794 = 1.0;
        double r789795 = x;
        double r789796 = 1.0;
        double r789797 = r789795 + r789796;
        double r789798 = r789794 / r789797;
        double r789799 = y;
        double r789800 = t;
        double r789801 = r789800 * r789791;
        double r789802 = r789801 - r789795;
        double r789803 = r789799 / r789802;
        double r789804 = fma(r789803, r789791, r789795);
        double r789805 = r789798 * r789804;
        double r789806 = r789795 / r789802;
        double r789807 = r789806 / r789797;
        double r789808 = r789805 - r789807;
        double r789809 = 4.5668290330858535e+76;
        bool r789810 = r789791 <= r789809;
        double r789811 = r789799 * r789791;
        double r789812 = r789811 - r789795;
        double r789813 = r789802 / r789812;
        double r789814 = r789794 / r789813;
        double r789815 = r789795 + r789814;
        double r789816 = r789815 / r789797;
        double r789817 = r789799 / r789800;
        double r789818 = r789795 + r789817;
        double r789819 = r789818 / r789797;
        double r789820 = r789810 ? r789816 : r789819;
        double r789821 = r789793 ? r789808 : r789820;
        return r789821;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.7
Target0.3
Herbie3.2
\[\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 < -6.308835771186266e+63

    1. Initial program 18.7

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

      \[\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-18.7

      \[\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-sub18.7

      \[\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. Simplified7.9

      \[\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-identity7.9

      \[\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-frac8.0

      \[\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. Simplified8.0

      \[\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}\]

    if -6.308835771186266e+63 < z < 4.5668290330858535e+76

    1. Initial program 0.7

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

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

    if 4.5668290330858535e+76 < z

    1. Initial program 20.2

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

      \[\leadsto \frac{x + \color{blue}{\frac{y}{t}}}{x + 1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.3088357711862659 \cdot 10^{63}:\\ \;\;\;\;\frac{1}{x + 1} \cdot \mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right) - \frac{\frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;z \le 4.56682903308585354 \cdot 10^{76}:\\ \;\;\;\;\frac{x + \frac{1}{\frac{t \cdot z - x}{y \cdot z - x}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +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)))