Average Error: 6.8 → 3.5
Time: 4.9s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.154512528065834 \cdot 10^{229} \lor \neg \left(z \le 9.1298419035993844 \cdot 10^{-77}\right):\\ \;\;\;\;{\left(\frac{\frac{x}{\frac{y - t}{2}}}{z}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z}}{y - t} \cdot \frac{x}{\frac{1}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -4.154512528065834 \cdot 10^{229} \lor \neg \left(z \le 9.1298419035993844 \cdot 10^{-77}\right):\\
\;\;\;\;{\left(\frac{\frac{x}{\frac{y - t}{2}}}{z}\right)}^{1}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r643225 = x;
        double r643226 = 2.0;
        double r643227 = r643225 * r643226;
        double r643228 = y;
        double r643229 = z;
        double r643230 = r643228 * r643229;
        double r643231 = t;
        double r643232 = r643231 * r643229;
        double r643233 = r643230 - r643232;
        double r643234 = r643227 / r643233;
        return r643234;
}

double f(double x, double y, double z, double t) {
        double r643235 = z;
        double r643236 = -4.154512528065834e+229;
        bool r643237 = r643235 <= r643236;
        double r643238 = 9.129841903599384e-77;
        bool r643239 = r643235 <= r643238;
        double r643240 = !r643239;
        bool r643241 = r643237 || r643240;
        double r643242 = x;
        double r643243 = y;
        double r643244 = t;
        double r643245 = r643243 - r643244;
        double r643246 = 2.0;
        double r643247 = r643245 / r643246;
        double r643248 = r643242 / r643247;
        double r643249 = r643248 / r643235;
        double r643250 = 1.0;
        double r643251 = pow(r643249, r643250);
        double r643252 = r643250 / r643235;
        double r643253 = r643252 / r643245;
        double r643254 = r643250 / r643246;
        double r643255 = r643242 / r643254;
        double r643256 = r643253 * r643255;
        double r643257 = r643241 ? r643251 : r643256;
        return r643257;
}

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.1
Herbie3.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 2 regimes
  2. if z < -4.154512528065834e+229 or 9.129841903599384e-77 < z

    1. Initial program 10.0

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

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

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

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

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

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

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

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

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

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

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

    if -4.154512528065834e+229 < z < 9.129841903599384e-77

    1. Initial program 4.6

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.154512528065834 \cdot 10^{229} \lor \neg \left(z \le 9.1298419035993844 \cdot 10^{-77}\right):\\ \;\;\;\;{\left(\frac{\frac{x}{\frac{y - t}{2}}}{z}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z}}{y - t} \cdot \frac{x}{\frac{1}{2}}\\ \end{array}\]

Reproduce

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