Average Error: 7.1 → 5.5
Time: 4.8s
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 r508343 = x;
        double r508344 = 2.0;
        double r508345 = r508343 * r508344;
        double r508346 = y;
        double r508347 = z;
        double r508348 = r508346 * r508347;
        double r508349 = t;
        double r508350 = r508349 * r508347;
        double r508351 = r508348 - r508350;
        double r508352 = r508345 / r508351;
        return r508352;
}

double f(double x, double y, double z, double t) {
        double r508353 = y;
        double r508354 = -2.296857784253987e-184;
        bool r508355 = r508353 <= r508354;
        double r508356 = x;
        double r508357 = z;
        double r508358 = r508356 / r508357;
        double r508359 = t;
        double r508360 = r508353 - r508359;
        double r508361 = 2.0;
        double r508362 = r508360 / r508361;
        double r508363 = r508358 / r508362;
        double r508364 = 2.5639366194123703e-127;
        bool r508365 = r508353 <= r508364;
        double r508366 = cbrt(r508360);
        double r508367 = r508366 * r508366;
        double r508368 = r508356 / r508367;
        double r508369 = r508361 / r508366;
        double r508370 = r508369 / r508357;
        double r508371 = r508368 * r508370;
        double r508372 = 1.7827284404274002e+216;
        bool r508373 = r508353 <= r508372;
        double r508374 = r508361 / r508360;
        double r508375 = r508374 / r508357;
        double r508376 = r508356 * r508375;
        double r508377 = 1.0;
        double r508378 = r508377 / r508357;
        double r508379 = r508356 / r508362;
        double r508380 = r508378 * r508379;
        double r508381 = r508373 ? r508376 : r508380;
        double r508382 = r508365 ? r508371 : r508381;
        double r508383 = r508355 ? r508363 : r508382;
        return r508383;
}

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 +o rules:numerics
(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))))