Average Error: 6.9 → 4.2
Time: 22.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le 4.973589732317052276576615101673609471705 \cdot 10^{83}:\\ \;\;\;\;\frac{\frac{2}{z} \cdot x}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le 4.973589732317052276576615101673609471705 \cdot 10^{83}:\\
\;\;\;\;\frac{\frac{2}{z} \cdot x}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r27676803 = x;
        double r27676804 = 2.0;
        double r27676805 = r27676803 * r27676804;
        double r27676806 = y;
        double r27676807 = z;
        double r27676808 = r27676806 * r27676807;
        double r27676809 = t;
        double r27676810 = r27676809 * r27676807;
        double r27676811 = r27676808 - r27676810;
        double r27676812 = r27676805 / r27676811;
        return r27676812;
}

double f(double x, double y, double z, double t) {
        double r27676813 = x;
        double r27676814 = 4.973589732317052e+83;
        bool r27676815 = r27676813 <= r27676814;
        double r27676816 = 2.0;
        double r27676817 = z;
        double r27676818 = r27676816 / r27676817;
        double r27676819 = r27676818 * r27676813;
        double r27676820 = y;
        double r27676821 = t;
        double r27676822 = r27676820 - r27676821;
        double r27676823 = r27676819 / r27676822;
        double r27676824 = r27676822 / r27676813;
        double r27676825 = r27676818 / r27676824;
        double r27676826 = r27676815 ? r27676823 : r27676825;
        return r27676826;
}

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.3
Herbie4.2
\[\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.045027827330126029709547581125571222799 \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 < 4.973589732317052e+83

    1. Initial program 5.5

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\frac{z}{x}}}{y - t}}\]
    3. Using strategy rm
    4. Applied associate-/r/4.3

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

    if 4.973589732317052e+83 < x

    1. Initial program 13.7

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\frac{z}{x}}}{y - t}}\]
    3. Using strategy rm
    4. Applied associate-/r/12.9

      \[\leadsto \frac{\color{blue}{\frac{2}{z} \cdot x}}{y - t}\]
    5. Applied associate-/l*3.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 4.973589732317052276576615101673609471705 \cdot 10^{83}:\\ \;\;\;\;\frac{\frac{2}{z} \cdot x}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{z}}{\frac{y - t}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

  (/ (* x 2.0) (- (* y z) (* t z))))