Average Error: 6.9 → 5.5
Time: 11.4s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.558225734480629833036083443548553390336 \cdot 10^{208}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \le 6.171057382867539840170668000327560127887 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;y \le 2.246074663959288529012282053243044048945 \cdot 10^{111}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \le 1.538759424307254056311250070293585704887 \cdot 10^{171}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \le -2.558225734480629833036083443548553390336 \cdot 10^{208}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\

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

\mathbf{elif}\;y \le 2.246074663959288529012282053243044048945 \cdot 10^{111}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r302014 = x;
        double r302015 = 2.0;
        double r302016 = r302014 * r302015;
        double r302017 = y;
        double r302018 = z;
        double r302019 = r302017 * r302018;
        double r302020 = t;
        double r302021 = r302020 * r302018;
        double r302022 = r302019 - r302021;
        double r302023 = r302016 / r302022;
        return r302023;
}

double f(double x, double y, double z, double t) {
        double r302024 = y;
        double r302025 = -2.55822573448063e+208;
        bool r302026 = r302024 <= r302025;
        double r302027 = x;
        double r302028 = 2.0;
        double r302029 = r302027 * r302028;
        double r302030 = z;
        double r302031 = t;
        double r302032 = r302024 - r302031;
        double r302033 = r302030 * r302032;
        double r302034 = r302029 / r302033;
        double r302035 = 6.17105738286754e-299;
        bool r302036 = r302024 <= r302035;
        double r302037 = r302029 / r302030;
        double r302038 = r302037 / r302032;
        double r302039 = 2.2460746639592885e+111;
        bool r302040 = r302024 <= r302039;
        double r302041 = 1.538759424307254e+171;
        bool r302042 = r302024 <= r302041;
        double r302043 = r302028 / r302032;
        double r302044 = r302027 * r302043;
        double r302045 = r302044 / r302030;
        double r302046 = r302042 ? r302038 : r302045;
        double r302047 = r302040 ? r302034 : r302046;
        double r302048 = r302036 ? r302038 : r302047;
        double r302049 = r302026 ? r302034 : r302048;
        return r302049;
}

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.9
Target2.2
Herbie5.5
\[\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 < -2.55822573448063e+208 or 6.17105738286754e-299 < y < 2.2460746639592885e+111

    1. Initial program 6.4

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

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

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

      \[\leadsto \frac{x}{z} \cdot \frac{2}{\color{blue}{1 \cdot \left(y - t\right)}}\]
    7. Applied add-sqr-sqrt5.9

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

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

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

      \[\leadsto \color{blue}{\left(\frac{x}{z} \cdot \sqrt{2}\right)} \cdot \frac{\sqrt{2}}{y - t}\]
    11. Using strategy rm
    12. Applied associate-*l/5.7

      \[\leadsto \color{blue}{\frac{x \cdot \sqrt{2}}{z}} \cdot \frac{\sqrt{2}}{y - t}\]
    13. Applied frac-times5.8

      \[\leadsto \color{blue}{\frac{\left(x \cdot \sqrt{2}\right) \cdot \sqrt{2}}{z \cdot \left(y - t\right)}}\]
    14. Simplified5.4

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

    if -2.55822573448063e+208 < y < 6.17105738286754e-299 or 2.2460746639592885e+111 < y < 1.538759424307254e+171

    1. Initial program 6.4

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

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

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

    if 1.538759424307254e+171 < y

    1. Initial program 10.5

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

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

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \frac{2}{y - t}}\]
    5. Using strategy rm
    6. Applied associate-*l/6.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.558225734480629833036083443548553390336 \cdot 10^{208}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \le 6.171057382867539840170668000327560127887 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;y \le 2.246074663959288529012282053243044048945 \cdot 10^{111}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \le 1.538759424307254056311250070293585704887 \cdot 10^{171}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \end{array}\]

Reproduce

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