Average Error: 7.4 → 0.9
Time: 17.9s
Precision: 64
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
\[\begin{array}{l} \mathbf{if}\;\left(t - z\right) \cdot \left(y - z\right) = -\infty:\\ \;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\ \mathbf{elif}\;\left(t - z\right) \cdot \left(y - z\right) \le 5.4712057353380415 \cdot 10^{+122}:\\ \;\;\;\;\frac{x}{\left(t - z\right) \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z} \cdot \frac{1}{t - z}\\ \end{array}\]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
\mathbf{if}\;\left(t - z\right) \cdot \left(y - z\right) = -\infty:\\
\;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r38643006 = x;
        double r38643007 = y;
        double r38643008 = z;
        double r38643009 = r38643007 - r38643008;
        double r38643010 = t;
        double r38643011 = r38643010 - r38643008;
        double r38643012 = r38643009 * r38643011;
        double r38643013 = r38643006 / r38643012;
        return r38643013;
}

double f(double x, double y, double z, double t) {
        double r38643014 = t;
        double r38643015 = z;
        double r38643016 = r38643014 - r38643015;
        double r38643017 = y;
        double r38643018 = r38643017 - r38643015;
        double r38643019 = r38643016 * r38643018;
        double r38643020 = -inf.0;
        bool r38643021 = r38643019 <= r38643020;
        double r38643022 = x;
        double r38643023 = r38643022 / r38643016;
        double r38643024 = r38643023 / r38643018;
        double r38643025 = 5.4712057353380415e+122;
        bool r38643026 = r38643019 <= r38643025;
        double r38643027 = r38643022 / r38643019;
        double r38643028 = r38643022 / r38643018;
        double r38643029 = 1.0;
        double r38643030 = r38643029 / r38643016;
        double r38643031 = r38643028 * r38643030;
        double r38643032 = r38643026 ? r38643027 : r38643031;
        double r38643033 = r38643021 ? r38643024 : r38643032;
        return r38643033;
}

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

    1. Initial program 19.3

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt19.3

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{y - z} \cdot \frac{\sqrt[3]{x}}{t - z}}\]
    5. Using strategy rm
    6. Applied associate-*l/0.4

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

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

    if -inf.0 < (* (- y z) (- t z)) < 5.4712057353380415e+122

    1. Initial program 1.5

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

    if 5.4712057353380415e+122 < (* (- y z) (- t z))

    1. Initial program 10.1

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt10.3

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{y - z} \cdot \frac{\sqrt[3]{x}}{t - z}}\]
    5. Using strategy rm
    6. Applied div-inv0.8

      \[\leadsto \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{y - z} \cdot \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{t - z}\right)}\]
    7. Applied associate-*r*1.0

      \[\leadsto \color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{y - z} \cdot \sqrt[3]{x}\right) \cdot \frac{1}{t - z}}\]
    8. Simplified0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(t - z\right) \cdot \left(y - z\right) = -\infty:\\ \;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\ \mathbf{elif}\;\left(t - z\right) \cdot \left(y - z\right) \le 5.4712057353380415 \cdot 10^{+122}:\\ \;\;\;\;\frac{x}{\left(t - z\right) \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z} \cdot \frac{1}{t - z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 
(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 (* (- y z) (- t z)))))

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