Average Error: 6.8 → 0.4
Time: 4.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\ \;\;\;\;\frac{x}{y - t} \cdot \left(\frac{1}{z} \cdot 2\right)\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -1.26696064920865741 \cdot 10^{-220}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 6.35822688866664516 \cdot 10^{-124}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 1.2920916156507311 \cdot 10^{222}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\
\;\;\;\;\frac{x}{y - t} \cdot \left(\frac{1}{z} \cdot 2\right)\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r537598 = x;
        double r537599 = 2.0;
        double r537600 = r537598 * r537599;
        double r537601 = y;
        double r537602 = z;
        double r537603 = r537601 * r537602;
        double r537604 = t;
        double r537605 = r537604 * r537602;
        double r537606 = r537603 - r537605;
        double r537607 = r537600 / r537606;
        return r537607;
}

double f(double x, double y, double z, double t) {
        double r537608 = y;
        double r537609 = z;
        double r537610 = r537608 * r537609;
        double r537611 = t;
        double r537612 = r537611 * r537609;
        double r537613 = r537610 - r537612;
        double r537614 = -inf.0;
        bool r537615 = r537613 <= r537614;
        double r537616 = x;
        double r537617 = r537608 - r537611;
        double r537618 = r537616 / r537617;
        double r537619 = 1.0;
        double r537620 = r537619 / r537609;
        double r537621 = 2.0;
        double r537622 = r537620 * r537621;
        double r537623 = r537618 * r537622;
        double r537624 = -1.2669606492086574e-220;
        bool r537625 = r537613 <= r537624;
        double r537626 = r537616 * r537621;
        double r537627 = r537626 / r537613;
        double r537628 = 6.358226888666645e-124;
        bool r537629 = r537613 <= r537628;
        double r537630 = r537616 / r537609;
        double r537631 = r537617 / r537621;
        double r537632 = r537630 / r537631;
        double r537633 = 1.2920916156507311e+222;
        bool r537634 = r537613 <= r537633;
        double r537635 = r537621 * r537618;
        double r537636 = r537635 / r537609;
        double r537637 = r537634 ? r537627 : r537636;
        double r537638 = r537629 ? r537632 : r537637;
        double r537639 = r537625 ? r537627 : r537638;
        double r537640 = r537615 ? r537623 : r537639;
        return r537640;
}

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
Herbie0.4
\[\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 z) (* t z)) < -inf.0

    1. Initial program 20.0

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{z}}{\color{blue}{\left(y - t\right) \cdot \frac{1}{2}}}\]
    10. Applied div-inv0.1

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

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

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

    if -inf.0 < (- (* y z) (* t z)) < -1.2669606492086574e-220 or 6.358226888666645e-124 < (- (* y z) (* t z)) < 1.2920916156507311e+222

    1. Initial program 0.3

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

    if -1.2669606492086574e-220 < (- (* y z) (* t z)) < 6.358226888666645e-124

    1. Initial program 13.5

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

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

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

      \[\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}}\]

    if 1.2920916156507311e+222 < (- (* y z) (* t z))

    1. Initial program 18.6

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{z}}{\color{blue}{\left(y - t\right) \cdot \frac{1}{2}}}\]
    10. Applied div-inv0.2

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

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

      \[\leadsto \frac{x}{y - t} \cdot \color{blue}{\left(\frac{1}{z} \cdot 2\right)}\]
    13. Using strategy rm
    14. Applied associate-*l/0.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\ \;\;\;\;\frac{x}{y - t} \cdot \left(\frac{1}{z} \cdot 2\right)\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -1.26696064920865741 \cdot 10^{-220}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 6.35822688866664516 \cdot 10^{-124}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 1.2920916156507311 \cdot 10^{222}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \end{array}\]

Reproduce

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