Average Error: 6.6 → 1.7
Time: 13.4s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -2.189692383898529 \cdot 10^{+133}:\\ \;\;\;\;\frac{\frac{2.0 \cdot x}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 5.325542296946449 \cdot 10^{+160}:\\ \;\;\;\;\frac{2.0 \cdot x}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2.0 \cdot x}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -2.189692383898529 \cdot 10^{+133}:\\
\;\;\;\;\frac{\frac{2.0 \cdot x}{z}}{y - t}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le 5.325542296946449 \cdot 10^{+160}:\\
\;\;\;\;\frac{2.0 \cdot x}{y \cdot z - t \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r26134143 = x;
        double r26134144 = 2.0;
        double r26134145 = r26134143 * r26134144;
        double r26134146 = y;
        double r26134147 = z;
        double r26134148 = r26134146 * r26134147;
        double r26134149 = t;
        double r26134150 = r26134149 * r26134147;
        double r26134151 = r26134148 - r26134150;
        double r26134152 = r26134145 / r26134151;
        return r26134152;
}

double f(double x, double y, double z, double t) {
        double r26134153 = y;
        double r26134154 = z;
        double r26134155 = r26134153 * r26134154;
        double r26134156 = t;
        double r26134157 = r26134156 * r26134154;
        double r26134158 = r26134155 - r26134157;
        double r26134159 = -2.189692383898529e+133;
        bool r26134160 = r26134158 <= r26134159;
        double r26134161 = 2.0;
        double r26134162 = x;
        double r26134163 = r26134161 * r26134162;
        double r26134164 = r26134163 / r26134154;
        double r26134165 = r26134153 - r26134156;
        double r26134166 = r26134164 / r26134165;
        double r26134167 = 5.325542296946449e+160;
        bool r26134168 = r26134158 <= r26134167;
        double r26134169 = r26134163 / r26134158;
        double r26134170 = r26134168 ? r26134169 : r26134166;
        double r26134171 = r26134160 ? r26134166 : r26134170;
        return r26134171;
}

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.1
Herbie1.7
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \mathbf{elif}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt 1.045027827330126 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2.0}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* y z) (* t z)) < -2.189692383898529e+133 or 5.325542296946449e+160 < (- (* y z) (* t z))

    1. Initial program 11.8

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

      \[\leadsto \color{blue}{\frac{2.0}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt1.8

      \[\leadsto \frac{2.0}{y - t} \cdot \frac{x}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}\]
    5. Applied *-un-lft-identity1.8

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{2.0}{y - t}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{x}{\sqrt[3]{z}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity5.5

      \[\leadsto \frac{\frac{2.0}{y - t}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{x}{\sqrt[3]{\color{blue}{1 \cdot z}}}\]
    11. Applied cbrt-prod5.5

      \[\leadsto \frac{\frac{2.0}{y - t}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{x}{\color{blue}{\sqrt[3]{1} \cdot \sqrt[3]{z}}}\]
    12. Applied *-un-lft-identity5.5

      \[\leadsto \frac{\frac{2.0}{y - t}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{\color{blue}{1 \cdot x}}{\sqrt[3]{1} \cdot \sqrt[3]{z}}\]
    13. Applied times-frac5.5

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

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

      \[\leadsto \color{blue}{\frac{\frac{2.0}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{y - t}} \cdot \frac{x}{\sqrt[3]{z}}\]
    16. Using strategy rm
    17. Applied associate-*l/1.8

      \[\leadsto \color{blue}{\frac{\frac{2.0}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{x}{\sqrt[3]{z}}}{y - t}}\]
    18. Simplified1.3

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

    if -2.189692383898529e+133 < (- (* y z) (* t z)) < 5.325542296946449e+160

    1. Initial program 2.1

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -2.189692383898529 \cdot 10^{+133}:\\ \;\;\;\;\frac{\frac{2.0 \cdot x}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 5.325542296946449 \cdot 10^{+160}:\\ \;\;\;\;\frac{2.0 \cdot x}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2.0 \cdot x}{z}}{y - t}\\ \end{array}\]

Reproduce

herbie shell --seed 2019164 
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

  (/ (* x 2.0) (- (* y z) (* t z))))