Average Error: 6.6 → 3.3
Time: 15.4s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le 1.3435888100724286 \cdot 10^{+183}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2.0}}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le 1.3435888100724286 \cdot 10^{+183}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2.0}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r31094926 = x;
        double r31094927 = 2.0;
        double r31094928 = r31094926 * r31094927;
        double r31094929 = y;
        double r31094930 = z;
        double r31094931 = r31094929 * r31094930;
        double r31094932 = t;
        double r31094933 = r31094932 * r31094930;
        double r31094934 = r31094931 - r31094933;
        double r31094935 = r31094928 / r31094934;
        return r31094935;
}

double f(double x, double y, double z, double t) {
        double r31094936 = y;
        double r31094937 = z;
        double r31094938 = r31094936 * r31094937;
        double r31094939 = t;
        double r31094940 = r31094939 * r31094937;
        double r31094941 = r31094938 - r31094940;
        double r31094942 = 1.3435888100724286e+183;
        bool r31094943 = r31094941 <= r31094942;
        double r31094944 = x;
        double r31094945 = r31094936 - r31094939;
        double r31094946 = r31094937 * r31094945;
        double r31094947 = 2.0;
        double r31094948 = r31094946 / r31094947;
        double r31094949 = r31094944 / r31094948;
        double r31094950 = r31094944 / r31094937;
        double r31094951 = r31094945 / r31094947;
        double r31094952 = r31094950 / r31094951;
        double r31094953 = r31094943 ? r31094949 : r31094952;
        return r31094953;
}

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.6
Target2.2
Herbie3.3
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \mathbf{elif}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt 1.045027827330126 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2.0}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* y z) (* t z)) < 1.3435888100724286e+183

    1. Initial program 4.0

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied associate-/l*4.0

      \[\leadsto \color{blue}{\frac{x}{\frac{y \cdot z - t \cdot z}{2.0}}}\]
    4. Simplified4.0

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

    if 1.3435888100724286e+183 < (- (* y z) (* t z))

    1. Initial program 16.2

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied associate-/l*16.1

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z \cdot \left(y - t\right)}{2.0}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity11.2

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2.0}}}\]
    8. Applied associate-/r*0.6

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{z}{1}}}{\frac{y - t}{2.0}}}\]
    9. Simplified0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le 1.3435888100724286 \cdot 10^{+183}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2.0}}\\ \end{array}\]

Reproduce

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