Average Error: 6.8 → 2.7
Time: 8.4s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.66531436768127368 \cdot 10^{-57} \lor \neg \left(x \le 3.501200984228306 \cdot 10^{-154}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{\frac{z}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -1.66531436768127368 \cdot 10^{-57} \lor \neg \left(x \le 3.501200984228306 \cdot 10^{-154}\right):\\
\;\;\;\;\frac{\frac{x}{y - t}}{\frac{z}{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r434138 = x;
        double r434139 = 2.0;
        double r434140 = r434138 * r434139;
        double r434141 = y;
        double r434142 = z;
        double r434143 = r434141 * r434142;
        double r434144 = t;
        double r434145 = r434144 * r434142;
        double r434146 = r434143 - r434145;
        double r434147 = r434140 / r434146;
        return r434147;
}

double f(double x, double y, double z, double t) {
        double r434148 = x;
        double r434149 = -1.6653143676812737e-57;
        bool r434150 = r434148 <= r434149;
        double r434151 = 3.501200984228306e-154;
        bool r434152 = r434148 <= r434151;
        double r434153 = !r434152;
        bool r434154 = r434150 || r434153;
        double r434155 = y;
        double r434156 = t;
        double r434157 = r434155 - r434156;
        double r434158 = r434148 / r434157;
        double r434159 = z;
        double r434160 = 2.0;
        double r434161 = r434159 / r434160;
        double r434162 = r434158 / r434161;
        double r434163 = r434157 * r434161;
        double r434164 = r434148 / r434163;
        double r434165 = r434154 ? r434162 : r434164;
        return r434165;
}

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.8
Target2.0
Herbie2.7
\[\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 x < -1.6653143676812737e-57 or 3.501200984228306e-154 < x

    1. Initial program 8.6

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    5. Simplified7.7

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

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

    if -1.6653143676812737e-57 < x < 3.501200984228306e-154

    1. Initial program 3.5

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\left(y - t\right) \cdot \frac{z}{2}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.66531436768127368 \cdot 10^{-57} \lor \neg \left(x \le 3.501200984228306 \cdot 10^{-154}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{\frac{z}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\ \end{array}\]

Reproduce

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