Average Error: 6.8 → 2.3
Time: 5.8s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.9379949802427703 \cdot 10^{-128}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{\frac{y - t}{\sqrt[3]{x}}} \cdot \left(\frac{\sqrt[3]{x}}{z} \cdot 2\right)\\ \mathbf{elif}\;z \le 4.5360233662522261 \cdot 10^{-37}:\\ \;\;\;\;\frac{x}{\frac{y - t}{2} \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -6.9379949802427703 \cdot 10^{-128}:\\
\;\;\;\;\frac{\sqrt[3]{x}}{\frac{y - t}{\sqrt[3]{x}}} \cdot \left(\frac{\sqrt[3]{x}}{z} \cdot 2\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r658525 = x;
        double r658526 = 2.0;
        double r658527 = r658525 * r658526;
        double r658528 = y;
        double r658529 = z;
        double r658530 = r658528 * r658529;
        double r658531 = t;
        double r658532 = r658531 * r658529;
        double r658533 = r658530 - r658532;
        double r658534 = r658527 / r658533;
        return r658534;
}

double f(double x, double y, double z, double t) {
        double r658535 = z;
        double r658536 = -6.93799498024277e-128;
        bool r658537 = r658535 <= r658536;
        double r658538 = x;
        double r658539 = cbrt(r658538);
        double r658540 = y;
        double r658541 = t;
        double r658542 = r658540 - r658541;
        double r658543 = r658542 / r658539;
        double r658544 = r658539 / r658543;
        double r658545 = r658539 / r658535;
        double r658546 = 2.0;
        double r658547 = r658545 * r658546;
        double r658548 = r658544 * r658547;
        double r658549 = 4.536023366252226e-37;
        bool r658550 = r658535 <= r658549;
        double r658551 = r658542 / r658546;
        double r658552 = r658551 * r658535;
        double r658553 = r658538 / r658552;
        double r658554 = r658538 / r658535;
        double r658555 = r658554 / r658551;
        double r658556 = r658550 ? r658553 : r658555;
        double r658557 = r658537 ? r658548 : r658556;
        return r658557;
}

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.8
Target2.2
Herbie2.3
\[\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 3 regimes
  2. if z < -6.93799498024277e-128

    1. Initial program 7.5

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{y - t}{2}}\]
    8. Using strategy rm
    9. Applied div-inv2.4

      \[\leadsto \frac{\frac{x}{z}}{\color{blue}{\left(y - t\right) \cdot \frac{1}{2}}}\]
    10. Applied *-un-lft-identity2.4

      \[\leadsto \frac{\frac{x}{\color{blue}{1 \cdot z}}}{\left(y - t\right) \cdot \frac{1}{2}}\]
    11. Applied add-cube-cbrt3.1

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

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

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

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

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

    if -6.93799498024277e-128 < z < 4.536023366252226e-37

    1. Initial program 3.5

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{y - t}{2}}\]
    8. Using strategy rm
    9. Applied div-inv12.0

      \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{z}}}{\frac{y - t}{2}}\]
    10. Applied associate-/l*3.6

      \[\leadsto \color{blue}{\frac{x}{\frac{\frac{y - t}{2}}{\frac{1}{z}}}}\]
    11. Simplified3.5

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

    if 4.536023366252226e-37 < z

    1. Initial program 9.5

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

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

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

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

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

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

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

Reproduce

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