Average Error: 6.7 → 0.3
Time: 7.1s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -4.3120437454803144 \cdot 10^{250} \lor \neg \left(y \cdot z - t \cdot z \le -2.6777160931771426 \cdot 10^{-239} \lor \neg \left(y \cdot z - t \cdot z \le 0.0\right) \land y \cdot z - t \cdot z \le 4.8948064958718642 \cdot 10^{265}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -4.3120437454803144 \cdot 10^{250} \lor \neg \left(y \cdot z - t \cdot z \le -2.6777160931771426 \cdot 10^{-239} \lor \neg \left(y \cdot z - t \cdot z \le 0.0\right) \land y \cdot z - t \cdot z \le 4.8948064958718642 \cdot 10^{265}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r511928 = x;
        double r511929 = 2.0;
        double r511930 = r511928 * r511929;
        double r511931 = y;
        double r511932 = z;
        double r511933 = r511931 * r511932;
        double r511934 = t;
        double r511935 = r511934 * r511932;
        double r511936 = r511933 - r511935;
        double r511937 = r511930 / r511936;
        return r511937;
}

double f(double x, double y, double z, double t) {
        double r511938 = y;
        double r511939 = z;
        double r511940 = r511938 * r511939;
        double r511941 = t;
        double r511942 = r511941 * r511939;
        double r511943 = r511940 - r511942;
        double r511944 = -4.3120437454803144e+250;
        bool r511945 = r511943 <= r511944;
        double r511946 = -2.6777160931771426e-239;
        bool r511947 = r511943 <= r511946;
        double r511948 = 0.0;
        bool r511949 = r511943 <= r511948;
        double r511950 = !r511949;
        double r511951 = 4.894806495871864e+265;
        bool r511952 = r511943 <= r511951;
        bool r511953 = r511950 && r511952;
        bool r511954 = r511947 || r511953;
        double r511955 = !r511954;
        bool r511956 = r511945 || r511955;
        double r511957 = x;
        double r511958 = 2.0;
        double r511959 = r511957 * r511958;
        double r511960 = r511959 / r511939;
        double r511961 = r511938 - r511941;
        double r511962 = r511960 / r511961;
        double r511963 = r511959 / r511943;
        double r511964 = r511956 ? r511962 : r511963;
        return r511964;
}

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.7
Target2.0
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061 \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.04502782733012586 \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 (- (* y z) (* t z)) < -4.3120437454803144e+250 or -2.6777160931771426e-239 < (- (* y z) (* t z)) < 0.0 or 4.894806495871864e+265 < (- (* y z) (* t z))

    1. Initial program 20.7

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

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

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

    if -4.3120437454803144e+250 < (- (* y z) (* t z)) < -2.6777160931771426e-239 or 0.0 < (- (* y z) (* t z)) < 4.894806495871864e+265

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -4.3120437454803144 \cdot 10^{250} \lor \neg \left(y \cdot z - t \cdot z \le -2.6777160931771426 \cdot 10^{-239} \lor \neg \left(y \cdot z - t \cdot z \le 0.0\right) \land y \cdot z - t \cdot z \le 4.8948064958718642 \cdot 10^{265}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 
(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.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

  (/ (* x 2) (- (* y z) (* t z))))