Average Error: 6.7 → 2.9
Time: 9.2s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.021762082410781549036184893167115988887 \cdot 10^{147} \lor \neg \left(z \le 2.635494250498725666564973693616699303691 \cdot 10^{-102}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z + \left(-t\right) \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -3.021762082410781549036184893167115988887 \cdot 10^{147} \lor \neg \left(z \le 2.635494250498725666564973693616699303691 \cdot 10^{-102}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z + \left(-t\right) \cdot z}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r476115 = x;
        double r476116 = 2.0;
        double r476117 = r476115 * r476116;
        double r476118 = y;
        double r476119 = z;
        double r476120 = r476118 * r476119;
        double r476121 = t;
        double r476122 = r476121 * r476119;
        double r476123 = r476120 - r476122;
        double r476124 = r476117 / r476123;
        return r476124;
}

double f(double x, double y, double z, double t) {
        double r476125 = z;
        double r476126 = -3.0217620824107815e+147;
        bool r476127 = r476125 <= r476126;
        double r476128 = 2.6354942504987257e-102;
        bool r476129 = r476125 <= r476128;
        double r476130 = !r476129;
        bool r476131 = r476127 || r476130;
        double r476132 = x;
        double r476133 = 2.0;
        double r476134 = r476132 * r476133;
        double r476135 = r476134 / r476125;
        double r476136 = y;
        double r476137 = t;
        double r476138 = r476136 - r476137;
        double r476139 = r476135 / r476138;
        double r476140 = r476136 * r476125;
        double r476141 = -r476137;
        double r476142 = r476141 * r476125;
        double r476143 = r476140 + r476142;
        double r476144 = r476134 / r476143;
        double r476145 = r476131 ? r476139 : r476144;
        return r476145;
}

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.7
Target2.0
Herbie2.9
\[\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 z < -3.0217620824107815e+147 or 2.6354942504987257e-102 < z

    1. Initial program 10.2

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

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

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

    if -3.0217620824107815e+147 < z < 2.6354942504987257e-102

    1. Initial program 3.3

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

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

      \[\leadsto \frac{x \cdot 2}{z \cdot \color{blue}{\left(y + \left(-t\right)\right)}}\]
    5. Applied distribute-lft-in3.3

      \[\leadsto \frac{x \cdot 2}{\color{blue}{z \cdot y + z \cdot \left(-t\right)}}\]
    6. Simplified3.3

      \[\leadsto \frac{x \cdot 2}{\color{blue}{y \cdot z} + z \cdot \left(-t\right)}\]
    7. Simplified3.3

      \[\leadsto \frac{x \cdot 2}{y \cdot z + \color{blue}{\left(-t\right) \cdot z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.021762082410781549036184893167115988887 \cdot 10^{147} \lor \neg \left(z \le 2.635494250498725666564973693616699303691 \cdot 10^{-102}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z + \left(-t\right) \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 
(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))))