Average Error: 7.0 → 2.1
Time: 10.5s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.0679094448922225 \cdot 10^{66}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 5.15733133231175267 \cdot 10^{-28}:\\ \;\;\;\;\frac{x}{\frac{-z \cdot \left(y - t\right)}{-2}}\\ \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 -3.0679094448922225 \cdot 10^{66}:\\
\;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\

\mathbf{elif}\;z \le 5.15733133231175267 \cdot 10^{-28}:\\
\;\;\;\;\frac{x}{\frac{-z \cdot \left(y - t\right)}{-2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r590211 = x;
        double r590212 = 2.0;
        double r590213 = r590211 * r590212;
        double r590214 = y;
        double r590215 = z;
        double r590216 = r590214 * r590215;
        double r590217 = t;
        double r590218 = r590217 * r590215;
        double r590219 = r590216 - r590218;
        double r590220 = r590213 / r590219;
        return r590220;
}

double f(double x, double y, double z, double t) {
        double r590221 = z;
        double r590222 = -3.0679094448922225e+66;
        bool r590223 = r590221 <= r590222;
        double r590224 = x;
        double r590225 = cbrt(r590224);
        double r590226 = r590221 / r590225;
        double r590227 = r590225 / r590226;
        double r590228 = y;
        double r590229 = t;
        double r590230 = r590228 - r590229;
        double r590231 = 2.0;
        double r590232 = r590230 / r590231;
        double r590233 = r590225 / r590232;
        double r590234 = r590227 * r590233;
        double r590235 = 5.157331332311753e-28;
        bool r590236 = r590221 <= r590235;
        double r590237 = r590221 * r590230;
        double r590238 = -r590237;
        double r590239 = -r590231;
        double r590240 = r590238 / r590239;
        double r590241 = r590224 / r590240;
        double r590242 = r590224 / r590221;
        double r590243 = r590242 / r590232;
        double r590244 = r590236 ? r590241 : r590243;
        double r590245 = r590223 ? r590234 : r590244;
        return r590245;
}

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
Herbie2.1
\[\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 < -3.0679094448922225e+66

    1. Initial program 13.6

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

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

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

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

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

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

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

    if -3.0679094448922225e+66 < z < 5.157331332311753e-28

    1. Initial program 2.4

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

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

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

    if 5.157331332311753e-28 < z

    1. Initial program 9.5

      \[\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 associate-/r*1.7

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

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

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

Reproduce

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