Average Error: 6.7 → 3.0
Time: 6.9s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.646136584525686015243781694282027335309 \cdot 10^{138} \lor \neg \left(z \le 8.697575599925424886021160018753896601857 \cdot 10^{81}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -5.646136584525686015243781694282027335309 \cdot 10^{138} \lor \neg \left(z \le 8.697575599925424886021160018753896601857 \cdot 10^{81}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r425810 = x;
        double r425811 = 2.0;
        double r425812 = r425810 * r425811;
        double r425813 = y;
        double r425814 = z;
        double r425815 = r425813 * r425814;
        double r425816 = t;
        double r425817 = r425816 * r425814;
        double r425818 = r425815 - r425817;
        double r425819 = r425812 / r425818;
        return r425819;
}

double f(double x, double y, double z, double t) {
        double r425820 = z;
        double r425821 = -5.646136584525686e+138;
        bool r425822 = r425820 <= r425821;
        double r425823 = 8.697575599925425e+81;
        bool r425824 = r425820 <= r425823;
        double r425825 = !r425824;
        bool r425826 = r425822 || r425825;
        double r425827 = x;
        double r425828 = 2.0;
        double r425829 = r425827 * r425828;
        double r425830 = r425829 / r425820;
        double r425831 = y;
        double r425832 = t;
        double r425833 = r425831 - r425832;
        double r425834 = r425830 / r425833;
        double r425835 = r425820 * r425833;
        double r425836 = r425829 / r425835;
        double r425837 = r425826 ? r425834 : r425836;
        return r425837;
}

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.7
Target2.2
Herbie3.0
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \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.045027827330125861587720199944080049996 \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 z < -5.646136584525686e+138 or 8.697575599925425e+81 < z

    1. Initial program 13.3

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

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

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

    if -5.646136584525686e+138 < z < 8.697575599925425e+81

    1. Initial program 3.3

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

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

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

Reproduce

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