Average Error: 7.1 → 0.4
Time: 4.9s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le -1.1621051041344287 \cdot 10^{-259} \lor \neg \left(y \cdot z - t \cdot z \le 5.0899252137800039 \cdot 10^{-179} \lor \neg \left(y \cdot z - t \cdot z \le 1.7881153538091119 \cdot 10^{170}\right)\right)\right):\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le -1.1621051041344287 \cdot 10^{-259} \lor \neg \left(y \cdot z - t \cdot z \le 5.0899252137800039 \cdot 10^{-179} \lor \neg \left(y \cdot z - t \cdot z \le 1.7881153538091119 \cdot 10^{170}\right)\right)\right):\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r1072162 = x;
        double r1072163 = 2.0;
        double r1072164 = r1072162 * r1072163;
        double r1072165 = y;
        double r1072166 = z;
        double r1072167 = r1072165 * r1072166;
        double r1072168 = t;
        double r1072169 = r1072168 * r1072166;
        double r1072170 = r1072167 - r1072169;
        double r1072171 = r1072164 / r1072170;
        return r1072171;
}

double f(double x, double y, double z, double t) {
        double r1072172 = y;
        double r1072173 = z;
        double r1072174 = r1072172 * r1072173;
        double r1072175 = t;
        double r1072176 = r1072175 * r1072173;
        double r1072177 = r1072174 - r1072176;
        double r1072178 = -inf.0;
        bool r1072179 = r1072177 <= r1072178;
        double r1072180 = -1.1621051041344287e-259;
        bool r1072181 = r1072177 <= r1072180;
        double r1072182 = 5.089925213780004e-179;
        bool r1072183 = r1072177 <= r1072182;
        double r1072184 = 1.788115353809112e+170;
        bool r1072185 = r1072177 <= r1072184;
        double r1072186 = !r1072185;
        bool r1072187 = r1072183 || r1072186;
        double r1072188 = !r1072187;
        bool r1072189 = r1072181 || r1072188;
        double r1072190 = !r1072189;
        bool r1072191 = r1072179 || r1072190;
        double r1072192 = x;
        double r1072193 = r1072192 / r1072173;
        double r1072194 = r1072172 - r1072175;
        double r1072195 = 2.0;
        double r1072196 = r1072194 / r1072195;
        double r1072197 = r1072193 / r1072196;
        double r1072198 = r1072192 * r1072195;
        double r1072199 = r1072198 / r1072177;
        double r1072200 = r1072191 ? r1072197 : r1072199;
        return r1072200;
}

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.1
Target2.2
Herbie0.4
\[\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 (- (* y z) (* t z)) < -inf.0 or -1.1621051041344287e-259 < (- (* y z) (* t z)) < 5.089925213780004e-179 or 1.788115353809112e+170 < (- (* y z) (* t z))

    1. Initial program 17.8

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

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

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

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

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

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

    if -inf.0 < (- (* y z) (* t z)) < -1.1621051041344287e-259 or 5.089925213780004e-179 < (- (* y z) (* t z)) < 1.788115353809112e+170

    1. Initial program 0.3

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le -1.1621051041344287 \cdot 10^{-259} \lor \neg \left(y \cdot z - t \cdot z \le 5.0899252137800039 \cdot 10^{-179} \lor \neg \left(y \cdot z - t \cdot z \le 1.7881153538091119 \cdot 10^{170}\right)\right)\right):\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

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