(FPCore (x y z t) :precision binary64 (/ x (* (- y z) (- t z))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ x (* (- y z) (- t z)))) (t_2 (/ (/ x (- z t)) (- z y))))
(if (<= t_1 0.0)
t_2
(if (<= t_1 2.351325104598589e+147)
(/ x (- (fma z z (* y t)) (* z (+ y t))))
t_2))))double code(double x, double y, double z, double t) {
return x / ((y - z) * (t - z));
}
double code(double x, double y, double z, double t) {
double t_1 = x / ((y - z) * (t - z));
double t_2 = (x / (z - t)) / (z - y);
double tmp;
if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 2.351325104598589e+147) {
tmp = x / (fma(z, z, (y * t)) - (z * (y + t)));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t) return Float64(x / Float64(Float64(y - z) * Float64(t - z))) end
function code(x, y, z, t) t_1 = Float64(x / Float64(Float64(y - z) * Float64(t - z))) t_2 = Float64(Float64(x / Float64(z - t)) / Float64(z - y)) tmp = 0.0 if (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 2.351325104598589e+147) tmp = Float64(x / Float64(fma(z, z, Float64(y * t)) - Float64(z * Float64(y + t)))); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_] := N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 2.351325104598589e+147], N[(x / N[(N[(z * z + N[(y * t), $MachinePrecision]), $MachinePrecision] - N[(z * N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
t_1 := \frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\
t_2 := \frac{\frac{x}{z - t}}{z - y}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 2.351325104598589 \cdot 10^{+147}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(z, z, y \cdot t\right) - z \cdot \left(y + t\right)}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 7.8 |
|---|---|
| Target | 8.7 |
| Herbie | 1.4 |
if (/.f64 x (*.f64 (-.f64 y z) (-.f64 t z))) < -0.0 or 2.351325104598589e147 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 t z))) Initial program 9.7
Simplified2.1
Taylor expanded in x around 0 9.7
Simplified1.6
if -0.0 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 t z))) < 2.351325104598589e147Initial program 0.3
Simplified3.5
Taylor expanded in x around inf 0.3
Simplified0.3
Final simplification1.4
herbie shell --seed 2022153
(FPCore (x y z t)
:name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, B"
:precision binary64
: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))))