Average Error: 6.8 → 2.4
Time: 18.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -755289072304684734196219904:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{2}{y - t} \cdot x\right)\\ \mathbf{elif}\;z \le 1.396543592613626308964562986658656960328 \cdot 10^{74}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -755289072304684734196219904:\\
\;\;\;\;\frac{1}{z} \cdot \left(\frac{2}{y - t} \cdot x\right)\\

\mathbf{elif}\;z \le 1.396543592613626308964562986658656960328 \cdot 10^{74}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r28343460 = x;
        double r28343461 = 2.0;
        double r28343462 = r28343460 * r28343461;
        double r28343463 = y;
        double r28343464 = z;
        double r28343465 = r28343463 * r28343464;
        double r28343466 = t;
        double r28343467 = r28343466 * r28343464;
        double r28343468 = r28343465 - r28343467;
        double r28343469 = r28343462 / r28343468;
        return r28343469;
}

double f(double x, double y, double z, double t) {
        double r28343470 = z;
        double r28343471 = -7.552890723046847e+26;
        bool r28343472 = r28343470 <= r28343471;
        double r28343473 = 1.0;
        double r28343474 = r28343473 / r28343470;
        double r28343475 = 2.0;
        double r28343476 = y;
        double r28343477 = t;
        double r28343478 = r28343476 - r28343477;
        double r28343479 = r28343475 / r28343478;
        double r28343480 = x;
        double r28343481 = r28343479 * r28343480;
        double r28343482 = r28343474 * r28343481;
        double r28343483 = 1.3965435926136263e+74;
        bool r28343484 = r28343470 <= r28343483;
        double r28343485 = r28343480 * r28343475;
        double r28343486 = r28343470 * r28343478;
        double r28343487 = r28343485 / r28343486;
        double r28343488 = r28343480 / r28343470;
        double r28343489 = r28343488 / r28343478;
        double r28343490 = r28343475 * r28343489;
        double r28343491 = r28343484 ? r28343487 : r28343490;
        double r28343492 = r28343472 ? r28343482 : r28343491;
        return r28343492;
}

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
Herbie2.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 3 regimes
  2. if z < -7.552890723046847e+26

    1. Initial program 11.2

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied div-inv2.1

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

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

    if -7.552890723046847e+26 < z < 1.3965435926136263e+74

    1. Initial program 2.4

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

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

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

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

      \[\leadsto \color{blue}{\frac{2 \cdot x}{y - t}} \cdot \frac{1}{z}\]
    8. Applied frac-times2.4

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

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

    if 1.3965435926136263e+74 < z

    1. Initial program 13.3

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -755289072304684734196219904:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{2}{y - t} \cdot x\right)\\ \mathbf{elif}\;z \le 1.396543592613626308964562986658656960328 \cdot 10^{74}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\ \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))))