Average Error: 6.9 → 2.4
Time: 10.5s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.302276795464792958697075142375509937409 \cdot 10^{-8} \lor \neg \left(z \le 6.74946915654484623003503662072569973222 \cdot 10^{-38}\right):\\ \;\;\;\;\frac{1}{\frac{y - t}{x \cdot 2}} \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot y + \left(-t \cdot z\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -2.302276795464792958697075142375509937409 \cdot 10^{-8} \lor \neg \left(z \le 6.74946915654484623003503662072569973222 \cdot 10^{-38}\right):\\
\;\;\;\;\frac{1}{\frac{y - t}{x \cdot 2}} \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r553604 = x;
        double r553605 = 2.0;
        double r553606 = r553604 * r553605;
        double r553607 = y;
        double r553608 = z;
        double r553609 = r553607 * r553608;
        double r553610 = t;
        double r553611 = r553610 * r553608;
        double r553612 = r553609 - r553611;
        double r553613 = r553606 / r553612;
        return r553613;
}

double f(double x, double y, double z, double t) {
        double r553614 = z;
        double r553615 = -2.302276795464793e-08;
        bool r553616 = r553614 <= r553615;
        double r553617 = 6.749469156544846e-38;
        bool r553618 = r553614 <= r553617;
        double r553619 = !r553618;
        bool r553620 = r553616 || r553619;
        double r553621 = 1.0;
        double r553622 = y;
        double r553623 = t;
        double r553624 = r553622 - r553623;
        double r553625 = x;
        double r553626 = 2.0;
        double r553627 = r553625 * r553626;
        double r553628 = r553624 / r553627;
        double r553629 = r553621 / r553628;
        double r553630 = r553621 / r553614;
        double r553631 = r553629 * r553630;
        double r553632 = r553614 * r553622;
        double r553633 = r553623 * r553614;
        double r553634 = -r553633;
        double r553635 = r553632 + r553634;
        double r553636 = r553627 / r553635;
        double r553637 = r553620 ? r553631 : r553636;
        return r553637;
}

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.1
Herbie2.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.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 z < -2.302276795464793e-08 or 6.749469156544846e-38 < z

    1. Initial program 10.2

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

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

      \[\leadsto \color{blue}{\frac{\frac{x \cdot 2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied clear-num2.2

      \[\leadsto \color{blue}{\frac{1}{\frac{y - t}{\frac{x \cdot 2}{z}}}}\]
    7. Using strategy rm
    8. Applied associate-/r/2.5

      \[\leadsto \frac{1}{\color{blue}{\frac{y - t}{x \cdot 2} \cdot z}}\]
    9. Applied add-cube-cbrt2.5

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

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

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

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

    if -2.302276795464793e-08 < z < 6.749469156544846e-38

    1. Initial program 2.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied sub-neg2.5

      \[\leadsto \frac{x \cdot 2}{z \cdot \color{blue}{\left(y + \left(-t\right)\right)}}\]
    5. Applied distribute-lft-in2.5

      \[\leadsto \frac{x \cdot 2}{\color{blue}{z \cdot y + z \cdot \left(-t\right)}}\]
    6. Simplified2.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.302276795464792958697075142375509937409 \cdot 10^{-8} \lor \neg \left(z \le 6.74946915654484623003503662072569973222 \cdot 10^{-38}\right):\\ \;\;\;\;\frac{1}{\frac{y - t}{x \cdot 2}} \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot y + \left(-t \cdot z\right)}\\ \end{array}\]

Reproduce

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

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