Average Error: 6.9 → 5.5
Time: 9.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.558225734480629833036083443548553390336 \cdot 10^{208}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{\frac{1}{z}}{y - t}\\ \mathbf{elif}\;y \le 6.171057382867539840170668000327560127887 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;y \le 1.951130067970849161540972989726809538744 \cdot 10^{111}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z + z \cdot \left(-t\right)}\\ \mathbf{elif}\;y \le 1.538759424307254056311250070293585704887 \cdot 10^{171}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{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}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{\frac{1}{z}}{y - t}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r362913 = x;
        double r362914 = 2.0;
        double r362915 = r362913 * r362914;
        double r362916 = y;
        double r362917 = z;
        double r362918 = r362916 * r362917;
        double r362919 = t;
        double r362920 = r362919 * r362917;
        double r362921 = r362918 - r362920;
        double r362922 = r362915 / r362921;
        return r362922;
}

double f(double x, double y, double z, double t) {
        double r362923 = y;
        double r362924 = -2.55822573448063e+208;
        bool r362925 = r362923 <= r362924;
        double r362926 = x;
        double r362927 = 2.0;
        double r362928 = r362926 * r362927;
        double r362929 = 1.0;
        double r362930 = z;
        double r362931 = r362929 / r362930;
        double r362932 = t;
        double r362933 = r362923 - r362932;
        double r362934 = r362931 / r362933;
        double r362935 = r362928 * r362934;
        double r362936 = 6.17105738286754e-299;
        bool r362937 = r362923 <= r362936;
        double r362938 = r362928 / r362930;
        double r362939 = r362938 / r362933;
        double r362940 = 1.9511300679708492e+111;
        bool r362941 = r362923 <= r362940;
        double r362942 = r362923 * r362930;
        double r362943 = -r362932;
        double r362944 = r362930 * r362943;
        double r362945 = r362942 + r362944;
        double r362946 = r362928 / r362945;
        double r362947 = 1.538759424307254e+171;
        bool r362948 = r362923 <= r362947;
        double r362949 = r362927 * r362926;
        double r362950 = r362949 / r362933;
        double r362951 = r362950 / r362930;
        double r362952 = r362948 ? r362939 : r362951;
        double r362953 = r362941 ? r362946 : r362952;
        double r362954 = r362937 ? r362939 : r362953;
        double r362955 = r362925 ? r362935 : r362954;
        return r362955;
}

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 4 regimes
  2. if y < -2.55822573448063e+208

    1. Initial program 10.7

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{1} \cdot \frac{\frac{1}{z}}{y - t}}\]
    9. Simplified6.7

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

    if -2.55822573448063e+208 < y < 6.17105738286754e-299 or 1.9511300679708492e+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 6.17105738286754e-299 < y < 1.9511300679708492e+111

    1. Initial program 5.3

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

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

      \[\leadsto \frac{x \cdot 2}{z \cdot \color{blue}{\left(y + \left(-t\right)\right)}}\]
    5. Applied distribute-lft-in5.3

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

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

    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 associate-/r*8.4

      \[\leadsto \color{blue}{\frac{\frac{x \cdot 2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied clear-num8.9

      \[\leadsto \color{blue}{\frac{1}{\frac{y - t}{\frac{x \cdot 2}{z}}}}\]
    7. Using strategy rm
    8. Applied associate-/r/7.5

      \[\leadsto \frac{1}{\color{blue}{\frac{y - t}{x \cdot 2} \cdot z}}\]
    9. Applied associate-/r*7.1

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{y - t}{x \cdot 2}}}{z}}\]
    10. Simplified6.7

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

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

Reproduce

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