Average Error: 6.6 → 2.3
Time: 12.2s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -35148661089821.66015625 \lor \neg \left(z \le 3.818366843617034597316373479678641130316 \cdot 10^{83}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -35148661089821.66015625 \lor \neg \left(z \le 3.818366843617034597316373479678641130316 \cdot 10^{83}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r377530 = x;
        double r377531 = 2.0;
        double r377532 = r377530 * r377531;
        double r377533 = y;
        double r377534 = z;
        double r377535 = r377533 * r377534;
        double r377536 = t;
        double r377537 = r377536 * r377534;
        double r377538 = r377535 - r377537;
        double r377539 = r377532 / r377538;
        return r377539;
}

double f(double x, double y, double z, double t) {
        double r377540 = z;
        double r377541 = -35148661089821.66;
        bool r377542 = r377540 <= r377541;
        double r377543 = 3.8183668436170346e+83;
        bool r377544 = r377540 <= r377543;
        double r377545 = !r377544;
        bool r377546 = r377542 || r377545;
        double r377547 = x;
        double r377548 = 2.0;
        double r377549 = r377547 * r377548;
        double r377550 = y;
        double r377551 = t;
        double r377552 = r377550 - r377551;
        double r377553 = r377549 / r377552;
        double r377554 = r377553 / r377540;
        double r377555 = r377540 * r377552;
        double r377556 = r377549 / r377555;
        double r377557 = r377546 ? r377554 : r377556;
        return r377557;
}

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.6
Target2.2
Herbie2.3
\[\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 < -35148661089821.66 or 3.8183668436170346e+83 < z

    1. Initial program 11.7

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt9.5

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied pow18.9

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{{\left(\frac{1}{y - t}\right)}^{1}}\right)\]
    12. Applied pow18.9

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\color{blue}{{\left(\frac{1}{z}\right)}^{1}} \cdot {\left(\frac{1}{y - t}\right)}^{1}\right)\]
    13. Applied pow-prod-down8.9

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

      \[\leadsto \left(x \cdot \color{blue}{{2}^{1}}\right) \cdot {\left(\frac{1}{z} \cdot \frac{1}{y - t}\right)}^{1}\]
    15. Applied pow18.9

      \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {2}^{1}\right) \cdot {\left(\frac{1}{z} \cdot \frac{1}{y - t}\right)}^{1}\]
    16. Applied pow-prod-down8.9

      \[\leadsto \color{blue}{{\left(x \cdot 2\right)}^{1}} \cdot {\left(\frac{1}{z} \cdot \frac{1}{y - t}\right)}^{1}\]
    17. Applied pow-prod-down8.9

      \[\leadsto \color{blue}{{\left(\left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \frac{1}{y - t}\right)\right)}^{1}}\]
    18. Simplified2.2

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

    if -35148661089821.66 < z < 3.8183668436170346e+83

    1. Initial program 2.3

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt2.7

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied frac-times2.7

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\frac{1 \cdot 1}{z \cdot \left(y - t\right)}}\]
    12. Applied associate-*r/2.3

      \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot \left(1 \cdot 1\right)}{z \cdot \left(y - t\right)}}\]
    13. Simplified2.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -35148661089821.66015625 \lor \neg \left(z \le 3.818366843617034597316373479678641130316 \cdot 10^{83}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]

Reproduce

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