(FPCore (x y z t) :precision binary64 (/ x (* (- y z) (- t z))))
(FPCore (x y z t) :precision binary64 (if (<= t 1.15e-71) (/ (/ -1.0 (/ (- y z) x)) (- z t)) (if (<= t 2.25e+171) (/ (/ x (- z t)) (- z y)) (/ (/ x (- z y)) (- z t)))))
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 tmp;
if (t <= 1.15e-71) {
tmp = (-1.0 / ((y - z) / x)) / (z - t);
} else if (t <= 2.25e+171) {
tmp = (x / (z - t)) / (z - y);
} else {
tmp = (x / (z - y)) / (z - t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / ((y - z) * (t - z))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 1.15d-71) then
tmp = ((-1.0d0) / ((y - z) / x)) / (z - t)
else if (t <= 2.25d+171) then
tmp = (x / (z - t)) / (z - y)
else
tmp = (x / (z - y)) / (z - t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x / ((y - z) * (t - z));
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.15e-71) {
tmp = (-1.0 / ((y - z) / x)) / (z - t);
} else if (t <= 2.25e+171) {
tmp = (x / (z - t)) / (z - y);
} else {
tmp = (x / (z - y)) / (z - t);
}
return tmp;
}
def code(x, y, z, t): return x / ((y - z) * (t - z))
def code(x, y, z, t): tmp = 0 if t <= 1.15e-71: tmp = (-1.0 / ((y - z) / x)) / (z - t) elif t <= 2.25e+171: tmp = (x / (z - t)) / (z - y) else: tmp = (x / (z - y)) / (z - t) 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) tmp = 0.0 if (t <= 1.15e-71) tmp = Float64(Float64(-1.0 / Float64(Float64(y - z) / x)) / Float64(z - t)); elseif (t <= 2.25e+171) tmp = Float64(Float64(x / Float64(z - t)) / Float64(z - y)); else tmp = Float64(Float64(x / Float64(z - y)) / Float64(z - t)); end return tmp end
function tmp = code(x, y, z, t) tmp = x / ((y - z) * (t - z)); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 1.15e-71) tmp = (-1.0 / ((y - z) / x)) / (z - t); elseif (t <= 2.25e+171) tmp = (x / (z - t)) / (z - y); else tmp = (x / (z - y)) / (z - t); end tmp_2 = 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_] := If[LessEqual[t, 1.15e-71], N[(N[(-1.0 / N[(N[(y - z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.25e+171], N[(N[(x / N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]]]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
\mathbf{if}\;t \leq 1.15 \cdot 10^{-71}:\\
\;\;\;\;\frac{\frac{-1}{\frac{y - z}{x}}}{z - t}\\
\mathbf{elif}\;t \leq 2.25 \cdot 10^{+171}:\\
\;\;\;\;\frac{\frac{x}{z - t}}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z - y}}{z - t}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 7.3 |
|---|---|
| Target | 8.2 |
| Herbie | 2.2 |
if t < 1.1499999999999999e-71Initial program 7.5
Simplified2.0
Applied egg-rr2.6
Applied egg-rr2.3
if 1.1499999999999999e-71 < t < 2.24999999999999984e171Initial program 5.2
Simplified2.0
Taylor expanded in x around 0 5.2
Simplified1.8
if 2.24999999999999984e171 < t Initial program 10.0
Simplified2.4
Final simplification2.2
herbie shell --seed 2022166
(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))))