Average Error: 6.6 → 3.9
Time: 18.1s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.956108709657717 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{2.0}{z}}{\frac{y - t}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{\frac{2.0}{y - t}}}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -5.956108709657717 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{2.0}{z}}{\frac{y - t}{x}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r40475989 = x;
        double r40475990 = 2.0;
        double r40475991 = r40475989 * r40475990;
        double r40475992 = y;
        double r40475993 = z;
        double r40475994 = r40475992 * r40475993;
        double r40475995 = t;
        double r40475996 = r40475995 * r40475993;
        double r40475997 = r40475994 - r40475996;
        double r40475998 = r40475991 / r40475997;
        return r40475998;
}

double f(double x, double y, double z, double t) {
        double r40475999 = z;
        double r40476000 = -5.956108709657717e+41;
        bool r40476001 = r40475999 <= r40476000;
        double r40476002 = 2.0;
        double r40476003 = r40476002 / r40475999;
        double r40476004 = y;
        double r40476005 = t;
        double r40476006 = r40476004 - r40476005;
        double r40476007 = x;
        double r40476008 = r40476006 / r40476007;
        double r40476009 = r40476003 / r40476008;
        double r40476010 = r40476002 / r40476006;
        double r40476011 = r40475999 / r40476010;
        double r40476012 = r40476007 / r40476011;
        double r40476013 = r40476001 ? r40476009 : r40476012;
        return r40476013;
}

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.6
Target2.2
Herbie3.9
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \mathbf{elif}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt 1.045027827330126 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2.0}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -5.956108709657717e+41

    1. Initial program 11.6

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied *-commutative11.6

      \[\leadsto \frac{x \cdot 2.0}{y \cdot z - \color{blue}{z \cdot t}}\]
    4. Applied *-commutative11.6

      \[\leadsto \frac{x \cdot 2.0}{\color{blue}{z \cdot y} - z \cdot t}\]
    5. Applied distribute-lft-out--9.3

      \[\leadsto \frac{x \cdot 2.0}{\color{blue}{z \cdot \left(y - t\right)}}\]
    6. Using strategy rm
    7. Applied *-commutative9.3

      \[\leadsto \frac{\color{blue}{2.0 \cdot x}}{z \cdot \left(y - t\right)}\]
    8. Applied associate-/l*9.7

      \[\leadsto \color{blue}{\frac{2.0}{\frac{z \cdot \left(y - t\right)}{x}}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity9.7

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

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

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

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

    if -5.956108709657717e+41 < z

    1. Initial program 5.1

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied associate-/l*5.1

      \[\leadsto \color{blue}{\frac{x}{\frac{y \cdot z - t \cdot z}{2.0}}}\]
    4. Simplified4.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.956108709657717 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{2.0}{z}}{\frac{y - t}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{\frac{2.0}{y - t}}}\\ \end{array}\]

Reproduce

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