Average Error: 7.0 → 3.1
Time: 9.5s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.75990003782298736234312668363110151253 \cdot 10^{-96} \lor \neg \left(z \le 5.732254660182225784731442368188511089989 \cdot 10^{-44}\right) \land z \le 1.543139768798940977224028096103984027981 \cdot 10^{209}:\\ \;\;\;\;\frac{\frac{1}{z}}{\frac{y - t}{x \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -5.75990003782298736234312668363110151253 \cdot 10^{-96} \lor \neg \left(z \le 5.732254660182225784731442368188511089989 \cdot 10^{-44}\right) \land z \le 1.543139768798940977224028096103984027981 \cdot 10^{209}:\\
\;\;\;\;\frac{\frac{1}{z}}{\frac{y - t}{x \cdot 2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r362427 = x;
        double r362428 = 2.0;
        double r362429 = r362427 * r362428;
        double r362430 = y;
        double r362431 = z;
        double r362432 = r362430 * r362431;
        double r362433 = t;
        double r362434 = r362433 * r362431;
        double r362435 = r362432 - r362434;
        double r362436 = r362429 / r362435;
        return r362436;
}

double f(double x, double y, double z, double t) {
        double r362437 = z;
        double r362438 = -5.759900037822987e-96;
        bool r362439 = r362437 <= r362438;
        double r362440 = 5.732254660182226e-44;
        bool r362441 = r362437 <= r362440;
        double r362442 = !r362441;
        double r362443 = 1.543139768798941e+209;
        bool r362444 = r362437 <= r362443;
        bool r362445 = r362442 && r362444;
        bool r362446 = r362439 || r362445;
        double r362447 = 1.0;
        double r362448 = r362447 / r362437;
        double r362449 = y;
        double r362450 = t;
        double r362451 = r362449 - r362450;
        double r362452 = x;
        double r362453 = 2.0;
        double r362454 = r362452 * r362453;
        double r362455 = r362451 / r362454;
        double r362456 = r362448 / r362455;
        double r362457 = r362437 * r362451;
        double r362458 = r362454 / r362457;
        double r362459 = r362446 ? r362456 : r362458;
        return r362459;
}

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
Herbie3.1
\[\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 < -5.759900037822987e-96 or 5.732254660182226e-44 < z < 1.543139768798941e+209

    1. Initial program 8.2

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{z \cdot \left(y - t\right)}{x \cdot 2}}}\]
    5. Using strategy rm
    6. Applied div-inv7.2

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

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{z}}{y - t}}}{\frac{1}{x \cdot 2}}\]
    10. Using strategy rm
    11. Applied div-inv6.2

      \[\leadsto \frac{\color{blue}{\frac{1}{z} \cdot \frac{1}{y - t}}}{\frac{1}{x \cdot 2}}\]
    12. Applied associate-/l*2.0

      \[\leadsto \color{blue}{\frac{\frac{1}{z}}{\frac{\frac{1}{x \cdot 2}}{\frac{1}{y - t}}}}\]
    13. Simplified2.0

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

    if -5.759900037822987e-96 < z < 5.732254660182226e-44 or 1.543139768798941e+209 < z

    1. Initial program 5.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.75990003782298736234312668363110151253 \cdot 10^{-96} \lor \neg \left(z \le 5.732254660182225784731442368188511089989 \cdot 10^{-44}\right) \land z \le 1.543139768798940977224028096103984027981 \cdot 10^{209}:\\ \;\;\;\;\frac{\frac{1}{z}}{\frac{y - t}{x \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019235 +o rules:numerics
(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))))