Average Error: 7.0 → 3.4
Time: 5.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.854073483132409627892280748735859896789 \cdot 10^{-80} \lor \neg \left(x \le 4.280064491975717546527013185442469963537 \cdot 10^{-221}\right):\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{x}{z \cdot \frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -2.854073483132409627892280748735859896789 \cdot 10^{-80} \lor \neg \left(x \le 4.280064491975717546527013185442469963537 \cdot 10^{-221}\right):\\
\;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r653458 = x;
        double r653459 = 2.0;
        double r653460 = r653458 * r653459;
        double r653461 = y;
        double r653462 = z;
        double r653463 = r653461 * r653462;
        double r653464 = t;
        double r653465 = r653464 * r653462;
        double r653466 = r653463 - r653465;
        double r653467 = r653460 / r653466;
        return r653467;
}

double f(double x, double y, double z, double t) {
        double r653468 = x;
        double r653469 = -2.8540734831324096e-80;
        bool r653470 = r653468 <= r653469;
        double r653471 = 4.2800644919757175e-221;
        bool r653472 = r653468 <= r653471;
        double r653473 = !r653472;
        bool r653474 = r653470 || r653473;
        double r653475 = 1.0;
        double r653476 = sqrt(r653475);
        double r653477 = r653476 / r653475;
        double r653478 = y;
        double r653479 = t;
        double r653480 = r653478 - r653479;
        double r653481 = 2.0;
        double r653482 = r653480 / r653481;
        double r653483 = r653468 / r653482;
        double r653484 = z;
        double r653485 = r653483 / r653484;
        double r653486 = r653477 * r653485;
        double r653487 = r653484 * r653482;
        double r653488 = r653468 / r653487;
        double r653489 = r653477 * r653488;
        double r653490 = r653474 ? r653486 : r653489;
        return r653490;
}

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.2
Herbie3.4
\[\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.045027827330125861587720199944080049996 \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 < -2.8540734831324096e-80 or 4.2800644919757175e-221 < x

    1. Initial program 8.3

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    11. Applied add-sqr-sqrt3.9

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

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

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

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

    if -2.8540734831324096e-80 < x < 4.2800644919757175e-221

    1. Initial program 3.5

      \[\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. Using strategy rm
    4. Applied *-un-lft-identity2.2

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    11. Applied add-sqr-sqrt9.9

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

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

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

      \[\leadsto \frac{\sqrt{1}}{1} \cdot \color{blue}{\frac{\frac{x}{\frac{y - t}{2}}}{z}}\]
    15. Using strategy rm
    16. Applied div-inv9.9

      \[\leadsto \frac{\sqrt{1}}{1} \cdot \frac{\color{blue}{x \cdot \frac{1}{\frac{y - t}{2}}}}{z}\]
    17. Applied associate-/l*2.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.854073483132409627892280748735859896789 \cdot 10^{-80} \lor \neg \left(x \le 4.280064491975717546527013185442469963537 \cdot 10^{-221}\right):\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{x}{z \cdot \frac{y - t}{2}}\\ \end{array}\]

Reproduce

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