Average Error: 7.0 → 3.1
Time: 10.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 r1656043 = x;
        double r1656044 = 2.0;
        double r1656045 = r1656043 * r1656044;
        double r1656046 = y;
        double r1656047 = z;
        double r1656048 = r1656046 * r1656047;
        double r1656049 = t;
        double r1656050 = r1656049 * r1656047;
        double r1656051 = r1656048 - r1656050;
        double r1656052 = r1656045 / r1656051;
        return r1656052;
}

double f(double x, double y, double z, double t) {
        double r1656053 = z;
        double r1656054 = -5.759900037822987e-96;
        bool r1656055 = r1656053 <= r1656054;
        double r1656056 = 5.732254660182226e-44;
        bool r1656057 = r1656053 <= r1656056;
        double r1656058 = !r1656057;
        double r1656059 = 1.543139768798941e+209;
        bool r1656060 = r1656053 <= r1656059;
        bool r1656061 = r1656058 && r1656060;
        bool r1656062 = r1656055 || r1656061;
        double r1656063 = 1.0;
        double r1656064 = r1656063 / r1656053;
        double r1656065 = y;
        double r1656066 = t;
        double r1656067 = r1656065 - r1656066;
        double r1656068 = x;
        double r1656069 = 2.0;
        double r1656070 = r1656068 * r1656069;
        double r1656071 = r1656067 / r1656070;
        double r1656072 = r1656064 / r1656071;
        double r1656073 = r1656053 * r1656067;
        double r1656074 = r1656070 / r1656073;
        double r1656075 = r1656062 ? r1656072 : r1656074;
        return r1656075;
}

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 
(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))))