Average Error: 6.8 → 2.2
Time: 4.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.95442192702372847 \cdot 10^{61}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 4.6738271756222066 \cdot 10^{62}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\frac{x}{\frac{y - t}{2}}}{z}\right)}^{1}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -1.95442192702372847 \cdot 10^{61}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\frac{x}{\frac{y - t}{2}}}{z}\right)}^{1}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r624614 = x;
        double r624615 = 2.0;
        double r624616 = r624614 * r624615;
        double r624617 = y;
        double r624618 = z;
        double r624619 = r624617 * r624618;
        double r624620 = t;
        double r624621 = r624620 * r624618;
        double r624622 = r624619 - r624621;
        double r624623 = r624616 / r624622;
        return r624623;
}

double f(double x, double y, double z, double t) {
        double r624624 = z;
        double r624625 = -1.9544219270237285e+61;
        bool r624626 = r624624 <= r624625;
        double r624627 = x;
        double r624628 = r624627 / r624624;
        double r624629 = y;
        double r624630 = t;
        double r624631 = r624629 - r624630;
        double r624632 = 2.0;
        double r624633 = r624631 / r624632;
        double r624634 = r624628 / r624633;
        double r624635 = 4.673827175622207e+62;
        bool r624636 = r624624 <= r624635;
        double r624637 = r624624 * r624631;
        double r624638 = r624637 / r624632;
        double r624639 = r624627 / r624638;
        double r624640 = r624627 / r624633;
        double r624641 = r624640 / r624624;
        double r624642 = 1.0;
        double r624643 = pow(r624641, r624642);
        double r624644 = r624636 ? r624639 : r624643;
        double r624645 = r624626 ? r624634 : r624644;
        return r624645;
}

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.0
Herbie2.2
\[\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 < -1.9544219270237285e+61

    1. Initial program 12.7

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

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

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

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

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

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

    if -1.9544219270237285e+61 < z < 4.673827175622207e+62

    1. Initial program 2.2

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

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

    if 4.673827175622207e+62 < z

    1. Initial program 12.7

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    9. Using strategy rm
    10. Applied pow12.3

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

      \[\leadsto \color{blue}{{\left(\frac{1}{z}\right)}^{1}} \cdot {\left(\frac{x}{\frac{y - t}{2}}\right)}^{1}\]
    12. Applied pow-prod-down2.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.95442192702372847 \cdot 10^{61}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 4.6738271756222066 \cdot 10^{62}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\frac{x}{\frac{y - t}{2}}}{z}\right)}^{1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +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))))