Average Error: 6.6 → 1.4
Time: 9.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le 4.460260718279960201724564022638644452838 \cdot 10^{143}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le 4.460260718279960201724564022638644452838 \cdot 10^{143}\right):\\
\;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r438034 = x;
        double r438035 = 2.0;
        double r438036 = r438034 * r438035;
        double r438037 = y;
        double r438038 = z;
        double r438039 = r438037 * r438038;
        double r438040 = t;
        double r438041 = r438040 * r438038;
        double r438042 = r438039 - r438041;
        double r438043 = r438036 / r438042;
        return r438043;
}

double f(double x, double y, double z, double t) {
        double r438044 = y;
        double r438045 = z;
        double r438046 = r438044 * r438045;
        double r438047 = t;
        double r438048 = r438047 * r438045;
        double r438049 = r438046 - r438048;
        double r438050 = -inf.0;
        bool r438051 = r438049 <= r438050;
        double r438052 = 4.46026071827996e+143;
        bool r438053 = r438049 <= r438052;
        double r438054 = !r438053;
        bool r438055 = r438051 || r438054;
        double r438056 = 2.0;
        double r438057 = x;
        double r438058 = r438056 * r438057;
        double r438059 = r438058 / r438045;
        double r438060 = r438044 - r438047;
        double r438061 = r438059 / r438060;
        double r438062 = r438057 * r438056;
        double r438063 = r438062 / r438049;
        double r438064 = r438055 ? r438061 : r438063;
        return r438064;
}

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

Original6.6
Target2.1
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt 1.045027827330126029709547581125571222799 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* y z) (* t z)) < -inf.0 or 4.46026071827996e+143 < (- (* y z) (* t z))

    1. Initial program 15.3

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified12.4

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied div-inv12.4

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied associate-/r*11.4

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\frac{\frac{1}{z}}{y - t}}\]
    7. Using strategy rm
    8. Applied associate-*r/0.7

      \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot \frac{1}{z}}{y - t}}\]
    9. Simplified0.7

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

    if -inf.0 < (- (* y z) (* t z)) < 4.46026071827996e+143

    1. Initial program 1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le 4.460260718279960201724564022638644452838 \cdot 10^{143}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019212 
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (if (< (/ (* x 2) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2) (if (< (/ (* x 2) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

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