Average Error: 6.7 → 3.6
Time: 6.4s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le 3.04308694177459833 \cdot 10^{-224}:\\ \;\;\;\;\left(x \cdot \left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right)\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{\sqrt{\frac{1}{z}}}{\frac{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}{\sqrt{2}}}\right) \cdot \frac{\sqrt{\frac{1}{z}}}{\frac{\sqrt[3]{y - t}}{\sqrt{2}}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le 3.04308694177459833 \cdot 10^{-224}:\\
\;\;\;\;\left(x \cdot \left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right)\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{\frac{y - t}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r159494 = x;
        double r159495 = 2.0;
        double r159496 = r159494 * r159495;
        double r159497 = y;
        double r159498 = z;
        double r159499 = r159497 * r159498;
        double r159500 = t;
        double r159501 = r159500 * r159498;
        double r159502 = r159499 - r159501;
        double r159503 = r159496 / r159502;
        return r159503;
}

double f(double x, double y, double z, double t) {
        double r159504 = z;
        double r159505 = 3.0430869417745983e-224;
        bool r159506 = r159504 <= r159505;
        double r159507 = x;
        double r159508 = 1.0;
        double r159509 = r159508 / r159504;
        double r159510 = cbrt(r159509);
        double r159511 = r159510 * r159510;
        double r159512 = r159507 * r159511;
        double r159513 = y;
        double r159514 = t;
        double r159515 = r159513 - r159514;
        double r159516 = 2.0;
        double r159517 = r159515 / r159516;
        double r159518 = r159510 / r159517;
        double r159519 = r159512 * r159518;
        double r159520 = sqrt(r159509);
        double r159521 = cbrt(r159515);
        double r159522 = r159521 * r159521;
        double r159523 = sqrt(r159516);
        double r159524 = r159522 / r159523;
        double r159525 = r159520 / r159524;
        double r159526 = r159507 * r159525;
        double r159527 = r159521 / r159523;
        double r159528 = r159520 / r159527;
        double r159529 = r159526 * r159528;
        double r159530 = r159506 ? r159519 : r159529;
        return r159530;
}

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.7
Target2.0
Herbie3.6
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061 \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.04502782733012586 \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 < 3.0430869417745983e-224

    1. Initial program 6.6

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{y - t}{2}}}\]
    6. Using strategy rm
    7. Applied div-inv5.7

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

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

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

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

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

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

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

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

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

    if 3.0430869417745983e-224 < z

    1. Initial program 6.9

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

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

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

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{y - t}{2}}}\]
    6. Using strategy rm
    7. Applied div-inv5.9

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

      \[\leadsto x \cdot \color{blue}{\frac{\frac{1}{z}}{\frac{y - t}{2}}}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt6.0

      \[\leadsto x \cdot \frac{\frac{1}{z}}{\frac{y - t}{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}}\]
    12. Applied add-cube-cbrt6.2

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

      \[\leadsto x \cdot \frac{\frac{1}{z}}{\color{blue}{\frac{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}{\sqrt{2}} \cdot \frac{\sqrt[3]{y - t}}{\sqrt{2}}}}\]
    14. Applied add-sqr-sqrt6.2

      \[\leadsto x \cdot \frac{\color{blue}{\sqrt{\frac{1}{z}} \cdot \sqrt{\frac{1}{z}}}}{\frac{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}{\sqrt{2}} \cdot \frac{\sqrt[3]{y - t}}{\sqrt{2}}}\]
    15. Applied times-frac6.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 3.04308694177459833 \cdot 10^{-224}:\\ \;\;\;\;\left(x \cdot \left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right)\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{\sqrt{\frac{1}{z}}}{\frac{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}{\sqrt{2}}}\right) \cdot \frac{\sqrt{\frac{1}{z}}}{\frac{\sqrt[3]{y - t}}{\sqrt{2}}}\\ \end{array}\]

Reproduce

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