Average Error: 7.0 → 0.6
Time: 43.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.139725979683943522159912749677994697875 \cdot 10^{233}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -3.245316065863089464287331474884689067707 \cdot 10^{-117}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 1.185757550018991706023765102883731293676 \cdot 10^{-322}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 8.381475908009203724065215376399557533858 \cdot 10^{226}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -1.139725979683943522159912749677994697875 \cdot 10^{233}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le -3.245316065863089464287331474884689067707 \cdot 10^{-117}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le 1.185757550018991706023765102883731293676 \cdot 10^{-322}:\\
\;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le 8.381475908009203724065215376399557533858 \cdot 10^{226}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r25959691 = x;
        double r25959692 = 2.0;
        double r25959693 = r25959691 * r25959692;
        double r25959694 = y;
        double r25959695 = z;
        double r25959696 = r25959694 * r25959695;
        double r25959697 = t;
        double r25959698 = r25959697 * r25959695;
        double r25959699 = r25959696 - r25959698;
        double r25959700 = r25959693 / r25959699;
        return r25959700;
}

double f(double x, double y, double z, double t) {
        double r25959701 = y;
        double r25959702 = z;
        double r25959703 = r25959701 * r25959702;
        double r25959704 = t;
        double r25959705 = r25959704 * r25959702;
        double r25959706 = r25959703 - r25959705;
        double r25959707 = -1.1397259796839435e+233;
        bool r25959708 = r25959706 <= r25959707;
        double r25959709 = x;
        double r25959710 = 2.0;
        double r25959711 = r25959709 * r25959710;
        double r25959712 = r25959701 - r25959704;
        double r25959713 = r25959711 / r25959712;
        double r25959714 = r25959713 / r25959702;
        double r25959715 = -3.2453160658630895e-117;
        bool r25959716 = r25959706 <= r25959715;
        double r25959717 = r25959711 / r25959706;
        double r25959718 = 1.185757550019e-322;
        bool r25959719 = r25959706 <= r25959718;
        double r25959720 = r25959710 / r25959712;
        double r25959721 = r25959709 / r25959702;
        double r25959722 = r25959720 * r25959721;
        double r25959723 = 8.381475908009204e+226;
        bool r25959724 = r25959706 <= r25959723;
        double r25959725 = r25959724 ? r25959717 : r25959722;
        double r25959726 = r25959719 ? r25959722 : r25959725;
        double r25959727 = r25959716 ? r25959717 : r25959726;
        double r25959728 = r25959708 ? r25959714 : r25959727;
        return r25959728;
}

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.0
Herbie0.6
\[\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 (- (* y z) (* t z)) < -1.1397259796839435e+233

    1. Initial program 14.0

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

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

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

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

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

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

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

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

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

    if -1.1397259796839435e+233 < (- (* y z) (* t z)) < -3.2453160658630895e-117 or 1.185757550019e-322 < (- (* y z) (* t z)) < 8.381475908009204e+226

    1. Initial program 0.3

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

    if -3.2453160658630895e-117 < (- (* y z) (* t z)) < 1.185757550019e-322 or 8.381475908009204e+226 < (- (* y z) (* t z))

    1. Initial program 19.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.139725979683943522159912749677994697875 \cdot 10^{233}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -3.245316065863089464287331474884689067707 \cdot 10^{-117}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 1.185757550018991706023765102883731293676 \cdot 10^{-322}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 8.381475908009203724065215376399557533858 \cdot 10^{226}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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