(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z (+ y -1.0)))))
(if (<= t_0 -1.98e+301)
(fma z (fma x y x) x)
(if (<= t_0 2e+62) (fma x (- (* y z) z) x) (- x (* z (- x (* y 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 t_0 = 1.0 + (z * (y + -1.0));
double tmp;
if (t_0 <= -1.98e+301) {
tmp = fma(z, fma(x, y, x), x);
} else if (t_0 <= 2e+62) {
tmp = fma(x, ((y * z) - z), x);
} else {
tmp = x - (z * (x - (y * 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) t_0 = Float64(1.0 + Float64(z * Float64(y + -1.0))) tmp = 0.0 if (t_0 <= -1.98e+301) tmp = fma(z, fma(x, y, x), x); elseif (t_0 <= 2e+62) tmp = fma(x, Float64(Float64(y * z) - z), x); else tmp = Float64(x - Float64(z * Float64(x - Float64(y * 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_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.98e+301], N[(z * N[(x * y + x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 2e+62], N[(x * N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision] + x), $MachinePrecision], N[(x - N[(z * N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
t_0 := 1 + z \cdot \left(y + -1\right)\\
\mathbf{if}\;t_0 \leq -1.98 \cdot 10^{+301}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(x, y, x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \left(x - y \cdot x\right)\\
\end{array}
| Original | 3.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
if (-.f64 1 (*.f64 (-.f64 1 y) z)) < -1.98e301Initial program 57.1
Simplified0.2
Applied egg-rr1.3
Applied egg-rr4.0
if -1.98e301 < (-.f64 1 (*.f64 (-.f64 1 y) z)) < 2.00000000000000007e62Initial program 0.1
Simplified4.1
Taylor expanded in z around 0 4.1
Simplified0.1
if 2.00000000000000007e62 < (-.f64 1 (*.f64 (-.f64 1 y) z)) Initial program 8.7
Simplified2.6
Taylor expanded in y around 0 2.2
Taylor expanded in z around 0 2.6
Final simplification0.7
herbie shell --seed 2022190
(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))))