(FPCore (x y z t a b) :precision binary64 (* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))
(FPCore (x y z t a b)
:precision binary64
(if (<=
(*
(* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0)))
(cos (/ (* t (* (+ 1.0 (* 2.0 a)) b)) 16.0)))
2e+17)
(*
(log (+ 1.0 (expm1 (cos (* (fma y 0.125 0.0625) (* z t))))))
(* x (cos (* t (* b (fma a 0.125 0.0625))))))
x))double code(double x, double y, double z, double t, double a, double b) {
return (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(((t * ((1.0 + (2.0 * a)) * b)) / 16.0))) <= 2e+17) {
tmp = log((1.0 + expm1(cos((fma(y, 0.125, 0.0625) * (z * t)))))) * (x * cos((t * (b * fma(a, 0.125, 0.0625)))));
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(Float64(Float64(Float64(Float64(Float64(a * 2.0) + 1.0) * b) * t) / 16.0))) end
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(Float64(Float64(t * Float64(Float64(1.0 + Float64(2.0 * a)) * b)) / 16.0))) <= 2e+17) tmp = Float64(log(Float64(1.0 + expm1(cos(Float64(fma(y, 0.125, 0.0625) * Float64(z * t)))))) * Float64(x * cos(Float64(t * Float64(b * fma(a, 0.125, 0.0625)))))); else tmp = x; end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(N[(N[(N[(a * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(t * N[(N[(1.0 + N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2e+17], N[(N[Log[N[(1.0 + N[(Exp[N[Cos[N[(N[(y * 0.125 + 0.0625), $MachinePrecision] * N[(z * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(x * N[Cos[N[(t * N[(b * N[(a * 0.125 + 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)
\begin{array}{l}
\mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{t \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right) \leq 2 \cdot 10^{+17}:\\
\;\;\;\;\log \left(1 + \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(y, 0.125, 0.0625\right) \cdot \left(z \cdot t\right)\right)\right)\right) \cdot \left(x \cdot \cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a




Bits error versus b
| Original | 46.6 |
|---|---|
| Target | 44.9 |
| Herbie | 44.0 |
if (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) < 2e17Initial program 34.5
Simplified34.8
Applied egg-rr34.5
if 2e17 < (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) Initial program 56.6
Simplified56.2
Applied egg-rr55.8
Taylor expanded in z around 0 54.2
Taylor expanded in t around 0 51.8
Final simplification44.0
herbie shell --seed 2022170
(FPCore (x y z t a b)
:name "Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* x (cos (* (/ b 16.0) (/ t (+ (- 1.0 (* a 2.0)) (pow (* a 2.0) 2.0))))))
(* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))