Average Error: 6.9 → 5.7
Time: 6.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\frac{\frac{x}{\frac{y - t}{2}}}{z}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\frac{\frac{x}{\frac{y - t}{2}}}{z}
double f(double x, double y, double z, double t) {
        double r422324 = x;
        double r422325 = 2.0;
        double r422326 = r422324 * r422325;
        double r422327 = y;
        double r422328 = z;
        double r422329 = r422327 * r422328;
        double r422330 = t;
        double r422331 = r422330 * r422328;
        double r422332 = r422329 - r422331;
        double r422333 = r422326 / r422332;
        return r422333;
}

double f(double x, double y, double z, double t) {
        double r422334 = x;
        double r422335 = y;
        double r422336 = t;
        double r422337 = r422335 - r422336;
        double r422338 = 2.0;
        double r422339 = r422337 / r422338;
        double r422340 = r422334 / r422339;
        double r422341 = z;
        double r422342 = r422340 / r422341;
        return r422342;
}

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.9
Target2.2
Herbie5.7
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \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.045027827330126029709547581125571222799 \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 x < -1.0086536878019123e+59 or 6.8034908568658585e+65 < x

    1. Initial program 12.8

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity12.1

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac3.8

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

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity3.8

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    11. Applied *-un-lft-identity3.8

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{1 \cdot z} \cdot \frac{x}{\frac{y - t}{2}}\]
    12. Applied times-frac3.8

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

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

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

    if -1.0086536878019123e+59 < x < 6.8034908568658585e+65

    1. Initial program 3.6

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

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

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

Reproduce

herbie shell --seed 2019308 
(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.045027827330126e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

  (/ (* x 2) (- (* y z) (* t z))))