(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+201)
(/ (/ x (- z t)) (- z y))
(if (<= t_1 -2e-248)
(/ x (* (- z t) (- z y)))
(* (/ (pow (cbrt x) 2.0) (- z t)) (/ (cbrt x) (- z y)))))))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+201) {
tmp = (x / (z - t)) / (z - y);
} else if (t_1 <= -2e-248) {
tmp = x / ((z - t) * (z - y));
} else {
tmp = (pow(cbrt(x), 2.0) / (z - t)) * (cbrt(x) / (z - y));
}
return tmp;
}
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+201) {
tmp = (x / (z - t)) / (z - y);
} else if (t_1 <= -2e-248) {
tmp = x / ((z - t) * (z - y));
} else {
tmp = (Math.pow(Math.cbrt(x), 2.0) / (z - t)) * (Math.cbrt(x) / (z - y));
}
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+201) tmp = Float64(Float64(x / Float64(z - t)) / Float64(z - y)); elseif (t_1 <= -2e-248) tmp = Float64(x / Float64(Float64(z - t) * Float64(z - y))); else tmp = Float64(Float64((cbrt(x) ^ 2.0) / Float64(z - t)) * Float64(cbrt(x) / Float64(z - y))); 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[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+201], N[(N[(x / N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -2e-248], N[(x / N[(N[(z - t), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] / N[(z - y), $MachinePrecision]), $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^{+201}:\\
\;\;\;\;\frac{\frac{x}{z - t}}{z - y}\\
\mathbf{elif}\;t_1 \leq -2 \cdot 10^{-248}:\\
\;\;\;\;\frac{x}{\left(z - t\right) \cdot \left(z - y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\sqrt[3]{x}\right)}^{2}}{z - t} \cdot \frac{\sqrt[3]{x}}{z - y}\\
\end{array}
Results
| Original | 7.4 |
|---|---|
| Target | 8.2 |
| Herbie | 1.1 |
if (*.f64 (-.f64 y z) (-.f64 t z)) < -2.00000000000000008e201Initial program 12.2
Simplified0.5
Applied egg-rr0.6
Applied egg-rr0.4
if -2.00000000000000008e201 < (*.f64 (-.f64 y z) (-.f64 t z)) < -1.99999999999999996e-248Initial program 0.2
Simplified5.8
Taylor expanded in x around 0 0.2
if -1.99999999999999996e-248 < (*.f64 (-.f64 y z) (-.f64 t z)) Initial program 8.0
Simplified1.7
Applied egg-rr1.5
Final simplification1.1
herbie shell --seed 2022210
(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))))