Average Error: 6.8 → 2.5
Time: 6.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.9425230437440893 \cdot 10^{45}:\\ \;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\ \mathbf{elif}\;z \le 3.0712348216511889 \cdot 10^{72}:\\ \;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -3.9425230437440893 \cdot 10^{45}:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\

\mathbf{elif}\;z \le 3.0712348216511889 \cdot 10^{72}:\\
\;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r228673 = x;
        double r228674 = 2.0;
        double r228675 = r228673 * r228674;
        double r228676 = y;
        double r228677 = z;
        double r228678 = r228676 * r228677;
        double r228679 = t;
        double r228680 = r228679 * r228677;
        double r228681 = r228678 - r228680;
        double r228682 = r228675 / r228681;
        return r228682;
}

double f(double x, double y, double z, double t) {
        double r228683 = z;
        double r228684 = -3.942523043744089e+45;
        bool r228685 = r228683 <= r228684;
        double r228686 = x;
        double r228687 = y;
        double r228688 = t;
        double r228689 = r228687 - r228688;
        double r228690 = r228686 / r228689;
        double r228691 = 2.0;
        double r228692 = r228691 / r228683;
        double r228693 = r228690 * r228692;
        double r228694 = 3.071234821651189e+72;
        bool r228695 = r228683 <= r228694;
        double r228696 = r228686 * r228691;
        double r228697 = r228689 * r228683;
        double r228698 = r228696 / r228697;
        double r228699 = r228686 / r228683;
        double r228700 = r228691 / r228689;
        double r228701 = r228699 * r228700;
        double r228702 = r228695 ? r228698 : r228701;
        double r228703 = r228685 ? r228693 : r228702;
        return r228703;
}

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.8
Target2.2
Herbie2.5
\[\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 3 regimes
  2. if z < -3.942523043744089e+45

    1. Initial program 11.7

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

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

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(y - t\right) \cdot z}}\]
    5. Using strategy rm
    6. Applied times-frac2.2

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

    if -3.942523043744089e+45 < z < 3.071234821651189e+72

    1. Initial program 2.7

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

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

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

    if 3.071234821651189e+72 < z

    1. Initial program 12.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.9425230437440893 \cdot 10^{45}:\\ \;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\ \mathbf{elif}\;z \le 3.0712348216511889 \cdot 10^{72}:\\ \;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]

Reproduce

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