Average Error: 7.0 → 3.0
Time: 24.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.948586446622267662315685094511317832413 \cdot 10^{96}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;z \le 138177673017854208086533707964897199915000:\\ \;\;\;\;\frac{x}{\frac{y - t}{\frac{2}{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\frac{y - t}{\frac{2}{\sqrt[3]{z}}}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -6.948586446622267662315685094511317832413 \cdot 10^{96}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

\mathbf{elif}\;z \le 138177673017854208086533707964897199915000:\\
\;\;\;\;\frac{x}{\frac{y - t}{\frac{2}{z}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\frac{y - t}{\frac{2}{\sqrt[3]{z}}}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r485613 = x;
        double r485614 = 2.0;
        double r485615 = r485613 * r485614;
        double r485616 = y;
        double r485617 = z;
        double r485618 = r485616 * r485617;
        double r485619 = t;
        double r485620 = r485619 * r485617;
        double r485621 = r485618 - r485620;
        double r485622 = r485615 / r485621;
        return r485622;
}

double f(double x, double y, double z, double t) {
        double r485623 = z;
        double r485624 = -6.948586446622268e+96;
        bool r485625 = r485623 <= r485624;
        double r485626 = x;
        double r485627 = 2.0;
        double r485628 = r485626 * r485627;
        double r485629 = r485628 / r485623;
        double r485630 = y;
        double r485631 = t;
        double r485632 = r485630 - r485631;
        double r485633 = r485629 / r485632;
        double r485634 = 1.381776730178542e+41;
        bool r485635 = r485623 <= r485634;
        double r485636 = r485627 / r485623;
        double r485637 = r485632 / r485636;
        double r485638 = r485626 / r485637;
        double r485639 = cbrt(r485623);
        double r485640 = r485639 * r485639;
        double r485641 = r485626 / r485640;
        double r485642 = r485627 / r485639;
        double r485643 = r485632 / r485642;
        double r485644 = r485641 / r485643;
        double r485645 = r485635 ? r485638 : r485644;
        double r485646 = r485625 ? r485633 : r485645;
        return r485646;
}

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.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 3 regimes
  2. if z < -6.948586446622268e+96

    1. Initial program 14.7

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

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

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

    if -6.948586446622268e+96 < z < 1.381776730178542e+41

    1. Initial program 2.7

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

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

      \[\leadsto \color{blue}{\frac{\frac{x \cdot 2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity8.5

      \[\leadsto \frac{\frac{x \cdot 2}{\color{blue}{1 \cdot z}}}{y - t}\]
    7. Applied times-frac8.6

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

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

    if 1.381776730178542e+41 < z

    1. Initial program 11.7

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{2}{\sqrt[3]{z}}}}{y - t}\]
    8. Applied associate-/l*4.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.948586446622267662315685094511317832413 \cdot 10^{96}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;z \le 138177673017854208086533707964897199915000:\\ \;\;\;\;\frac{x}{\frac{y - t}{\frac{2}{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\frac{y - t}{\frac{2}{\sqrt[3]{z}}}}\\ \end{array}\]

Reproduce

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