Average Error: 7.1 → 2.5
Time: 16.9s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.4437892270302555 \cdot 10^{+63}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \mathbf{elif}\;x \le 2.662792445968159 \cdot 10^{-130}:\\ \;\;\;\;\frac{2.0 \cdot \frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -6.4437892270302555 \cdot 10^{+63}:\\
\;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\

\mathbf{elif}\;x \le 2.662792445968159 \cdot 10^{-130}:\\
\;\;\;\;\frac{2.0 \cdot \frac{x}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r23614371 = x;
        double r23614372 = 2.0;
        double r23614373 = r23614371 * r23614372;
        double r23614374 = y;
        double r23614375 = z;
        double r23614376 = r23614374 * r23614375;
        double r23614377 = t;
        double r23614378 = r23614377 * r23614375;
        double r23614379 = r23614376 - r23614378;
        double r23614380 = r23614373 / r23614379;
        return r23614380;
}

double f(double x, double y, double z, double t) {
        double r23614381 = x;
        double r23614382 = -6.4437892270302555e+63;
        bool r23614383 = r23614381 <= r23614382;
        double r23614384 = 2.0;
        double r23614385 = y;
        double r23614386 = t;
        double r23614387 = r23614385 - r23614386;
        double r23614388 = r23614381 / r23614387;
        double r23614389 = z;
        double r23614390 = r23614388 / r23614389;
        double r23614391 = r23614384 * r23614390;
        double r23614392 = 2.662792445968159e-130;
        bool r23614393 = r23614381 <= r23614392;
        double r23614394 = r23614381 / r23614389;
        double r23614395 = r23614384 * r23614394;
        double r23614396 = r23614395 / r23614387;
        double r23614397 = r23614393 ? r23614396 : r23614391;
        double r23614398 = r23614383 ? r23614391 : r23614397;
        return r23614398;
}

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.1
Herbie2.5
\[\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 x < -6.4437892270302555e+63 or 2.662792445968159e-130 < x

    1. Initial program 10.1

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

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

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

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

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

    if -6.4437892270302555e+63 < x < 2.662792445968159e-130

    1. Initial program 3.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.4437892270302555 \cdot 10^{+63}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \mathbf{elif}\;x \le 2.662792445968159 \cdot 10^{-130}:\\ \;\;\;\;\frac{2.0 \cdot \frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \frac{\frac{x}{y - t}}{z}\\ \end{array}\]

Reproduce

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