?

Average Accuracy: 28.1% → 32.5%
Time: 24.7s
Precision: binary64
Cost: 54148

?

\[\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 10^{+272}:\\ \;\;\;\;\left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + y \cdot 0.125\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)} \cdot \sqrt[3]{t}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \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)))
      1e+272)
   (*
    (* x (cos (* (* z t) (+ 0.0625 (* y 0.125)))))
    (cos (pow (* (cbrt (* b (fma a 0.125 0.0625))) (cbrt t)) 3.0)))
   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))) <= 1e+272) {
		tmp = (x * cos(((z * t) * (0.0625 + (y * 0.125))))) * cos(pow((cbrt((b * fma(a, 0.125, 0.0625))) * cbrt(t)), 3.0));
	} 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))) <= 1e+272)
		tmp = Float64(Float64(x * cos(Float64(Float64(z * t) * Float64(0.0625 + Float64(y * 0.125))))) * cos((Float64(cbrt(Float64(b * fma(a, 0.125, 0.0625))) * cbrt(t)) ^ 3.0)));
	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], 1e+272], N[(N[(x * N[Cos[N[(N[(z * t), $MachinePrecision] * N[(0.0625 + N[(y * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[Power[N[(N[Power[N[(b * N[(a * 0.125 + 0.0625), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[t, 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $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 10^{+272}:\\
\;\;\;\;\left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + y \cdot 0.125\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)} \cdot \sqrt[3]{t}\right)}^{3}\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}

Error?

Target

Original28.1%
Target31.0%
Herbie32.5%
\[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))) < 1.0000000000000001e272

    1. Initial program 47.3%

      \[\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. Simplified47.2%

      \[\leadsto \color{blue}{\left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left(\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)\right)} \]
      Proof

      [Start]47.3

      \[ \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) \]
    3. Applied egg-rr47.1%

      \[\leadsto \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \color{blue}{\left({\left(\sqrt[3]{t \cdot \left(b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)\right)}\right)}^{3}\right)} \]
      Proof

      [Start]47.2

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left(\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)\right) \]

      add-cube-cbrt [=>]47.0

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \color{blue}{\left(\left(\sqrt[3]{\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)} \cdot \sqrt[3]{\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)}\right) \cdot \sqrt[3]{\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)}\right)} \]

      pow3 [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \color{blue}{\left({\left(\sqrt[3]{\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)}\right)}^{3}\right)} \]

      associate-*l* [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{\color{blue}{t \cdot \left(b \cdot \left(0.0625 + 0.125 \cdot a\right)\right)}}\right)}^{3}\right) \]

      +-commutative [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{t \cdot \left(b \cdot \color{blue}{\left(0.125 \cdot a + 0.0625\right)}\right)}\right)}^{3}\right) \]

      fma-def [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{t \cdot \left(b \cdot \color{blue}{\mathsf{fma}\left(0.125, a, 0.0625\right)}\right)}\right)}^{3}\right) \]
    4. Applied egg-rr47.1%

      \[\leadsto \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\color{blue}{\left(\sqrt[3]{b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)} \cdot \sqrt[3]{t}\right)}}^{3}\right) \]
      Proof

      [Start]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{t \cdot \left(b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)\right)}\right)}^{3}\right) \]

      cbrt-prod [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)}\right)}}^{3}\right) \]

      *-commutative [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\color{blue}{\left(\sqrt[3]{b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)} \cdot \sqrt[3]{t}\right)}}^{3}\right) \]
    5. Simplified47.1%

      \[\leadsto \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\color{blue}{\left(\sqrt[3]{b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)} \cdot \sqrt[3]{t}\right)}}^{3}\right) \]
      Proof

      [Start]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)} \cdot \sqrt[3]{t}\right)}^{3}\right) \]

      fma-udef [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \color{blue}{\left(0.125 \cdot a + 0.0625\right)}} \cdot \sqrt[3]{t}\right)}^{3}\right) \]

      *-commutative [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \left(\color{blue}{a \cdot 0.125} + 0.0625\right)} \cdot \sqrt[3]{t}\right)}^{3}\right) \]

      fma-def [=>]47.1

      \[ \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \color{blue}{\mathsf{fma}\left(a, 0.125, 0.0625\right)}} \cdot \sqrt[3]{t}\right)}^{3}\right) \]

    if 1.0000000000000001e272 < (*.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 2.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. Simplified4.0%

      \[\leadsto \color{blue}{\left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \cos \left(\left(t \cdot b\right) \cdot \left(0.0625 + 0.125 \cdot a\right)\right)} \]
      Proof

      [Start]2.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) \]
    3. Taylor expanded in t around 0 7.3%

      \[\leadsto \left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + 0.125 \cdot y\right)\right)\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in z around 0 12.5%

      \[\leadsto \color{blue}{x} \cdot 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification32.5%

    \[\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 10^{+272}:\\ \;\;\;\;\left(x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + y \cdot 0.125\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)} \cdot \sqrt[3]{t}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternatives

Alternative 1
Accuracy32.1%
Cost47492
\[\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 5 \cdot 10^{+243}:\\ \;\;\;\;\left(x \cdot \cos \left(t \cdot \left(z \cdot 0.0625\right)\right)\right) \cdot \cos \left({\left(\sqrt[3]{t \cdot \left(b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)\right)}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy31.3%
Cost64
\[x \]

Error

Reproduce?

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