Average Error: 6.9 → 5.5
Time: 10.7s
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 r341096 = x;
        double r341097 = 2.0;
        double r341098 = r341096 * r341097;
        double r341099 = y;
        double r341100 = z;
        double r341101 = r341099 * r341100;
        double r341102 = t;
        double r341103 = r341102 * r341100;
        double r341104 = r341101 - r341103;
        double r341105 = r341098 / r341104;
        return r341105;
}

double f(double x, double y, double z, double t) {
        double r341106 = y;
        double r341107 = -2.55822573448063e+208;
        bool r341108 = r341106 <= r341107;
        double r341109 = x;
        double r341110 = 2.0;
        double r341111 = r341109 * r341110;
        double r341112 = 1.0;
        double r341113 = z;
        double r341114 = r341112 / r341113;
        double r341115 = t;
        double r341116 = r341106 - r341115;
        double r341117 = r341114 / r341116;
        double r341118 = r341111 * r341117;
        double r341119 = 6.17105738286754e-299;
        bool r341120 = r341106 <= r341119;
        double r341121 = r341111 / r341113;
        double r341122 = r341121 / r341116;
        double r341123 = 1.9511300679708492e+111;
        bool r341124 = r341106 <= r341123;
        double r341125 = r341106 * r341113;
        double r341126 = -r341115;
        double r341127 = r341113 * r341126;
        double r341128 = r341125 + r341127;
        double r341129 = r341111 / r341128;
        double r341130 = 1.538759424307254e+171;
        bool r341131 = r341106 <= r341130;
        double r341132 = r341110 * r341109;
        double r341133 = r341132 / r341116;
        double r341134 = r341133 / r341113;
        double r341135 = r341131 ? r341122 : r341134;
        double r341136 = r341124 ? r341129 : r341135;
        double r341137 = r341120 ? r341122 : r341136;
        double r341138 = r341108 ? r341118 : r341137;
        return r341138;
}

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))))