Average Error: 7.0 → 1.1
Time: 10.5s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -5.966470809942352604280748168933341651291 \cdot 10^{-251}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{y - t}}{\frac{z}{x}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -5.966470809942352604280748168933341651291 \cdot 10^{-251}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

\mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0:\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r479087 = x;
        double r479088 = 2.0;
        double r479089 = r479087 * r479088;
        double r479090 = y;
        double r479091 = z;
        double r479092 = r479090 * r479091;
        double r479093 = t;
        double r479094 = r479093 * r479091;
        double r479095 = r479092 - r479094;
        double r479096 = r479089 / r479095;
        return r479096;
}

double f(double x, double y, double z, double t) {
        double r479097 = x;
        double r479098 = 2.0;
        double r479099 = r479097 * r479098;
        double r479100 = y;
        double r479101 = z;
        double r479102 = r479100 * r479101;
        double r479103 = t;
        double r479104 = r479103 * r479101;
        double r479105 = r479102 - r479104;
        double r479106 = r479099 / r479105;
        double r479107 = -5.9664708099423526e-251;
        bool r479108 = r479106 <= r479107;
        double r479109 = -0.0;
        bool r479110 = r479106 <= r479109;
        double r479111 = r479099 / r479101;
        double r479112 = r479100 - r479103;
        double r479113 = r479111 / r479112;
        double r479114 = 7.820034338024704e+269;
        bool r479115 = r479106 <= r479114;
        double r479116 = r479098 / r479112;
        double r479117 = r479101 / r479097;
        double r479118 = r479116 / r479117;
        double r479119 = r479115 ? r479106 : r479118;
        double r479120 = r479110 ? r479113 : r479119;
        double r479121 = r479108 ? r479106 : r479120;
        return r479121;
}

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.0
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \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.045027827330126029709547581125571222799 \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 (/ (* x 2.0) (- (* y z) (* t z))) < -5.9664708099423526e-251 or -0.0 < (/ (* x 2.0) (- (* y z) (* t z))) < 7.820034338024704e+269

    1. Initial program 1.0

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

    if -5.9664708099423526e-251 < (/ (* x 2.0) (- (* y z) (* t z))) < -0.0

    1. Initial program 12.5

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied clear-num13.0

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot z - t \cdot z}{x \cdot 2}}}\]
    4. Simplified13.0

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(y - t\right) \cdot z}{2 \cdot x}}}\]
    5. Using strategy rm
    6. Applied pow113.0

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

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

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

      \[\leadsto \frac{1}{\frac{{\color{blue}{\left(z \cdot \left(y - t\right)\right)}}^{1}}{2 \cdot x}}\]
    10. Using strategy rm
    11. Applied div-inv13.0

      \[\leadsto \frac{1}{\color{blue}{{\left(z \cdot \left(y - t\right)\right)}^{1} \cdot \frac{1}{2 \cdot x}}}\]
    12. Applied add-cube-cbrt13.0

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{z}}{y - t}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{2 \cdot x}}\]
    15. Simplified11.4

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{\frac{1}{1}}{1} \cdot \frac{\frac{1}{z}}{y - t}\right)} \cdot \left(x \cdot 2\right)\]
    22. Applied associate-*l*11.4

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

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

    if 7.820034338024704e+269 < (/ (* x 2.0) (- (* y z) (* t z)))

    1. Initial program 49.0

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied clear-num49.1

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -5.966470809942352604280748168933341651291 \cdot 10^{-251}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{y - t}}{\frac{z}{x}}\\ \end{array}\]

Reproduce

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