Average Error: 7.0 → 0.2
Time: 15.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -1.297678113855718635658789434496889949182 \cdot 10^{-286}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 5.046704240239332707872033601746706650501 \cdot 10^{-316}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 3.07549282083517302392638365759120992158 \cdot 10^{268}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le -1.297678113855718635658789434496889949182 \cdot 10^{-286}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le 5.046704240239332707872033601746706650501 \cdot 10^{-316}:\\
\;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le 3.07549282083517302392638365759120992158 \cdot 10^{268}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r426334 = x;
        double r426335 = 2.0;
        double r426336 = r426334 * r426335;
        double r426337 = y;
        double r426338 = z;
        double r426339 = r426337 * r426338;
        double r426340 = t;
        double r426341 = r426340 * r426338;
        double r426342 = r426339 - r426341;
        double r426343 = r426336 / r426342;
        return r426343;
}

double f(double x, double y, double z, double t) {
        double r426344 = y;
        double r426345 = z;
        double r426346 = r426344 * r426345;
        double r426347 = t;
        double r426348 = r426347 * r426345;
        double r426349 = r426346 - r426348;
        double r426350 = -inf.0;
        bool r426351 = r426349 <= r426350;
        double r426352 = x;
        double r426353 = 2.0;
        double r426354 = r426352 * r426353;
        double r426355 = r426354 / r426345;
        double r426356 = r426344 - r426347;
        double r426357 = r426355 / r426356;
        double r426358 = -1.2976781138557186e-286;
        bool r426359 = r426349 <= r426358;
        double r426360 = r426354 / r426349;
        double r426361 = 5.0467042402393e-316;
        bool r426362 = r426349 <= r426361;
        double r426363 = r426353 / r426356;
        double r426364 = r426352 / r426345;
        double r426365 = r426363 * r426364;
        double r426366 = 3.075492820835173e+268;
        bool r426367 = r426349 <= r426366;
        double r426368 = r426367 ? r426360 : r426357;
        double r426369 = r426362 ? r426365 : r426368;
        double r426370 = r426359 ? r426360 : r426369;
        double r426371 = r426351 ? r426357 : r426370;
        return r426371;
}

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

Original7.0
Target2.2
Herbie0.2
\[\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 3 regimes
  2. if (- (* y z) (* t z)) < -inf.0 or 3.075492820835173e+268 < (- (* y z) (* t z))

    1. Initial program 22.4

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied distribute-rgt-out--17.9

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

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

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

    if -inf.0 < (- (* y z) (* t z)) < -1.2976781138557186e-286 or 5.0467042402393e-316 < (- (* y z) (* t z)) < 3.075492820835173e+268

    1. Initial program 0.2

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

    if -1.2976781138557186e-286 < (- (* y z) (* t z)) < 5.0467042402393e-316

    1. Initial program 51.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -1.297678113855718635658789434496889949182 \cdot 10^{-286}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 5.046704240239332707872033601746706650501 \cdot 10^{-316}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 3.07549282083517302392638365759120992158 \cdot 10^{268}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \end{array}\]

Reproduce

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

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

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