Average Error: 6.6 → 5.0
Time: 13.1s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;t \le 1.252162427360217230393195741755373415123 \cdot 10^{-291} \lor \neg \left(t \le 1.175763829828214372931466074322922795802 \cdot 10^{77}\right):\\ \;\;\;\;\frac{x \cdot 2}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{\frac{1}{z}}{\sqrt[3]{y - t}}\\ \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}\;t \le 1.252162427360217230393195741755373415123 \cdot 10^{-291} \lor \neg \left(t \le 1.175763829828214372931466074322922795802 \cdot 10^{77}\right):\\
\;\;\;\;\frac{x \cdot 2}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{\frac{1}{z}}{\sqrt[3]{y - t}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r371056 = x;
        double r371057 = 2.0;
        double r371058 = r371056 * r371057;
        double r371059 = y;
        double r371060 = z;
        double r371061 = r371059 * r371060;
        double r371062 = t;
        double r371063 = r371062 * r371060;
        double r371064 = r371061 - r371063;
        double r371065 = r371058 / r371064;
        return r371065;
}

double f(double x, double y, double z, double t) {
        double r371066 = t;
        double r371067 = 1.2521624273602172e-291;
        bool r371068 = r371066 <= r371067;
        double r371069 = 1.1757638298282144e+77;
        bool r371070 = r371066 <= r371069;
        double r371071 = !r371070;
        bool r371072 = r371068 || r371071;
        double r371073 = x;
        double r371074 = 2.0;
        double r371075 = r371073 * r371074;
        double r371076 = y;
        double r371077 = r371076 - r371066;
        double r371078 = cbrt(r371077);
        double r371079 = r371078 * r371078;
        double r371080 = r371075 / r371079;
        double r371081 = 1.0;
        double r371082 = z;
        double r371083 = r371081 / r371082;
        double r371084 = r371083 / r371078;
        double r371085 = r371080 * r371084;
        double r371086 = r371075 / r371082;
        double r371087 = r371086 / r371077;
        double r371088 = r371072 ? r371085 : r371087;
        return r371088;
}

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.6
Target2.0
Herbie5.0
\[\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 t < 1.2521624273602172e-291 or 1.1757638298282144e+77 < t

    1. Initial program 7.5

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

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

      \[\leadsto \color{blue}{\frac{\frac{x \cdot 2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt7.0

      \[\leadsto \frac{\frac{x \cdot 2}{z}}{\color{blue}{\left(\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}\right) \cdot \sqrt[3]{y - t}}}\]
    7. Applied div-inv7.0

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

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

    if 1.2521624273602172e-291 < t < 1.1757638298282144e+77

    1. Initial program 4.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le 1.252162427360217230393195741755373415123 \cdot 10^{-291} \lor \neg \left(t \le 1.175763829828214372931466074322922795802 \cdot 10^{77}\right):\\ \;\;\;\;\frac{x \cdot 2}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{\frac{1}{z}}{\sqrt[3]{y - t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 +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))))