(FPCore (x y z t) :precision binary64 (/ x (* (- y z) (- t z))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- y z) (- t z))))
(if (<= t_1 -2e+215)
(/ (/ 1.0 (- z y)) (/ (- z t) x))
(if (<= t_1 2e+216) (/ x t_1) (/ (/ 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 t_1 = (y - z) * (t - z);
double tmp;
if (t_1 <= -2e+215) {
tmp = (1.0 / (z - y)) / ((z - t) / x);
} else if (t_1 <= 2e+216) {
tmp = x / t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = (y - z) * (t - z)
if (t_1 <= (-2d+215)) then
tmp = (1.0d0 / (z - y)) / ((z - t) / x)
else if (t_1 <= 2d+216) then
tmp = x / t_1
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 t_1 = (y - z) * (t - z);
double tmp;
if (t_1 <= -2e+215) {
tmp = (1.0 / (z - y)) / ((z - t) / x);
} else if (t_1 <= 2e+216) {
tmp = x / t_1;
} 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): t_1 = (y - z) * (t - z) tmp = 0 if t_1 <= -2e+215: tmp = (1.0 / (z - y)) / ((z - t) / x) elif t_1 <= 2e+216: tmp = x / t_1 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) t_1 = Float64(Float64(y - z) * Float64(t - z)) tmp = 0.0 if (t_1 <= -2e+215) tmp = Float64(Float64(1.0 / Float64(z - y)) / Float64(Float64(z - t) / x)); elseif (t_1 <= 2e+216) tmp = Float64(x / t_1); 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) t_1 = (y - z) * (t - z); tmp = 0.0; if (t_1 <= -2e+215) tmp = (1.0 / (z - y)) / ((z - t) / x); elseif (t_1 <= 2e+216) tmp = x / t_1; 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_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+215], N[(N[(1.0 / N[(z - y), $MachinePrecision]), $MachinePrecision] / N[(N[(z - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+216], N[(x / t$95$1), $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}
t_1 := \left(y - z\right) \cdot \left(t - z\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+215}:\\
\;\;\;\;\frac{\frac{1}{z - y}}{\frac{z - t}{x}}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+216}:\\
\;\;\;\;\frac{x}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z - y}}{z - t}\\
\end{array}
Results
| Original | 7.7 |
|---|---|
| Target | 8.4 |
| Herbie | 0.9 |
if (*.f64 (-.f64 y z) (-.f64 t z)) < -1.99999999999999981e215Initial program 12.6
Simplified0.3
Applied egg-rr0.8
Applied egg-rr0.3
if -1.99999999999999981e215 < (*.f64 (-.f64 y z) (-.f64 t z)) < 2e216Initial program 1.6
if 2e216 < (*.f64 (-.f64 y z) (-.f64 t z)) Initial program 13.0
Simplified0.2
Final simplification0.9
herbie shell --seed 2022192
(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))))