Average Error: 6.8 → 1.2
Time: 13.4s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.989577839511013605559193707688169001455 \cdot 10^{188}:\\ \;\;\;\;\frac{\frac{x}{y - t} \cdot 2}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 1.05207730988959976736022850622177780129 \cdot 10^{250}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y - t} \cdot 2}{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 -1.989577839511013605559193707688169001455 \cdot 10^{188}:\\
\;\;\;\;\frac{\frac{x}{y - t} \cdot 2}{z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r39462431 = x;
        double r39462432 = 2.0;
        double r39462433 = r39462431 * r39462432;
        double r39462434 = y;
        double r39462435 = z;
        double r39462436 = r39462434 * r39462435;
        double r39462437 = t;
        double r39462438 = r39462437 * r39462435;
        double r39462439 = r39462436 - r39462438;
        double r39462440 = r39462433 / r39462439;
        return r39462440;
}

double f(double x, double y, double z, double t) {
        double r39462441 = y;
        double r39462442 = z;
        double r39462443 = r39462441 * r39462442;
        double r39462444 = t;
        double r39462445 = r39462444 * r39462442;
        double r39462446 = r39462443 - r39462445;
        double r39462447 = -1.9895778395110136e+188;
        bool r39462448 = r39462446 <= r39462447;
        double r39462449 = x;
        double r39462450 = r39462441 - r39462444;
        double r39462451 = r39462449 / r39462450;
        double r39462452 = 2.0;
        double r39462453 = r39462451 * r39462452;
        double r39462454 = r39462453 / r39462442;
        double r39462455 = 1.0520773098895998e+250;
        bool r39462456 = r39462446 <= r39462455;
        double r39462457 = r39462449 * r39462452;
        double r39462458 = r39462457 / r39462446;
        double r39462459 = r39462456 ? r39462458 : r39462454;
        double r39462460 = r39462448 ? r39462454 : r39462459;
        return r39462460;
}

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.8
Target2.1
Herbie1.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 2 regimes
  2. if (- (* y z) (* t z)) < -1.9895778395110136e+188 or 1.0520773098895998e+250 < (- (* y z) (* t z))

    1. Initial program 16.1

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

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

      \[\leadsto \color{blue}{\frac{\frac{2}{y - t} \cdot x}{z}}\]
    5. Using strategy rm
    6. Applied div-inv0.4

      \[\leadsto \frac{\color{blue}{\left(2 \cdot \frac{1}{y - t}\right)} \cdot x}{z}\]
    7. Applied associate-*l*0.4

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

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

    if -1.9895778395110136e+188 < (- (* y z) (* t z)) < 1.0520773098895998e+250

    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.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.989577839511013605559193707688169001455 \cdot 10^{188}:\\ \;\;\;\;\frac{\frac{x}{y - t} \cdot 2}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 1.05207730988959976736022850622177780129 \cdot 10^{250}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y - t} \cdot 2}{z}\\ \end{array}\]

Reproduce

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