Average Error: 7.0 → 3.4
Time: 4.9s
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[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{1} \cdot \sqrt[3]{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[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r531095 = x;
        double r531096 = 2.0;
        double r531097 = r531095 * r531096;
        double r531098 = y;
        double r531099 = z;
        double r531100 = r531098 * r531099;
        double r531101 = t;
        double r531102 = r531101 * r531099;
        double r531103 = r531100 - r531102;
        double r531104 = r531097 / r531103;
        return r531104;
}

double f(double x, double y, double z, double t) {
        double r531105 = x;
        double r531106 = -2.8540734831324096e-80;
        bool r531107 = r531105 <= r531106;
        double r531108 = 4.2800644919757175e-221;
        bool r531109 = r531105 <= r531108;
        double r531110 = !r531109;
        bool r531111 = r531107 || r531110;
        double r531112 = 1.0;
        double r531113 = cbrt(r531112);
        double r531114 = r531113 * r531113;
        double r531115 = r531114 / r531112;
        double r531116 = y;
        double r531117 = t;
        double r531118 = r531116 - r531117;
        double r531119 = 2.0;
        double r531120 = r531118 / r531119;
        double r531121 = r531105 / r531120;
        double r531122 = z;
        double r531123 = r531121 / r531122;
        double r531124 = r531115 * r531123;
        double r531125 = r531122 * r531120;
        double r531126 = r531105 / r531125;
        double r531127 = r531115 * r531126;
        double r531128 = r531111 ? r531124 : r531127;
        return r531128;
}

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-cube-cbrt3.9

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

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

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

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{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-cube-cbrt9.9

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

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

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

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{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[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\color{blue}{x \cdot \frac{1}{\frac{y - t}{2}}}}{z}\]
    17. Applied associate-/l*2.3

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

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{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[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{x}{z \cdot \frac{y - t}{2}}\\ \end{array}\]

Reproduce

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