Average Error: 6.9 → 2.6
Time: 5.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.7670119028815515 \cdot 10^{96} \lor \neg \left(x \le 1.0269027638925969 \cdot 10^{-67}\right):\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -1.7670119028815515 \cdot 10^{96} \lor \neg \left(x \le 1.0269027638925969 \cdot 10^{-67}\right):\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r496815 = x;
        double r496816 = 2.0;
        double r496817 = r496815 * r496816;
        double r496818 = y;
        double r496819 = z;
        double r496820 = r496818 * r496819;
        double r496821 = t;
        double r496822 = r496821 * r496819;
        double r496823 = r496820 - r496822;
        double r496824 = r496817 / r496823;
        return r496824;
}

double f(double x, double y, double z, double t) {
        double r496825 = x;
        double r496826 = -1.7670119028815515e+96;
        bool r496827 = r496825 <= r496826;
        double r496828 = 1.0269027638925969e-67;
        bool r496829 = r496825 <= r496828;
        double r496830 = !r496829;
        bool r496831 = r496827 || r496830;
        double r496832 = 2.0;
        double r496833 = y;
        double r496834 = t;
        double r496835 = r496833 - r496834;
        double r496836 = r496832 / r496835;
        double r496837 = r496825 * r496836;
        double r496838 = z;
        double r496839 = r496837 / r496838;
        double r496840 = r496838 * r496835;
        double r496841 = r496840 / r496832;
        double r496842 = r496825 / r496841;
        double r496843 = r496831 ? r496839 : r496842;
        return r496843;
}

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.9
Target2.1
Herbie2.6
\[\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.7670119028815515e+96 or 1.0269027638925969e-67 < x

    1. Initial program 11.0

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

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

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

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

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

    if -1.7670119028815515e+96 < x < 1.0269027638925969e-67

    1. Initial program 3.8

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

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

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

Reproduce

herbie shell --seed 2020033 +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))))