(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(if (<= z -2.8203134534163076e-14)
(- (fma (* z x) y x) (* z x))
(if (<= z 4.6176097849876254e-54)
(* x (fma z y (- 1.0 z)))
(fma z (- (* x y) x) x))))double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
double code(double x, double y, double z) {
double tmp;
if (z <= -2.8203134534163076e-14) {
tmp = fma((z * x), y, x) - (z * x);
} else if (z <= 4.6176097849876254e-54) {
tmp = x * fma(z, y, (1.0 - z));
} else {
tmp = fma(z, ((x * y) - x), x);
}
return tmp;
}
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function code(x, y, z) tmp = 0.0 if (z <= -2.8203134534163076e-14) tmp = Float64(fma(Float64(z * x), y, x) - Float64(z * x)); elseif (z <= 4.6176097849876254e-54) tmp = Float64(x * fma(z, y, Float64(1.0 - z))); else tmp = fma(z, Float64(Float64(x * y) - x), x); end return tmp end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, -2.8203134534163076e-14], N[(N[(N[(z * x), $MachinePrecision] * y + x), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.6176097849876254e-54], N[(x * N[(z * y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision] + x), $MachinePrecision]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \leq -2.8203134534163076 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot x, y, x\right) - z \cdot x\\
\mathbf{elif}\;z \leq 4.6176097849876254 \cdot 10^{-54}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(z, y, 1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x \cdot y - x, x\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 3.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
if z < -2.8203134534163076e-14Initial program 8.1
Taylor expanded in y around 0 0.1
Applied egg-rr0.1
if -2.8203134534163076e-14 < z < 4.6176097849876254e-54Initial program 0.1
Taylor expanded in y around 0 2.6
Taylor expanded in y around inf 2.6
Simplified0.1
if 4.6176097849876254e-54 < z Initial program 6.6
Simplified0.4
Final simplification0.2
herbie shell --seed 2022153
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))