Average Error: 7.2 → 2.2
Time: 5.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.6260780497245676 \cdot 10^{34} \lor \neg \left(x \le 3.47347495168652677 \cdot 10^{-84}\right):\\ \;\;\;\;1 \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -5.6260780497245676 \cdot 10^{34} \lor \neg \left(x \le 3.47347495168652677 \cdot 10^{-84}\right):\\
\;\;\;\;1 \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r527738 = x;
        double r527739 = 2.0;
        double r527740 = r527738 * r527739;
        double r527741 = y;
        double r527742 = z;
        double r527743 = r527741 * r527742;
        double r527744 = t;
        double r527745 = r527744 * r527742;
        double r527746 = r527743 - r527745;
        double r527747 = r527740 / r527746;
        return r527747;
}

double f(double x, double y, double z, double t) {
        double r527748 = x;
        double r527749 = -5.626078049724568e+34;
        bool r527750 = r527748 <= r527749;
        double r527751 = 3.4734749516865268e-84;
        bool r527752 = r527748 <= r527751;
        double r527753 = !r527752;
        bool r527754 = r527750 || r527753;
        double r527755 = 1.0;
        double r527756 = y;
        double r527757 = t;
        double r527758 = r527756 - r527757;
        double r527759 = 2.0;
        double r527760 = r527758 / r527759;
        double r527761 = r527748 / r527760;
        double r527762 = z;
        double r527763 = r527761 / r527762;
        double r527764 = r527755 * r527763;
        double r527765 = r527748 / r527762;
        double r527766 = r527765 / r527760;
        double r527767 = r527754 ? r527764 : r527766;
        return r527767;
}

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.2
Target2.2
Herbie2.2
\[\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 < -5.626078049724568e+34 or 3.4734749516865268e-84 < x

    1. Initial program 10.7

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity9.8

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac2.6

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{1}} \cdot \frac{x}{\frac{y - t}{2}}}\]
    8. Simplified2.6

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity2.6

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

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

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

    if -5.626078049724568e+34 < x < 3.4734749516865268e-84

    1. Initial program 3.6

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.6260780497245676 \cdot 10^{34} \lor \neg \left(x \le 3.47347495168652677 \cdot 10^{-84}\right):\\ \;\;\;\;1 \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020064 +o rules:numerics
(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))))