Average Error: 7.1 → 2.2
Time: 6.8s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1133642082614431.25 \lor \neg \left(z \le 2713.6534281564946\right):\\ \;\;\;\;\frac{x}{z} \cdot \frac{1}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -1133642082614431.25 \lor \neg \left(z \le 2713.6534281564946\right):\\
\;\;\;\;\frac{x}{z} \cdot \frac{1}{\frac{y - t}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r507135 = x;
        double r507136 = 2.0;
        double r507137 = r507135 * r507136;
        double r507138 = y;
        double r507139 = z;
        double r507140 = r507138 * r507139;
        double r507141 = t;
        double r507142 = r507141 * r507139;
        double r507143 = r507140 - r507142;
        double r507144 = r507137 / r507143;
        return r507144;
}

double f(double x, double y, double z, double t) {
        double r507145 = z;
        double r507146 = -1133642082614431.2;
        bool r507147 = r507145 <= r507146;
        double r507148 = 2713.6534281564946;
        bool r507149 = r507145 <= r507148;
        double r507150 = !r507149;
        bool r507151 = r507147 || r507150;
        double r507152 = x;
        double r507153 = r507152 / r507145;
        double r507154 = 1.0;
        double r507155 = y;
        double r507156 = t;
        double r507157 = r507155 - r507156;
        double r507158 = 2.0;
        double r507159 = r507157 / r507158;
        double r507160 = r507154 / r507159;
        double r507161 = r507153 * r507160;
        double r507162 = r507145 * r507157;
        double r507163 = r507162 / r507158;
        double r507164 = r507152 / r507163;
        double r507165 = r507151 ? r507161 : r507164;
        return r507165;
}

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.3
Herbie2.2
\[\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 z < -1133642082614431.2 or 2713.6534281564946 < z

    1. Initial program 11.3

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{y - t}{2}}\]
    8. Using strategy rm
    9. Applied div-inv2.1

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

    if -1133642082614431.2 < z < 2713.6534281564946

    1. Initial program 2.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1133642082614431.25 \lor \neg \left(z \le 2713.6534281564946\right):\\ \;\;\;\;\frac{x}{z} \cdot \frac{1}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array}\]

Reproduce

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