(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(if (<= x -5.3988853793724826e+48)
(fma (- x) z (fma y (* x z) x))
(if (<= x 75475486738441900.0)
(fma z (* x y) (- x (* x z)))
(- (fma (* x z) y x) (* x z)))))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 (x <= -5.3988853793724826e+48) {
tmp = fma(-x, z, fma(y, (x * z), x));
} else if (x <= 75475486738441900.0) {
tmp = fma(z, (x * y), (x - (x * z)));
} else {
tmp = fma((x * z), y, x) - (x * z);
}
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 (x <= -5.3988853793724826e+48) tmp = fma(Float64(-x), z, fma(y, Float64(x * z), x)); elseif (x <= 75475486738441900.0) tmp = fma(z, Float64(x * y), Float64(x - Float64(x * z))); else tmp = Float64(fma(Float64(x * z), y, x) - Float64(x * z)); 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[x, -5.3988853793724826e+48], N[((-x) * z + N[(y * N[(x * z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 75475486738441900.0], N[(z * N[(x * y), $MachinePrecision] + N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * z), $MachinePrecision] * y + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \leq -5.3988853793724826 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, \mathsf{fma}\left(y, x \cdot z, x\right)\right)\\
\mathbf{elif}\;x \leq 75475486738441900:\\
\;\;\;\;\mathsf{fma}\left(z, x \cdot y, x - x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot z, y, x\right) - x \cdot z\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 3.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
if x < -5.39888537937248265e48Initial program 0.1
Simplified0.1
Taylor expanded in y around 0 0.1
Applied egg-rr0.1
if -5.39888537937248265e48 < x < 75475486738441904Initial program 5.3
Simplified5.3
Taylor expanded in y around 0 2.5
Applied egg-rr0.2
if 75475486738441904 < x Initial program 0.1
Simplified0.1
Taylor expanded in y around 0 0.1
Applied egg-rr0.0
Final simplification0.1
herbie shell --seed 2022133
(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))))