Average Error: 7.1 → 5.5
Time: 4.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.29685778425398707 \cdot 10^{-184}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \le 2.5639366194123703 \cdot 10^{-127}:\\ \;\;\;\;\frac{x}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{\frac{2}{\sqrt[3]{y - t}}}{z}\\ \mathbf{elif}\;y \le 1.7827284404274002 \cdot 10^{216}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \le -2.29685778425398707 \cdot 10^{-184}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

\mathbf{elif}\;y \le 2.5639366194123703 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{\frac{2}{\sqrt[3]{y - t}}}{z}\\

\mathbf{elif}\;y \le 1.7827284404274002 \cdot 10^{216}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r517513 = x;
        double r517514 = 2.0;
        double r517515 = r517513 * r517514;
        double r517516 = y;
        double r517517 = z;
        double r517518 = r517516 * r517517;
        double r517519 = t;
        double r517520 = r517519 * r517517;
        double r517521 = r517518 - r517520;
        double r517522 = r517515 / r517521;
        return r517522;
}

double f(double x, double y, double z, double t) {
        double r517523 = y;
        double r517524 = -2.296857784253987e-184;
        bool r517525 = r517523 <= r517524;
        double r517526 = x;
        double r517527 = z;
        double r517528 = r517526 / r517527;
        double r517529 = t;
        double r517530 = r517523 - r517529;
        double r517531 = 2.0;
        double r517532 = r517530 / r517531;
        double r517533 = r517528 / r517532;
        double r517534 = 2.5639366194123703e-127;
        bool r517535 = r517523 <= r517534;
        double r517536 = cbrt(r517530);
        double r517537 = r517536 * r517536;
        double r517538 = r517526 / r517537;
        double r517539 = r517531 / r517536;
        double r517540 = r517539 / r517527;
        double r517541 = r517538 * r517540;
        double r517542 = 1.7827284404274002e+216;
        bool r517543 = r517523 <= r517542;
        double r517544 = r517531 / r517530;
        double r517545 = r517544 / r517527;
        double r517546 = r517526 * r517545;
        double r517547 = 1.0;
        double r517548 = r517547 / r517527;
        double r517549 = r517526 / r517532;
        double r517550 = r517548 * r517549;
        double r517551 = r517543 ? r517546 : r517550;
        double r517552 = r517535 ? r517541 : r517551;
        double r517553 = r517525 ? r517533 : r517552;
        return r517553;
}

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.1
Target2.0
Herbie5.5
\[\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 4 regimes
  2. if y < -2.296857784253987e-184

    1. Initial program 7.7

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied associate-/r*5.7

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

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

    if -2.296857784253987e-184 < y < 2.5639366194123703e-127

    1. Initial program 6.3

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{\frac{2}{y - t}}{z}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity6.3

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

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

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

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

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

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

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

    if 2.5639366194123703e-127 < y < 1.7827284404274002e+216

    1. Initial program 6.0

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

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

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

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

    if 1.7827284404274002e+216 < y

    1. Initial program 10.2

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.29685778425398707 \cdot 10^{-184}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \le 2.5639366194123703 \cdot 10^{-127}:\\ \;\;\;\;\frac{x}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{\frac{2}{\sqrt[3]{y - t}}}{z}\\ \mathbf{elif}\;y \le 1.7827284404274002 \cdot 10^{216}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

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