Average Error: 7.0 → 1.4
Time: 13.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -59715157321401631768576:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0:\\ \;\;\;\;\frac{\frac{1}{\frac{y - t}{2}}}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y - t}{\frac{x \cdot 2}{z}}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -59715157321401631768576:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

\mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0:\\
\;\;\;\;\frac{\frac{1}{\frac{y - t}{2}}}{\frac{z}{x}}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r24660065 = x;
        double r24660066 = 2.0;
        double r24660067 = r24660065 * r24660066;
        double r24660068 = y;
        double r24660069 = z;
        double r24660070 = r24660068 * r24660069;
        double r24660071 = t;
        double r24660072 = r24660071 * r24660069;
        double r24660073 = r24660070 - r24660072;
        double r24660074 = r24660067 / r24660073;
        return r24660074;
}

double f(double x, double y, double z, double t) {
        double r24660075 = x;
        double r24660076 = 2.0;
        double r24660077 = r24660075 * r24660076;
        double r24660078 = y;
        double r24660079 = z;
        double r24660080 = r24660078 * r24660079;
        double r24660081 = t;
        double r24660082 = r24660081 * r24660079;
        double r24660083 = r24660080 - r24660082;
        double r24660084 = r24660077 / r24660083;
        double r24660085 = -5.971515732140163e+22;
        bool r24660086 = r24660084 <= r24660085;
        double r24660087 = -0.0;
        bool r24660088 = r24660084 <= r24660087;
        double r24660089 = 1.0;
        double r24660090 = r24660078 - r24660081;
        double r24660091 = r24660090 / r24660076;
        double r24660092 = r24660089 / r24660091;
        double r24660093 = r24660079 / r24660075;
        double r24660094 = r24660092 / r24660093;
        double r24660095 = 7.820034338024704e+269;
        bool r24660096 = r24660084 <= r24660095;
        double r24660097 = r24660077 / r24660079;
        double r24660098 = r24660090 / r24660097;
        double r24660099 = r24660089 / r24660098;
        double r24660100 = r24660096 ? r24660084 : r24660099;
        double r24660101 = r24660088 ? r24660094 : r24660100;
        double r24660102 = r24660086 ? r24660084 : r24660101;
        return r24660102;
}

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
Herbie1.4
\[\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 (/ (* x 2.0) (- (* y z) (* t z))) < -5.971515732140163e+22 or -0.0 < (/ (* x 2.0) (- (* y z) (* t z))) < 7.820034338024704e+269

    1. Initial program 1.2

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

    if -5.971515732140163e+22 < (/ (* x 2.0) (- (* y z) (* t z))) < -0.0

    1. Initial program 8.6

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied clear-num9.0

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot z - t \cdot z}{x \cdot 2}}}\]
    4. Simplified9.0

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

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

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

    if 7.820034338024704e+269 < (/ (* x 2.0) (- (* y z) (* t z)))

    1. Initial program 49.0

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied clear-num49.1

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot z - t \cdot z}{x \cdot 2}}}\]
    4. Simplified19.8

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(y - t\right) \cdot z}{2 \cdot x}}}\]
    5. Using strategy rm
    6. Applied associate-/l*7.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -59715157321401631768576:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0:\\ \;\;\;\;\frac{\frac{1}{\frac{y - t}{2}}}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y - t}{\frac{x \cdot 2}{z}}}\\ \end{array}\]

Reproduce

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