Average Error: 6.7 → 0.3
Time: 7.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -4.3120437454803144 \cdot 10^{250} \lor \neg \left(y \cdot z - t \cdot z \le -2.6777160931771426 \cdot 10^{-239} \lor \neg \left(y \cdot z - t \cdot z \le 0.0\right) \land y \cdot z - t \cdot z \le 4.8948064958718642 \cdot 10^{265}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{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 \le -4.3120437454803144 \cdot 10^{250} \lor \neg \left(y \cdot z - t \cdot z \le -2.6777160931771426 \cdot 10^{-239} \lor \neg \left(y \cdot z - t \cdot z \le 0.0\right) \land y \cdot z - t \cdot z \le 4.8948064958718642 \cdot 10^{265}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{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 r470222 = x;
        double r470223 = 2.0;
        double r470224 = r470222 * r470223;
        double r470225 = y;
        double r470226 = z;
        double r470227 = r470225 * r470226;
        double r470228 = t;
        double r470229 = r470228 * r470226;
        double r470230 = r470227 - r470229;
        double r470231 = r470224 / r470230;
        return r470231;
}

double f(double x, double y, double z, double t) {
        double r470232 = y;
        double r470233 = z;
        double r470234 = r470232 * r470233;
        double r470235 = t;
        double r470236 = r470235 * r470233;
        double r470237 = r470234 - r470236;
        double r470238 = -4.3120437454803144e+250;
        bool r470239 = r470237 <= r470238;
        double r470240 = -2.6777160931771426e-239;
        bool r470241 = r470237 <= r470240;
        double r470242 = 0.0;
        bool r470243 = r470237 <= r470242;
        double r470244 = !r470243;
        double r470245 = 4.894806495871864e+265;
        bool r470246 = r470237 <= r470245;
        bool r470247 = r470244 && r470246;
        bool r470248 = r470241 || r470247;
        double r470249 = !r470248;
        bool r470250 = r470239 || r470249;
        double r470251 = x;
        double r470252 = 2.0;
        double r470253 = r470251 * r470252;
        double r470254 = r470253 / r470233;
        double r470255 = r470232 - r470235;
        double r470256 = r470254 / r470255;
        double r470257 = r470253 / r470237;
        double r470258 = r470250 ? r470256 : r470257;
        return r470258;
}

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
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061 \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.04502782733012586 \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)) < -4.3120437454803144e+250 or -2.6777160931771426e-239 < (- (* y z) (* t z)) < 0.0 or 4.894806495871864e+265 < (- (* y z) (* t z))

    1. Initial program 20.7

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

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

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

    if -4.3120437454803144e+250 < (- (* y z) (* t z)) < -2.6777160931771426e-239 or 0.0 < (- (* y z) (* t z)) < 4.894806495871864e+265

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -4.3120437454803144 \cdot 10^{250} \lor \neg \left(y \cdot z - t \cdot z \le -2.6777160931771426 \cdot 10^{-239} \lor \neg \left(y \cdot z - t \cdot z \le 0.0\right) \land y \cdot z - t \cdot z \le 4.8948064958718642 \cdot 10^{265}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 
(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.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

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