Average Error: 7.6 → 2.0
Time: 16.3s
Precision: 64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
\[\begin{array}{l} \mathbf{if}\;t \le 6.115713482054992916699565778010339304503 \cdot 10^{152}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{\mathsf{fma}\left(t, z, -x\right)}, y, x\right) - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\ \end{array}\]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;t \le 6.115713482054992916699565778010339304503 \cdot 10^{152}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{\mathsf{fma}\left(t, z, -x\right)}, y, x\right) - \frac{x}{z \cdot t - x}}{x + 1}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r417180 = x;
        double r417181 = y;
        double r417182 = z;
        double r417183 = r417181 * r417182;
        double r417184 = r417183 - r417180;
        double r417185 = t;
        double r417186 = r417185 * r417182;
        double r417187 = r417186 - r417180;
        double r417188 = r417184 / r417187;
        double r417189 = r417180 + r417188;
        double r417190 = 1.0;
        double r417191 = r417180 + r417190;
        double r417192 = r417189 / r417191;
        return r417192;
}

double f(double x, double y, double z, double t) {
        double r417193 = t;
        double r417194 = 6.115713482054993e+152;
        bool r417195 = r417193 <= r417194;
        double r417196 = z;
        double r417197 = x;
        double r417198 = -r417197;
        double r417199 = fma(r417193, r417196, r417198);
        double r417200 = r417196 / r417199;
        double r417201 = y;
        double r417202 = fma(r417200, r417201, r417197);
        double r417203 = r417196 * r417193;
        double r417204 = r417203 - r417197;
        double r417205 = r417197 / r417204;
        double r417206 = r417202 - r417205;
        double r417207 = 1.0;
        double r417208 = r417197 + r417207;
        double r417209 = r417206 / r417208;
        double r417210 = r417201 / r417193;
        double r417211 = r417210 + r417197;
        double r417212 = r417211 / r417208;
        double r417213 = r417195 ? r417209 : r417212;
        return r417213;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 2 regimes
  2. if t < 6.115713482054993e+152

    1. Initial program 7.0

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
    2. Simplified7.0

      \[\leadsto \color{blue}{\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}}\]
    3. Using strategy rm
    4. Applied div-sub7.0

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

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

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

    if 6.115713482054993e+152 < t

    1. Initial program 11.2

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
    2. Simplified11.2

      \[\leadsto \color{blue}{\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}}\]
    3. Taylor expanded around inf 2.4

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

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

Reproduce

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

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

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