(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (+ y z)) z)) (t_1 (fma y (/ x z) x)))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -2e-77)
(/ (fma z x (* x y)) z)
(if (<= t_0 2e-89) (fma x (/ y z) x) t_1)))))double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
double t_0 = (x * (y + z)) / z;
double t_1 = fma(y, (x / z), x);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -2e-77) {
tmp = fma(z, x, (x * y)) / z;
} else if (t_0 <= 2e-89) {
tmp = fma(x, (y / z), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y + z)) / z) t_1 = fma(y, Float64(x / z), x) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= -2e-77) tmp = Float64(fma(z, x, Float64(x * y)) / z); elseif (t_0 <= 2e-89) tmp = fma(x, Float64(y / z), x); else tmp = t_1; end return tmp end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, -2e-77], N[(N[(z * x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$0, 2e-89], N[(x * N[(y / z), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y + z\right)}{z}\\
t_1 := \mathsf{fma}\left(y, \frac{x}{z}, x\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-77}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, x \cdot y\right)}{z}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-89}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
| Original | 12.6 |
|---|---|
| Target | 3.1 |
| Herbie | 1.8 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or 2.00000000000000008e-89 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 22.2
Simplified3.8
Taylor expanded in x around 0 3.8
Simplified4.0
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -1.9999999999999999e-77Initial program 0.3
Applied egg-rr0.3
if -1.9999999999999999e-77 < (/.f64 (*.f64 x (+.f64 y z)) z) < 2.00000000000000008e-89Initial program 9.9
Simplified0.1
Final simplification1.8
herbie shell --seed 2022181
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))