Average Error: 7.1 → 2.5
Time: 17.0s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.4437892270302555 \cdot 10^{+63}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \mathbf{elif}\;x \le 2.662792445968159 \cdot 10^{-130}:\\ \;\;\;\;\frac{2.0 \cdot \frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -6.4437892270302555 \cdot 10^{+63}:\\
\;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\

\mathbf{elif}\;x \le 2.662792445968159 \cdot 10^{-130}:\\
\;\;\;\;\frac{2.0 \cdot \frac{x}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r23198056 = x;
        double r23198057 = 2.0;
        double r23198058 = r23198056 * r23198057;
        double r23198059 = y;
        double r23198060 = z;
        double r23198061 = r23198059 * r23198060;
        double r23198062 = t;
        double r23198063 = r23198062 * r23198060;
        double r23198064 = r23198061 - r23198063;
        double r23198065 = r23198058 / r23198064;
        return r23198065;
}

double f(double x, double y, double z, double t) {
        double r23198066 = x;
        double r23198067 = -6.4437892270302555e+63;
        bool r23198068 = r23198066 <= r23198067;
        double r23198069 = 2.0;
        double r23198070 = y;
        double r23198071 = t;
        double r23198072 = r23198070 - r23198071;
        double r23198073 = r23198066 / r23198072;
        double r23198074 = z;
        double r23198075 = r23198073 / r23198074;
        double r23198076 = r23198069 * r23198075;
        double r23198077 = 2.662792445968159e-130;
        bool r23198078 = r23198066 <= r23198077;
        double r23198079 = r23198066 / r23198074;
        double r23198080 = r23198069 * r23198079;
        double r23198081 = r23198080 / r23198072;
        double r23198082 = r23198078 ? r23198081 : r23198076;
        double r23198083 = r23198068 ? r23198076 : r23198082;
        return r23198083;
}

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.1
Target2.1
Herbie2.5
\[\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 x < -6.4437892270302555e+63 or 2.662792445968159e-130 < x

    1. Initial program 10.1

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

      \[\leadsto \color{blue}{\frac{2.0}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied div-inv8.8

      \[\leadsto \color{blue}{\left(2.0 \cdot \frac{1}{y - t}\right)} \cdot \frac{x}{z}\]
    5. Applied associate-*l*8.8

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

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

    if -6.4437892270302555e+63 < x < 2.662792445968159e-130

    1. Initial program 3.7

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Simplified2.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.4437892270302555 \cdot 10^{+63}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \mathbf{elif}\;x \le 2.662792445968159 \cdot 10^{-130}:\\ \;\;\;\;\frac{2.0 \cdot \frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \end{array}\]

Reproduce

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