Average Error: 7.4 → 1.7
Time: 1.1m
Precision: 64
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.304871333744858729950181693700096214694 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{1}{\frac{t - z}{x}}}{y - z}\\ \mathbf{elif}\;x \le 2.08364774622770445821819618058878978416 \cdot 10^{72}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{t - z}{\sqrt{x}}}{\frac{\sqrt{x}}{y - z}}}\\ \end{array}\]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
\mathbf{if}\;x \le -2.304871333744858729950181693700096214694 \cdot 10^{-57}:\\
\;\;\;\;\frac{\frac{1}{\frac{t - z}{x}}}{y - z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r34520053 = x;
        double r34520054 = y;
        double r34520055 = z;
        double r34520056 = r34520054 - r34520055;
        double r34520057 = t;
        double r34520058 = r34520057 - r34520055;
        double r34520059 = r34520056 * r34520058;
        double r34520060 = r34520053 / r34520059;
        return r34520060;
}

double f(double x, double y, double z, double t) {
        double r34520061 = x;
        double r34520062 = -2.3048713337448587e-57;
        bool r34520063 = r34520061 <= r34520062;
        double r34520064 = 1.0;
        double r34520065 = t;
        double r34520066 = z;
        double r34520067 = r34520065 - r34520066;
        double r34520068 = r34520067 / r34520061;
        double r34520069 = r34520064 / r34520068;
        double r34520070 = y;
        double r34520071 = r34520070 - r34520066;
        double r34520072 = r34520069 / r34520071;
        double r34520073 = 2.0836477462277045e+72;
        bool r34520074 = r34520061 <= r34520073;
        double r34520075 = r34520071 * r34520067;
        double r34520076 = r34520061 / r34520075;
        double r34520077 = sqrt(r34520061);
        double r34520078 = r34520067 / r34520077;
        double r34520079 = r34520077 / r34520071;
        double r34520080 = r34520078 / r34520079;
        double r34520081 = r34520064 / r34520080;
        double r34520082 = r34520074 ? r34520076 : r34520081;
        double r34520083 = r34520063 ? r34520072 : r34520082;
        return r34520083;
}

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.4
Target8.3
Herbie1.7
\[\begin{array}{l} \mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \lt 0.0:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{\left(y - z\right) \cdot \left(t - z\right)}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -2.3048713337448587e-57

    1. Initial program 12.2

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*2.2

      \[\leadsto \color{blue}{\frac{\frac{x}{y - z}}{t - z}}\]
    4. Using strategy rm
    5. Applied clear-num3.0

      \[\leadsto \color{blue}{\frac{1}{\frac{t - z}{\frac{x}{y - z}}}}\]
    6. Using strategy rm
    7. Applied associate-/r/2.5

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

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

    if -2.3048713337448587e-57 < x < 2.0836477462277045e+72

    1. Initial program 1.5

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*1.8

      \[\leadsto \color{blue}{\frac{\frac{x}{y - z}}{t - z}}\]
    4. Using strategy rm
    5. Applied div-inv1.9

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

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

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

    if 2.0836477462277045e+72 < x

    1. Initial program 17.7

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*2.9

      \[\leadsto \color{blue}{\frac{\frac{x}{y - z}}{t - z}}\]
    4. Using strategy rm
    5. Applied clear-num3.7

      \[\leadsto \color{blue}{\frac{1}{\frac{t - z}{\frac{x}{y - z}}}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity3.7

      \[\leadsto \frac{1}{\frac{t - z}{\frac{x}{\color{blue}{1 \cdot \left(y - z\right)}}}}\]
    8. Applied add-sqr-sqrt3.8

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

      \[\leadsto \frac{1}{\frac{t - z}{\color{blue}{\frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{y - z}}}}\]
    10. Applied associate-/r*1.9

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{t - z}{\frac{\sqrt{x}}{1}}}{\frac{\sqrt{x}}{y - z}}}}\]
    11. Simplified1.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.304871333744858729950181693700096214694 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{1}{\frac{t - z}{x}}}{y - z}\\ \mathbf{elif}\;x \le 2.08364774622770445821819618058878978416 \cdot 10^{72}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{t - z}{\sqrt{x}}}{\frac{\sqrt{x}}{y - z}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019200 
(FPCore (x y z t)
  :name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, B"

  :herbie-target
  (if (< (/ x (* (- y z) (- t z))) 0.0) (/ (/ x (- y z)) (- t z)) (* x (/ 1.0 (* (- y z) (- t z)))))

  (/ x (* (- y z) (- t z))))