Average Error: 6.8 → 2.7
Time: 3.1s
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}{\frac{\left(y - t\right) \cdot 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}{\frac{\left(y - t\right) \cdot z}{2}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r376680 = x;
        double r376681 = 2.0;
        double r376682 = r376680 * r376681;
        double r376683 = y;
        double r376684 = z;
        double r376685 = r376683 * r376684;
        double r376686 = t;
        double r376687 = r376686 * r376684;
        double r376688 = r376685 - r376687;
        double r376689 = r376682 / r376688;
        return r376689;
}

double f(double x, double y, double z, double t) {
        double r376690 = x;
        double r376691 = -1.6653143676812737e-57;
        bool r376692 = r376690 <= r376691;
        double r376693 = 3.501200984228306e-154;
        bool r376694 = r376690 <= r376693;
        double r376695 = !r376694;
        bool r376696 = r376692 || r376695;
        double r376697 = y;
        double r376698 = t;
        double r376699 = r376697 - r376698;
        double r376700 = r376690 / r376699;
        double r376701 = z;
        double r376702 = 2.0;
        double r376703 = r376701 / r376702;
        double r376704 = r376700 / r376703;
        double r376705 = r376699 * r376701;
        double r376706 = r376705 / r376702;
        double r376707 = r376690 / r376706;
        double r376708 = r376696 ? r376704 : r376707;
        return r376708;
}

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{y - t}{1}}}{\frac{z}{2}}}\]
    9. Simplified3.0

      \[\leadsto \frac{\color{blue}{\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}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied *-commutative2.1

      \[\leadsto \frac{x}{\frac{\color{blue}{\left(y - t\right) \cdot 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}{\frac{\left(y - t\right) \cdot 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))))