Average Error: 46.0 → 43.1
Time: 16.1s
Precision: binary64
\[\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 4.792666382654937 \cdot 10^{+276}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(t \cdot \left(z \cdot \mathsf{fma}\left(y, 0.125, 0.0625\right)\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 \cdot \left(e^{\log 2} + -1\right)\\ \end{array} \]
(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)))
      4.792666382654937e+276)
   (*
    (expm1 (log1p (cos (* t (* z (fma y 0.125 0.0625))))))
    (* x (cos (* t (* b (fma a 0.125 0.0625))))))
   (* x (+ (exp (log 2.0)) -1.0))))
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))) <= 4.792666382654937e+276) {
		tmp = expm1(log1p(cos((t * (z * fma(y, 0.125, 0.0625)))))) * (x * cos((t * (b * fma(a, 0.125, 0.0625)))));
	} else {
		tmp = x * (exp(log(2.0)) + -1.0);
	}
	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))) <= 4.792666382654937e+276)
		tmp = Float64(expm1(log1p(cos(Float64(t * Float64(z * fma(y, 0.125, 0.0625)))))) * Float64(x * cos(Float64(t * Float64(b * fma(a, 0.125, 0.0625))))));
	else
		tmp = Float64(x * Float64(exp(log(2.0)) + -1.0));
	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], 4.792666382654937e+276], N[(N[(Exp[N[Log[1 + N[Cos[N[(t * N[(z * N[(y * 0.125 + 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] * N[(x * N[Cos[N[(t * N[(b * N[(a * 0.125 + 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Exp[N[Log[2.0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\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 4.792666382654937 \cdot 10^{+276}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(t \cdot \left(z \cdot \mathsf{fma}\left(y, 0.125, 0.0625\right)\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 \cdot \left(e^{\log 2} + -1\right)\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original46.0
Target44.2
Herbie43.1
\[x \cdot \cos \left(\frac{b}{16} \cdot \frac{t}{\left(1 - a \cdot 2\right) + {\left(a \cdot 2\right)}^{2}}\right) \]

Derivation

  1. Split input into 2 regimes
  2. 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))) < 4.7926663826549375e276

    1. Initial program 33.4

      \[\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) \]
    2. Simplified33.7

      \[\leadsto \color{blue}{\cos \left(z \cdot \left(t \cdot \mathsf{fma}\left(y, 0.125, 0.0625\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)} \]
    3. Applied egg-rr33.4

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(t \cdot \left(\mathsf{fma}\left(y, 0.125, 0.0625\right) \cdot z\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) \]

    if 4.7926663826549375e276 < (*.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)))

    1. Initial program 63.0

      \[\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) \]
    2. Simplified62.3

      \[\leadsto \color{blue}{\cos \left(z \cdot \left(t \cdot \mathsf{fma}\left(y, 0.125, 0.0625\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)} \]
    3. Applied egg-rr61.7

      \[\leadsto \cos \left(z \cdot \left(t \cdot \mathsf{fma}\left(y, 0.125, 0.0625\right)\right)\right) \cdot \left(x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(a, 0.125, 0.0625\right) \cdot \left(t \cdot b\right)\right)\right)} - 1\right)}\right) \]
    4. Taylor expanded in y around 0 60.6

      \[\leadsto \color{blue}{\cos \left(0.0625 \cdot \left(t \cdot z\right)\right)} \cdot \left(x \cdot \left(e^{\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(a, 0.125, 0.0625\right) \cdot \left(t \cdot b\right)\right)\right)} - 1\right)\right) \]
    5. Simplified60.6

      \[\leadsto \color{blue}{\cos \left(z \cdot \left(t \cdot 0.0625\right)\right)} \cdot \left(x \cdot \left(e^{\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(a, 0.125, 0.0625\right) \cdot \left(t \cdot b\right)\right)\right)} - 1\right)\right) \]
    6. Taylor expanded in z around 0 59.4

      \[\leadsto \color{blue}{1} \cdot \left(x \cdot \left(e^{\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(a, 0.125, 0.0625\right) \cdot \left(t \cdot b\right)\right)\right)} - 1\right)\right) \]
    7. Taylor expanded in t around 0 56.3

      \[\leadsto 1 \cdot \left(x \cdot \left(e^{\color{blue}{\log 2}} - 1\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.1

    \[\leadsto \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 4.792666382654937 \cdot 10^{+276}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(t \cdot \left(z \cdot \mathsf{fma}\left(y, 0.125, 0.0625\right)\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 \cdot \left(e^{\log 2} + -1\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022150 
(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))))