Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1

Percentage Accurate: 27.5% → 31.5%
Time: 20.0s
Alternatives: 8
Speedup: 225.0×

Specification

?
\[\begin{array}{l} \\ \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) \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))))
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));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (x * cos((((((y * 2.0d0) + 1.0d0) * z) * t) / 16.0d0))) * cos((((((a * 2.0d0) + 1.0d0) * b) * t) / 16.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x * Math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * Math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
def code(x, y, z, t, a, b):
	return (x * math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0))
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 tmp = code(x, y, z, t, a, b)
	tmp = (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
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]
\begin{array}{l}

\\
\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)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 27.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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) \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))))
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));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (x * cos((((((y * 2.0d0) + 1.0d0) * z) * t) / 16.0d0))) * cos((((((a * 2.0d0) + 1.0d0) * b) * t) / 16.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x * Math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * Math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
def code(x, y, z, t, a, b):
	return (x * math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0))
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 tmp = code(x, y, z, t, a, b)
	tmp = (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
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]
\begin{array}{l}

\\
\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)
\end{array}

Alternative 1: 31.5% accurate, 0.4× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} \mathbf{if}\;t\_m \leq 2.25 \cdot 10^{-142}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t\_m}{16}\right)\right) \cdot \left(x \cdot \cos \left({\left(\sqrt[3]{\left(t\_m \cdot \left(b \cdot 0.0625\right)\right) \cdot \mathsf{fma}\left(2, a, 1\right)}\right)}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t\_m + \left(b \cdot -0.5\right) \cdot {t\_m}^{2}\right)\right)\right)\right)\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b)
 :precision binary64
 (if (<= t_m 2.25e-142)
   (*
    (cos (* (fma y 2.0 1.0) (* z (/ t_m 16.0))))
    (* x (cos (pow (cbrt (* (* t_m (* b 0.0625)) (fma 2.0 a 1.0))) 3.0))))
   (*
    x
    (cos
     (* -0.125 (* a (expm1 (* b (+ t_m (* (* b -0.5) (pow t_m 2.0)))))))))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	double tmp;
	if (t_m <= 2.25e-142) {
		tmp = cos((fma(y, 2.0, 1.0) * (z * (t_m / 16.0)))) * (x * cos(pow(cbrt(((t_m * (b * 0.0625)) * fma(2.0, a, 1.0))), 3.0)));
	} else {
		tmp = x * cos((-0.125 * (a * expm1((b * (t_m + ((b * -0.5) * pow(t_m, 2.0))))))));
	}
	return tmp;
}
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	tmp = 0.0
	if (t_m <= 2.25e-142)
		tmp = Float64(cos(Float64(fma(y, 2.0, 1.0) * Float64(z * Float64(t_m / 16.0)))) * Float64(x * cos((cbrt(Float64(Float64(t_m * Float64(b * 0.0625)) * fma(2.0, a, 1.0))) ^ 3.0))));
	else
		tmp = Float64(x * cos(Float64(-0.125 * Float64(a * expm1(Float64(b * Float64(t_m + Float64(Float64(b * -0.5) * (t_m ^ 2.0)))))))));
	end
	return tmp
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := If[LessEqual[t$95$m, 2.25e-142], N[(N[Cos[N[(N[(y * 2.0 + 1.0), $MachinePrecision] * N[(z * N[(t$95$m / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(x * N[Cos[N[Power[N[Power[N[(N[(t$95$m * N[(b * 0.0625), $MachinePrecision]), $MachinePrecision] * N[(2.0 * a + 1.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[Cos[N[(-0.125 * N[(a * N[(Exp[N[(b * N[(t$95$m + N[(N[(b * -0.5), $MachinePrecision] * N[Power[t$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
\mathbf{if}\;t\_m \leq 2.25 \cdot 10^{-142}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t\_m}{16}\right)\right) \cdot \left(x \cdot \cos \left({\left(\sqrt[3]{\left(t\_m \cdot \left(b \cdot 0.0625\right)\right) \cdot \mathsf{fma}\left(2, a, 1\right)}\right)}^{3}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t\_m + \left(b \cdot -0.5\right) \cdot {t\_m}^{2}\right)\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 2.25000000000000009e-142

    1. Initial program 33.8%

      \[\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. Simplified34.6%

      \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \left(\mathsf{fma}\left(2, a, 1\right) \cdot \left(t \cdot \frac{b}{16}\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-cube-cbrt34.6%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(t \cdot \frac{b}{16}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(t \cdot \frac{b}{16}\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(t \cdot \frac{b}{16}\right)}\right)}\right) \]
      2. pow334.6%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left({\left(\sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(t \cdot \frac{b}{16}\right)}\right)}^{3}\right)}\right) \]
      3. *-commutative34.6%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \left({\left(\sqrt[3]{\color{blue}{\left(t \cdot \frac{b}{16}\right) \cdot \mathsf{fma}\left(2, a, 1\right)}}\right)}^{3}\right)\right) \]
      4. div-inv34.6%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \left({\left(\sqrt[3]{\left(t \cdot \color{blue}{\left(b \cdot \frac{1}{16}\right)}\right) \cdot \mathsf{fma}\left(2, a, 1\right)}\right)}^{3}\right)\right) \]
      5. metadata-eval34.6%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \left({\left(\sqrt[3]{\left(t \cdot \left(b \cdot \color{blue}{0.0625}\right)\right) \cdot \mathsf{fma}\left(2, a, 1\right)}\right)}^{3}\right)\right) \]
    5. Applied egg-rr34.6%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left({\left(\sqrt[3]{\left(t \cdot \left(b \cdot 0.0625\right)\right) \cdot \mathsf{fma}\left(2, a, 1\right)}\right)}^{3}\right)}\right) \]

    if 2.25000000000000009e-142 < t

    1. Initial program 15.8%

      \[\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. Simplified16.3%

      \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in a around inf 16.3%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(-0.125 \cdot \left(a \cdot \left(b \cdot t\right)\right)\right)}\right) \]
    5. Step-by-step derivation
      1. associate-*r*16.3%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(-0.125 \cdot a\right) \cdot \left(b \cdot t\right)\right)}\right) \]
      2. *-commutative16.3%

        \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(-0.125 \cdot a\right) \cdot \color{blue}{\left(t \cdot b\right)}\right)\right) \]
    6. Simplified16.3%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(-0.125 \cdot a\right) \cdot \left(t \cdot b\right)\right)}\right) \]
    7. Taylor expanded in z around 0 17.1%

      \[\leadsto \color{blue}{x \cdot \cos \left(-0.125 \cdot \left(a \cdot \left(b \cdot t\right)\right)\right)} \]
    8. Step-by-step derivation
      1. expm1-log1p-u15.7%

        \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
      2. expm1-undefine14.7%

        \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot t\right)} - 1\right)}\right)\right) \]
    9. Applied egg-rr14.7%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot t\right)} - 1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. expm1-define15.7%

        \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
    11. Simplified15.7%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
    12. Taylor expanded in b around 0 20.8%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(\color{blue}{b \cdot \left(t + -0.5 \cdot \left(b \cdot {t}^{2}\right)\right)}\right)\right)\right) \]
    13. Step-by-step derivation
      1. associate-*r*20.8%

        \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t + \color{blue}{\left(-0.5 \cdot b\right) \cdot {t}^{2}}\right)\right)\right)\right) \]
    14. Simplified20.8%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(\color{blue}{b \cdot \left(t + \left(-0.5 \cdot b\right) \cdot {t}^{2}\right)}\right)\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification30.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 2.25 \cdot 10^{-142}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \frac{t}{16}\right)\right) \cdot \left(x \cdot \cos \left({\left(\sqrt[3]{\left(t \cdot \left(b \cdot 0.0625\right)\right) \cdot \mathsf{fma}\left(2, a, 1\right)}\right)}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t + \left(b \cdot -0.5\right) \cdot {t}^{2}\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 30.9% accurate, 0.7× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(t\_m \cdot \left(b + -0.5 \cdot \left(t\_m \cdot {b}^{2}\right)\right)\right)\right)\right) \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b)
 :precision binary64
 (*
  x
  (cos (* -0.125 (* a (expm1 (* t_m (+ b (* -0.5 (* t_m (pow b 2.0)))))))))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x * cos((-0.125 * (a * expm1((t_m * (b + (-0.5 * (t_m * pow(b, 2.0)))))))));
}
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x * Math.cos((-0.125 * (a * Math.expm1((t_m * (b + (-0.5 * (t_m * Math.pow(b, 2.0)))))))));
}
t_m = math.fabs(t)
def code(x, y, z, t_m, a, b):
	return x * math.cos((-0.125 * (a * math.expm1((t_m * (b + (-0.5 * (t_m * math.pow(b, 2.0)))))))))
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return Float64(x * cos(Float64(-0.125 * Float64(a * expm1(Float64(t_m * Float64(b + Float64(-0.5 * Float64(t_m * (b ^ 2.0))))))))))
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := N[(x * N[Cos[N[(-0.125 * N[(a * N[(Exp[N[(t$95$m * N[(b + N[(-0.5 * N[(t$95$m * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(t\_m \cdot \left(b + -0.5 \cdot \left(t\_m \cdot {b}^{2}\right)\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Simplified28.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in a around inf 28.3%

    \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(-0.125 \cdot \left(a \cdot \left(b \cdot t\right)\right)\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r*28.3%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(-0.125 \cdot a\right) \cdot \left(b \cdot t\right)\right)}\right) \]
    2. *-commutative28.3%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(-0.125 \cdot a\right) \cdot \color{blue}{\left(t \cdot b\right)}\right)\right) \]
  6. Simplified28.3%

    \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(-0.125 \cdot a\right) \cdot \left(t \cdot b\right)\right)}\right) \]
  7. Taylor expanded in z around 0 28.8%

    \[\leadsto \color{blue}{x \cdot \cos \left(-0.125 \cdot \left(a \cdot \left(b \cdot t\right)\right)\right)} \]
  8. Step-by-step derivation
    1. expm1-log1p-u27.2%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
    2. expm1-undefine26.5%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot t\right)} - 1\right)}\right)\right) \]
  9. Applied egg-rr26.5%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot t\right)} - 1\right)}\right)\right) \]
  10. Step-by-step derivation
    1. expm1-define27.2%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
  11. Simplified27.2%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
  12. Taylor expanded in t around 0 30.6%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(\color{blue}{t \cdot \left(b + -0.5 \cdot \left({b}^{2} \cdot t\right)\right)}\right)\right)\right) \]
  13. Final simplification30.6%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(t \cdot \left(b + -0.5 \cdot \left(t \cdot {b}^{2}\right)\right)\right)\right)\right) \]
  14. Add Preprocessing

Alternative 3: 31.1% accurate, 0.7× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t\_m + \left(b \cdot -0.5\right) \cdot {t\_m}^{2}\right)\right)\right)\right) \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b)
 :precision binary64
 (*
  x
  (cos (* -0.125 (* a (expm1 (* b (+ t_m (* (* b -0.5) (pow t_m 2.0))))))))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x * cos((-0.125 * (a * expm1((b * (t_m + ((b * -0.5) * pow(t_m, 2.0))))))));
}
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x * Math.cos((-0.125 * (a * Math.expm1((b * (t_m + ((b * -0.5) * Math.pow(t_m, 2.0))))))));
}
t_m = math.fabs(t)
def code(x, y, z, t_m, a, b):
	return x * math.cos((-0.125 * (a * math.expm1((b * (t_m + ((b * -0.5) * math.pow(t_m, 2.0))))))))
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return Float64(x * cos(Float64(-0.125 * Float64(a * expm1(Float64(b * Float64(t_m + Float64(Float64(b * -0.5) * (t_m ^ 2.0)))))))))
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := N[(x * N[Cos[N[(-0.125 * N[(a * N[(Exp[N[(b * N[(t$95$m + N[(N[(b * -0.5), $MachinePrecision] * N[Power[t$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t\_m + \left(b \cdot -0.5\right) \cdot {t\_m}^{2}\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Simplified28.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in a around inf 28.3%

    \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(-0.125 \cdot \left(a \cdot \left(b \cdot t\right)\right)\right)}\right) \]
  5. Step-by-step derivation
    1. associate-*r*28.3%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(-0.125 \cdot a\right) \cdot \left(b \cdot t\right)\right)}\right) \]
    2. *-commutative28.3%

      \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(-0.125 \cdot a\right) \cdot \color{blue}{\left(t \cdot b\right)}\right)\right) \]
  6. Simplified28.3%

    \[\leadsto \cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \color{blue}{\left(\left(-0.125 \cdot a\right) \cdot \left(t \cdot b\right)\right)}\right) \]
  7. Taylor expanded in z around 0 28.8%

    \[\leadsto \color{blue}{x \cdot \cos \left(-0.125 \cdot \left(a \cdot \left(b \cdot t\right)\right)\right)} \]
  8. Step-by-step derivation
    1. expm1-log1p-u27.2%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
    2. expm1-undefine26.5%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot t\right)} - 1\right)}\right)\right) \]
  9. Applied egg-rr26.5%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(b \cdot t\right)} - 1\right)}\right)\right) \]
  10. Step-by-step derivation
    1. expm1-define27.2%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
  11. Simplified27.2%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b \cdot t\right)\right)}\right)\right) \]
  12. Taylor expanded in b around 0 30.8%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(\color{blue}{b \cdot \left(t + -0.5 \cdot \left(b \cdot {t}^{2}\right)\right)}\right)\right)\right) \]
  13. Step-by-step derivation
    1. associate-*r*30.8%

      \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t + \color{blue}{\left(-0.5 \cdot b\right) \cdot {t}^{2}}\right)\right)\right)\right) \]
  14. Simplified30.8%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(\color{blue}{b \cdot \left(t + \left(-0.5 \cdot b\right) \cdot {t}^{2}\right)}\right)\right)\right) \]
  15. Final simplification30.8%

    \[\leadsto x \cdot \cos \left(-0.125 \cdot \left(a \cdot \mathsf{expm1}\left(b \cdot \left(t + \left(b \cdot -0.5\right) \cdot {t}^{2}\right)\right)\right)\right) \]
  16. Add Preprocessing

Alternative 4: 29.9% accurate, 0.7× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \cdot \left(\sqrt[3]{{\left(1 + \cos \left(t\_m \cdot \left(b \cdot -0.0625\right)\right)\right)}^{3}} + -1\right) \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b)
 :precision binary64
 (* x (+ (cbrt (pow (+ 1.0 (cos (* t_m (* b -0.0625)))) 3.0)) -1.0)))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x * (cbrt(pow((1.0 + cos((t_m * (b * -0.0625)))), 3.0)) + -1.0);
}
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x * (Math.cbrt(Math.pow((1.0 + Math.cos((t_m * (b * -0.0625)))), 3.0)) + -1.0);
}
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return Float64(x * Float64(cbrt((Float64(1.0 + cos(Float64(t_m * Float64(b * -0.0625)))) ^ 3.0)) + -1.0))
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := N[(x * N[(N[Power[N[Power[N[(1.0 + N[Cos[N[(t$95$m * N[(b * -0.0625), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
x \cdot \left(\sqrt[3]{{\left(1 + \cos \left(t\_m \cdot \left(b \cdot -0.0625\right)\right)\right)}^{3}} + -1\right)
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Simplified28.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 29.1%

    \[\leadsto \color{blue}{x \cdot \cos \left(0.0625 \cdot \left(b \cdot \left(t \cdot \left(-2 \cdot a - 1\right)\right)\right)\right)} \]
  5. Taylor expanded in a around 0 30.2%

    \[\leadsto \color{blue}{x \cdot \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)} \]
  6. Step-by-step derivation
    1. *-commutative30.2%

      \[\leadsto \color{blue}{\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right) \cdot x} \]
    2. associate-*r*30.2%

      \[\leadsto \cos \color{blue}{\left(\left(-0.0625 \cdot b\right) \cdot t\right)} \cdot x \]
  7. Simplified30.2%

    \[\leadsto \color{blue}{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right) \cdot x} \]
  8. Step-by-step derivation
    1. expm1-log1p-u30.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)\right)\right)} \cdot x \]
    2. expm1-undefine30.2%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)\right)} - 1\right)} \cdot x \]
    3. associate-*l*30.2%

      \[\leadsto \left(e^{\mathsf{log1p}\left(\cos \color{blue}{\left(-0.0625 \cdot \left(b \cdot t\right)\right)}\right)} - 1\right) \cdot x \]
  9. Applied egg-rr30.2%

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)} - 1\right)} \cdot x \]
  10. Step-by-step derivation
    1. add-cbrt-cube30.2%

      \[\leadsto \left(\color{blue}{\sqrt[3]{\left(e^{\mathsf{log1p}\left(\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)}\right) \cdot e^{\mathsf{log1p}\left(\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)}}} - 1\right) \cdot x \]
    2. pow330.2%

      \[\leadsto \left(\sqrt[3]{\color{blue}{{\left(e^{\mathsf{log1p}\left(\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)}\right)}^{3}}} - 1\right) \cdot x \]
    3. log1p-undefine30.2%

      \[\leadsto \left(\sqrt[3]{{\left(e^{\color{blue}{\log \left(1 + \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)}}\right)}^{3}} - 1\right) \cdot x \]
    4. rem-exp-log30.2%

      \[\leadsto \left(\sqrt[3]{{\color{blue}{\left(1 + \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)}}^{3}} - 1\right) \cdot x \]
    5. associate-*r*30.2%

      \[\leadsto \left(\sqrt[3]{{\left(1 + \cos \color{blue}{\left(\left(-0.0625 \cdot b\right) \cdot t\right)}\right)}^{3}} - 1\right) \cdot x \]
  11. Applied egg-rr30.2%

    \[\leadsto \left(\color{blue}{\sqrt[3]{{\left(1 + \cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)\right)}^{3}}} - 1\right) \cdot x \]
  12. Final simplification30.2%

    \[\leadsto x \cdot \left(\sqrt[3]{{\left(1 + \cos \left(t \cdot \left(b \cdot -0.0625\right)\right)\right)}^{3}} + -1\right) \]
  13. Add Preprocessing

Alternative 5: 29.9% accurate, 0.7× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \cdot {\left(\sqrt[3]{\cos \left(-0.0625 \cdot \left(t\_m \cdot b\right)\right)}\right)}^{3} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b)
 :precision binary64
 (* x (pow (cbrt (cos (* -0.0625 (* t_m b)))) 3.0)))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x * pow(cbrt(cos((-0.0625 * (t_m * b)))), 3.0);
}
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x * Math.pow(Math.cbrt(Math.cos((-0.0625 * (t_m * b)))), 3.0);
}
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return Float64(x * (cbrt(cos(Float64(-0.0625 * Float64(t_m * b)))) ^ 3.0))
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := N[(x * N[Power[N[Power[N[Cos[N[(-0.0625 * N[(t$95$m * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
x \cdot {\left(\sqrt[3]{\cos \left(-0.0625 \cdot \left(t\_m \cdot b\right)\right)}\right)}^{3}
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Simplified28.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 29.1%

    \[\leadsto \color{blue}{x \cdot \cos \left(0.0625 \cdot \left(b \cdot \left(t \cdot \left(-2 \cdot a - 1\right)\right)\right)\right)} \]
  5. Taylor expanded in a around 0 30.2%

    \[\leadsto \color{blue}{x \cdot \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)} \]
  6. Step-by-step derivation
    1. *-commutative30.2%

      \[\leadsto \color{blue}{\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right) \cdot x} \]
    2. associate-*r*30.2%

      \[\leadsto \cos \color{blue}{\left(\left(-0.0625 \cdot b\right) \cdot t\right)} \cdot x \]
  7. Simplified30.2%

    \[\leadsto \color{blue}{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right) \cdot x} \]
  8. Step-by-step derivation
    1. add-cube-cbrt30.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)} \cdot \sqrt[3]{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)}\right) \cdot \sqrt[3]{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)}\right)} \cdot x \]
    2. pow330.2%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)}\right)}^{3}} \cdot x \]
    3. associate-*l*30.2%

      \[\leadsto {\left(\sqrt[3]{\cos \color{blue}{\left(-0.0625 \cdot \left(b \cdot t\right)\right)}}\right)}^{3} \cdot x \]
  9. Applied egg-rr30.2%

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)}\right)}^{3}} \cdot x \]
  10. Final simplification30.2%

    \[\leadsto x \cdot {\left(\sqrt[3]{\cos \left(-0.0625 \cdot \left(t \cdot b\right)\right)}\right)}^{3} \]
  11. Add Preprocessing

Alternative 6: 29.9% accurate, 2.0× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \cdot \left(\left(1 + \cos \left(t\_m \cdot \left(b \cdot -0.0625\right)\right)\right) + -1\right) \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b)
 :precision binary64
 (* x (+ (+ 1.0 (cos (* t_m (* b -0.0625)))) -1.0)))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x * ((1.0 + cos((t_m * (b * -0.0625)))) + -1.0);
}
t_m = abs(t)
real(8) function code(x, y, z, t_m, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * ((1.0d0 + cos((t_m * (b * (-0.0625d0))))) + (-1.0d0))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x * ((1.0 + Math.cos((t_m * (b * -0.0625)))) + -1.0);
}
t_m = math.fabs(t)
def code(x, y, z, t_m, a, b):
	return x * ((1.0 + math.cos((t_m * (b * -0.0625)))) + -1.0)
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return Float64(x * Float64(Float64(1.0 + cos(Float64(t_m * Float64(b * -0.0625)))) + -1.0))
end
t_m = abs(t);
function tmp = code(x, y, z, t_m, a, b)
	tmp = x * ((1.0 + cos((t_m * (b * -0.0625)))) + -1.0);
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := N[(x * N[(N[(1.0 + N[Cos[N[(t$95$m * N[(b * -0.0625), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
x \cdot \left(\left(1 + \cos \left(t\_m \cdot \left(b \cdot -0.0625\right)\right)\right) + -1\right)
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Simplified28.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 29.1%

    \[\leadsto \color{blue}{x \cdot \cos \left(0.0625 \cdot \left(b \cdot \left(t \cdot \left(-2 \cdot a - 1\right)\right)\right)\right)} \]
  5. Taylor expanded in a around 0 30.2%

    \[\leadsto \color{blue}{x \cdot \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)} \]
  6. Step-by-step derivation
    1. *-commutative30.2%

      \[\leadsto \color{blue}{\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right) \cdot x} \]
    2. associate-*r*30.2%

      \[\leadsto \cos \color{blue}{\left(\left(-0.0625 \cdot b\right) \cdot t\right)} \cdot x \]
  7. Simplified30.2%

    \[\leadsto \color{blue}{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right) \cdot x} \]
  8. Step-by-step derivation
    1. expm1-log1p-u30.2%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)\right)\right)} \cdot x \]
    2. expm1-undefine30.2%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)\right)} - 1\right)} \cdot x \]
    3. associate-*l*30.2%

      \[\leadsto \left(e^{\mathsf{log1p}\left(\cos \color{blue}{\left(-0.0625 \cdot \left(b \cdot t\right)\right)}\right)} - 1\right) \cdot x \]
  9. Applied egg-rr30.2%

    \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)} - 1\right)} \cdot x \]
  10. Step-by-step derivation
    1. log1p-undefine30.2%

      \[\leadsto \left(e^{\color{blue}{\log \left(1 + \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)}} - 1\right) \cdot x \]
    2. rem-exp-log30.2%

      \[\leadsto \left(\color{blue}{\left(1 + \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)\right)} - 1\right) \cdot x \]
    3. associate-*r*30.2%

      \[\leadsto \left(\left(1 + \cos \color{blue}{\left(\left(-0.0625 \cdot b\right) \cdot t\right)}\right) - 1\right) \cdot x \]
  11. Applied egg-rr30.2%

    \[\leadsto \left(\color{blue}{\left(1 + \cos \left(\left(-0.0625 \cdot b\right) \cdot t\right)\right)} - 1\right) \cdot x \]
  12. Final simplification30.2%

    \[\leadsto x \cdot \left(\left(1 + \cos \left(t \cdot \left(b \cdot -0.0625\right)\right)\right) + -1\right) \]
  13. Add Preprocessing

Alternative 7: 29.9% accurate, 2.1× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \cdot \cos \left(t\_m \cdot \left(b \cdot -0.0625\right)\right) \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b) :precision binary64 (* x (cos (* t_m (* b -0.0625)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x * cos((t_m * (b * -0.0625)));
}
t_m = abs(t)
real(8) function code(x, y, z, t_m, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * cos((t_m * (b * (-0.0625d0))))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x * Math.cos((t_m * (b * -0.0625)));
}
t_m = math.fabs(t)
def code(x, y, z, t_m, a, b):
	return x * math.cos((t_m * (b * -0.0625)))
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return Float64(x * cos(Float64(t_m * Float64(b * -0.0625))))
end
t_m = abs(t);
function tmp = code(x, y, z, t_m, a, b)
	tmp = x * cos((t_m * (b * -0.0625)));
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := N[(x * N[Cos[N[(t$95$m * N[(b * -0.0625), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
x \cdot \cos \left(t\_m \cdot \left(b \cdot -0.0625\right)\right)
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Simplified28.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(y, 2, 1\right) \cdot \left(z \cdot \left(t \cdot 0.0625\right)\right)\right) \cdot \left(x \cdot \cos \left(\left(b \cdot 0.0625\right) \cdot \left(t \cdot \mathsf{fma}\left(a, -2, -1\right)\right)\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 29.1%

    \[\leadsto \color{blue}{x \cdot \cos \left(0.0625 \cdot \left(b \cdot \left(t \cdot \left(-2 \cdot a - 1\right)\right)\right)\right)} \]
  5. Taylor expanded in a around 0 30.2%

    \[\leadsto \color{blue}{x \cdot \cos \left(-0.0625 \cdot \left(b \cdot t\right)\right)} \]
  6. Step-by-step derivation
    1. *-commutative30.2%

      \[\leadsto \color{blue}{\cos \left(-0.0625 \cdot \left(b \cdot t\right)\right) \cdot x} \]
    2. associate-*r*30.2%

      \[\leadsto \cos \color{blue}{\left(\left(-0.0625 \cdot b\right) \cdot t\right)} \cdot x \]
  7. Simplified30.2%

    \[\leadsto \color{blue}{\cos \left(\left(-0.0625 \cdot b\right) \cdot t\right) \cdot x} \]
  8. Final simplification30.2%

    \[\leadsto x \cdot \cos \left(t \cdot \left(b \cdot -0.0625\right)\right) \]
  9. Add Preprocessing

Alternative 8: 31.0% accurate, 225.0× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ x \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m a b) :precision binary64 x)
t_m = fabs(t);
double code(double x, double y, double z, double t_m, double a, double b) {
	return x;
}
t_m = abs(t)
real(8) function code(x, y, z, t_m, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m, double a, double b) {
	return x;
}
t_m = math.fabs(t)
def code(x, y, z, t_m, a, b):
	return x
t_m = abs(t)
function code(x, y, z, t_m, a, b)
	return x
end
t_m = abs(t);
function tmp = code(x, y, z, t_m, a, b)
	tmp = x;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_, a_, b_] := x
\begin{array}{l}
t_m = \left|t\right|

\\
x
\end{array}
Derivation
  1. Initial program 27.8%

    \[\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. Step-by-step derivation
    1. associate-*l*27.8%

      \[\leadsto \color{blue}{x \cdot \left(\cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)} \]
    2. *-commutative27.8%

      \[\leadsto x \cdot \color{blue}{\left(\cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right)} \]
    3. *-commutative27.8%

      \[\leadsto x \cdot \color{blue}{\left(\cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)} \]
    4. associate-/l*27.8%

      \[\leadsto x \cdot \left(\cos \color{blue}{\left(\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot \frac{t}{16}\right)} \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right) \]
    5. fma-define27.8%

      \[\leadsto x \cdot \left(\cos \left(\left(\color{blue}{\mathsf{fma}\left(y, 2, 1\right)} \cdot z\right) \cdot \frac{t}{16}\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right) \]
    6. associate-/l*27.8%

      \[\leadsto x \cdot \left(\cos \left(\left(\mathsf{fma}\left(y, 2, 1\right) \cdot z\right) \cdot \frac{t}{16}\right) \cdot \cos \color{blue}{\left(\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot \frac{t}{16}\right)}\right) \]
    7. fma-define27.8%

      \[\leadsto x \cdot \left(\cos \left(\left(\mathsf{fma}\left(y, 2, 1\right) \cdot z\right) \cdot \frac{t}{16}\right) \cdot \cos \left(\left(\color{blue}{\mathsf{fma}\left(a, 2, 1\right)} \cdot b\right) \cdot \frac{t}{16}\right)\right) \]
  3. Simplified27.8%

    \[\leadsto \color{blue}{x \cdot \left(\cos \left(\left(\mathsf{fma}\left(y, 2, 1\right) \cdot z\right) \cdot \frac{t}{16}\right) \cdot \cos \left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot \frac{t}{16}\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in t around 0 29.6%

    \[\leadsto \color{blue}{x} \]
  6. Add Preprocessing

Developer Target 1: 30.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \cos \left(\frac{b}{16} \cdot \frac{t}{\left(1 - a \cdot 2\right) + {\left(a \cdot 2\right)}^{2}}\right) \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (* x (cos (* (/ b 16.0) (/ t (+ (- 1.0 (* a 2.0)) (pow (* a 2.0) 2.0)))))))
double code(double x, double y, double z, double t, double a, double b) {
	return x * cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + pow((a * 2.0), 2.0)))));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * cos(((b / 16.0d0) * (t / ((1.0d0 - (a * 2.0d0)) + ((a * 2.0d0) ** 2.0d0)))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * Math.cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + Math.pow((a * 2.0), 2.0)))));
}
def code(x, y, z, t, a, b):
	return x * math.cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + math.pow((a * 2.0), 2.0)))))
function code(x, y, z, t, a, b)
	return Float64(x * cos(Float64(Float64(b / 16.0) * Float64(t / Float64(Float64(1.0 - Float64(a * 2.0)) + (Float64(a * 2.0) ^ 2.0))))))
end
function tmp = code(x, y, z, t, a, b)
	tmp = x * cos(((b / 16.0) * (t / ((1.0 - (a * 2.0)) + ((a * 2.0) ^ 2.0)))));
end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Cos[N[(N[(b / 16.0), $MachinePrecision] * N[(t / N[(N[(1.0 - N[(a * 2.0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(a * 2.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \cos \left(\frac{b}{16} \cdot \frac{t}{\left(1 - a \cdot 2\right) + {\left(a \cdot 2\right)}^{2}}\right)
\end{array}

Reproduce

?
herbie shell --seed 2024128 
(FPCore (x y z t a b)
  :name "Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1"
  :precision binary64

  :alt
  (! :herbie-platform default (* x (cos (* (/ b 16) (/ t (+ (- 1 (* a 2)) (pow (* a 2) 2)))))))

  (* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))