Average Error: 2.9 → 1.9
Time: 12.8s
Precision: 64
\[\frac{x}{y - z \cdot t}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot t = -\infty:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{t}{\frac{x}{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \end{array}\]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t = -\infty:\\
\;\;\;\;\frac{1}{\frac{y}{x} - \frac{t}{\frac{x}{z}}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r764905 = x;
        double r764906 = y;
        double r764907 = z;
        double r764908 = t;
        double r764909 = r764907 * r764908;
        double r764910 = r764906 - r764909;
        double r764911 = r764905 / r764910;
        return r764911;
}

double f(double x, double y, double z, double t) {
        double r764912 = z;
        double r764913 = t;
        double r764914 = r764912 * r764913;
        double r764915 = -inf.0;
        bool r764916 = r764914 <= r764915;
        double r764917 = 1.0;
        double r764918 = y;
        double r764919 = x;
        double r764920 = r764918 / r764919;
        double r764921 = r764919 / r764912;
        double r764922 = r764913 / r764921;
        double r764923 = r764920 - r764922;
        double r764924 = r764917 / r764923;
        double r764925 = r764918 - r764914;
        double r764926 = r764919 / r764925;
        double r764927 = r764916 ? r764924 : r764926;
        return r764927;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.9
Target1.7
Herbie1.9
\[\begin{array}{l} \mathbf{if}\;x \lt -1.618195973607049 \cdot 10^{50}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \mathbf{elif}\;x \lt 2.13783064348764444 \cdot 10^{131}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* z t) < -inf.0

    1. Initial program 20.5

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y - z \cdot t}{x}}}\]
    4. Using strategy rm
    5. Applied div-sub24.7

      \[\leadsto \frac{1}{\color{blue}{\frac{y}{x} - \frac{z \cdot t}{x}}}\]
    6. Simplified5.0

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

    if -inf.0 < (* z t)

    1. Initial program 1.7

      \[\frac{x}{y - z \cdot t}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t = -\infty:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{t}{\frac{x}{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y z t)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< x -1.618195973607049e+50) (/ 1 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1 (- (/ y x) (* (/ z x) t)))))

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