Average Error: 6.9 → 4.3
Time: 16.8s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le 9.689975950898660972005034929956018776762 \cdot 10^{83}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le 9.689975950898660972005034929956018776762 \cdot 10^{83}:\\
\;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r24626987 = x;
        double r24626988 = 2.0;
        double r24626989 = r24626987 * r24626988;
        double r24626990 = y;
        double r24626991 = z;
        double r24626992 = r24626990 * r24626991;
        double r24626993 = t;
        double r24626994 = r24626993 * r24626991;
        double r24626995 = r24626992 - r24626994;
        double r24626996 = r24626989 / r24626995;
        return r24626996;
}

double f(double x, double y, double z, double t) {
        double r24626997 = x;
        double r24626998 = 2.0;
        double r24626999 = r24626997 * r24626998;
        double r24627000 = 9.689975950898661e+83;
        bool r24627001 = r24626999 <= r24627000;
        double r24627002 = y;
        double r24627003 = t;
        double r24627004 = r24627002 - r24627003;
        double r24627005 = r24626998 / r24627004;
        double r24627006 = z;
        double r24627007 = r24626997 / r24627006;
        double r24627008 = r24627005 * r24627007;
        double r24627009 = r24627004 / r24626997;
        double r24627010 = r24627006 * r24627009;
        double r24627011 = r24626998 / r24627010;
        double r24627012 = r24627001 ? r24627008 : r24627011;
        return r24627012;
}

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.3
Herbie4.3
\[\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 2 regimes
  2. if (* x 2.0) < 9.689975950898661e+83

    1. Initial program 5.5

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

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

    if 9.689975950898661e+83 < (* x 2.0)

    1. Initial program 13.7

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \le 9.689975950898660972005034929956018776762 \cdot 10^{83}:\\ \;\;\;\;\frac{2}{y - t} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\ \end{array}\]

Reproduce

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