Average Error: 6.8 → 2.7
Time: 8.3s
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 r648727 = x;
        double r648728 = 2.0;
        double r648729 = r648727 * r648728;
        double r648730 = y;
        double r648731 = z;
        double r648732 = r648730 * r648731;
        double r648733 = t;
        double r648734 = r648733 * r648731;
        double r648735 = r648732 - r648734;
        double r648736 = r648729 / r648735;
        return r648736;
}

double f(double x, double y, double z, double t) {
        double r648737 = x;
        double r648738 = -1.6653143676812737e-57;
        bool r648739 = r648737 <= r648738;
        double r648740 = 3.501200984228306e-154;
        bool r648741 = r648737 <= r648740;
        double r648742 = !r648741;
        bool r648743 = r648739 || r648742;
        double r648744 = y;
        double r648745 = t;
        double r648746 = r648744 - r648745;
        double r648747 = r648737 / r648746;
        double r648748 = z;
        double r648749 = 2.0;
        double r648750 = r648748 / r648749;
        double r648751 = r648747 / r648750;
        double r648752 = r648746 * r648750;
        double r648753 = r648737 / r648752;
        double r648754 = r648743 ? r648751 : r648753;
        return r648754;
}

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))))