Average Error: 7.0 → 2.6
Time: 34.9s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.4355961856746975 \cdot 10^{+39}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{2.0}{y - t} \cdot x\right)\\ \mathbf{elif}\;z \le 1.8536896221863033 \cdot 10^{-126}:\\ \;\;\;\;\frac{x \cdot 2.0}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{2.0}{y - t} \cdot x\right)\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -5.4355961856746975 \cdot 10^{+39}:\\
\;\;\;\;\frac{1}{z} \cdot \left(\frac{2.0}{y - t} \cdot x\right)\\

\mathbf{elif}\;z \le 1.8536896221863033 \cdot 10^{-126}:\\
\;\;\;\;\frac{x \cdot 2.0}{z \cdot \left(y - t\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r26762819 = x;
        double r26762820 = 2.0;
        double r26762821 = r26762819 * r26762820;
        double r26762822 = y;
        double r26762823 = z;
        double r26762824 = r26762822 * r26762823;
        double r26762825 = t;
        double r26762826 = r26762825 * r26762823;
        double r26762827 = r26762824 - r26762826;
        double r26762828 = r26762821 / r26762827;
        return r26762828;
}

double f(double x, double y, double z, double t) {
        double r26762829 = z;
        double r26762830 = -5.4355961856746975e+39;
        bool r26762831 = r26762829 <= r26762830;
        double r26762832 = 1.0;
        double r26762833 = r26762832 / r26762829;
        double r26762834 = 2.0;
        double r26762835 = y;
        double r26762836 = t;
        double r26762837 = r26762835 - r26762836;
        double r26762838 = r26762834 / r26762837;
        double r26762839 = x;
        double r26762840 = r26762838 * r26762839;
        double r26762841 = r26762833 * r26762840;
        double r26762842 = 1.8536896221863033e-126;
        bool r26762843 = r26762829 <= r26762842;
        double r26762844 = r26762839 * r26762834;
        double r26762845 = r26762829 * r26762837;
        double r26762846 = r26762844 / r26762845;
        double r26762847 = r26762843 ? r26762846 : r26762841;
        double r26762848 = r26762831 ? r26762841 : r26762847;
        return r26762848;
}

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.0
Target2.0
Herbie2.6
\[\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.4355961856746975e+39 or 1.8536896221863033e-126 < z

    1. Initial program 9.8

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

      \[\leadsto \color{blue}{\frac{2.0}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied div-inv2.7

      \[\leadsto \frac{2.0}{y - t} \cdot \color{blue}{\left(x \cdot \frac{1}{z}\right)}\]
    5. Applied associate-*r*2.6

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

    if -5.4355961856746975e+39 < z < 1.8536896221863033e-126

    1. Initial program 2.5

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Simplified11.8

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

      \[\leadsto \color{blue}{\frac{\frac{2.0}{y - t} \cdot x}{z}}\]
    5. Using strategy rm
    6. Applied associate-*l/10.3

      \[\leadsto \frac{\color{blue}{\frac{2.0 \cdot x}{y - t}}}{z}\]
    7. Applied associate-/l/2.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.4355961856746975 \cdot 10^{+39}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{2.0}{y - t} \cdot x\right)\\ \mathbf{elif}\;z \le 1.8536896221863033 \cdot 10^{-126}:\\ \;\;\;\;\frac{x \cdot 2.0}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{2.0}{y - t} \cdot x\right)\\ \end{array}\]

Reproduce

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