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

Percentage Accurate: 27.8% → 32.3%
Time: 30.9s
Alternatives: 5
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 5 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.8% 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: 32.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \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^{+286}:\\ \;\;\;\;x \cdot \left(\cos \left(\left(z \cdot \mathsf{fma}\left(y, 2, 1\right)\right) \cdot \frac{t}{16}\right) \cdot \cos \left({\left(\frac{1}{\sqrt[3]{\frac{\frac{\frac{16}{t}}{b}}{\mathsf{fma}\left(2, a, 1\right)}}}\right)}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(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)))
      5e+286)
   (*
    x
    (*
     (cos (* (* z (fma y 2.0 1.0)) (/ t 16.0)))
     (cos (pow (/ 1.0 (cbrt (/ (/ (/ 16.0 t) b) (fma 2.0 a 1.0)))) 3.0))))
   x))
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))) <= 5e+286) {
		tmp = x * (cos(((z * fma(y, 2.0, 1.0)) * (t / 16.0))) * cos(pow((1.0 / cbrt((((16.0 / t) / b) / fma(2.0, a, 1.0)))), 3.0)));
	} else {
		tmp = x;
	}
	return tmp;
}
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))) <= 5e+286)
		tmp = Float64(x * Float64(cos(Float64(Float64(z * fma(y, 2.0, 1.0)) * Float64(t / 16.0))) * cos((Float64(1.0 / cbrt(Float64(Float64(Float64(16.0 / t) / b) / fma(2.0, a, 1.0)))) ^ 3.0))));
	else
		tmp = x;
	end
	return tmp
end
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], 5e+286], N[(x * N[(N[Cos[N[(N[(z * N[(y * 2.0 + 1.0), $MachinePrecision]), $MachinePrecision] * N[(t / 16.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[(1.0 / N[Power[N[(N[(N[(16.0 / t), $MachinePrecision] / b), $MachinePrecision] / N[(2.0 * a + 1.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\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^{+286}:\\
\;\;\;\;x \cdot \left(\cos \left(\left(z \cdot \mathsf{fma}\left(y, 2, 1\right)\right) \cdot \frac{t}{16}\right) \cdot \cos \left({\left(\frac{1}{\sqrt[3]{\frac{\frac{\frac{16}{t}}{b}}{\mathsf{fma}\left(2, a, 1\right)}}}\right)}^{3}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y #s(literal 2 binary64)) #s(literal 1 binary64)) z) t) #s(literal 16 binary64)))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a #s(literal 2 binary64)) #s(literal 1 binary64)) b) t) #s(literal 16 binary64)))) < 5.0000000000000004e286

    1. Initial program 48.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. Simplified48.4%

      \[\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)} \]
    3. Add Preprocessing
    4. Applied egg-rr48.1%

      \[\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(\sqrt[3]{b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \left(t \cdot 0.0625\right)\right)}\right)}^{3}\right)}\right) \]
    5. Step-by-step derivation
      1. metadata-eval48.1%

        \[\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(\sqrt[3]{b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \left(t \cdot \color{blue}{\frac{1}{16}}\right)\right)}\right)}^{3}\right)\right) \]
      2. div-inv48.1%

        \[\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(\sqrt[3]{b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \color{blue}{\frac{t}{16}}\right)}\right)}^{3}\right)\right) \]
      3. associate-*r*48.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(\sqrt[3]{\color{blue}{\left(b \cdot \mathsf{fma}\left(a, 2, 1\right)\right) \cdot \frac{t}{16}}}\right)}^{3}\right)\right) \]
      4. *-commutative48.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(\sqrt[3]{\color{blue}{\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right)} \cdot \frac{t}{16}}\right)}^{3}\right)\right) \]
      5. fma-define48.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(\sqrt[3]{\left(\color{blue}{\left(a \cdot 2 + 1\right)} \cdot b\right) \cdot \frac{t}{16}}\right)}^{3}\right)\right) \]
      6. associate-/l*48.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(\sqrt[3]{\color{blue}{\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}}}\right)}^{3}\right)\right) \]
      7. fma-define48.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(\sqrt[3]{\frac{\left(\color{blue}{\mathsf{fma}\left(a, 2, 1\right)} \cdot b\right) \cdot t}{16}}\right)}^{3}\right)\right) \]
      8. associate-*r*48.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(\sqrt[3]{\frac{\color{blue}{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}}{16}}\right)}^{3}\right)\right) \]
      9. clear-num48.9%

        \[\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(\sqrt[3]{\color{blue}{\frac{1}{\frac{16}{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}}}}\right)}^{3}\right)\right) \]
      10. cbrt-div48.6%

        \[\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({\color{blue}{\left(\frac{\sqrt[3]{1}}{\sqrt[3]{\frac{16}{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}}}\right)}}^{3}\right)\right) \]
      11. metadata-eval48.6%

        \[\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(\frac{\color{blue}{1}}{\sqrt[3]{\frac{16}{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}}}\right)}^{3}\right)\right) \]
      12. associate-*r*49.0%

        \[\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(\frac{1}{\sqrt[3]{\frac{16}{\color{blue}{\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot t}}}}\right)}^{3}\right)\right) \]
      13. fma-define49.0%

        \[\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(\frac{1}{\sqrt[3]{\frac{16}{\left(\color{blue}{\left(a \cdot 2 + 1\right)} \cdot b\right) \cdot t}}}\right)}^{3}\right)\right) \]
      14. *-commutative49.0%

        \[\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(\frac{1}{\sqrt[3]{\frac{16}{\color{blue}{t \cdot \left(\left(a \cdot 2 + 1\right) \cdot b\right)}}}}\right)}^{3}\right)\right) \]
      15. fma-define49.0%

        \[\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(\frac{1}{\sqrt[3]{\frac{16}{t \cdot \left(\color{blue}{\mathsf{fma}\left(a, 2, 1\right)} \cdot b\right)}}}\right)}^{3}\right)\right) \]
      16. *-commutative49.0%

        \[\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(\frac{1}{\sqrt[3]{\frac{16}{t \cdot \color{blue}{\left(b \cdot \mathsf{fma}\left(a, 2, 1\right)\right)}}}}\right)}^{3}\right)\right) \]
      17. fma-define49.0%

        \[\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(\frac{1}{\sqrt[3]{\frac{16}{t \cdot \left(b \cdot \color{blue}{\left(a \cdot 2 + 1\right)}\right)}}}\right)}^{3}\right)\right) \]
    6. Applied egg-rr49.0%

      \[\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({\color{blue}{\left(\frac{1}{\sqrt[3]{\frac{16}{t \cdot \left(b \cdot \mathsf{fma}\left(2, a, 1\right)\right)}}}\right)}}^{3}\right)\right) \]
    7. Step-by-step derivation
      1. associate-/r*49.2%

        \[\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(\frac{1}{\sqrt[3]{\color{blue}{\frac{\frac{16}{t}}{b \cdot \mathsf{fma}\left(2, a, 1\right)}}}}\right)}^{3}\right)\right) \]
      2. fma-undefine49.2%

        \[\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(\frac{1}{\sqrt[3]{\frac{\frac{16}{t}}{b \cdot \color{blue}{\left(2 \cdot a + 1\right)}}}}\right)}^{3}\right)\right) \]
      3. +-commutative49.2%

        \[\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(\frac{1}{\sqrt[3]{\frac{\frac{16}{t}}{b \cdot \color{blue}{\left(1 + 2 \cdot a\right)}}}}\right)}^{3}\right)\right) \]
      4. associate-/r*48.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(\frac{1}{\sqrt[3]{\color{blue}{\frac{\frac{\frac{16}{t}}{b}}{1 + 2 \cdot a}}}}\right)}^{3}\right)\right) \]
      5. +-commutative48.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(\frac{1}{\sqrt[3]{\frac{\frac{\frac{16}{t}}{b}}{\color{blue}{2 \cdot a + 1}}}}\right)}^{3}\right)\right) \]
      6. fma-undefine48.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(\frac{1}{\sqrt[3]{\frac{\frac{\frac{16}{t}}{b}}{\color{blue}{\mathsf{fma}\left(2, a, 1\right)}}}}\right)}^{3}\right)\right) \]
    8. Simplified48.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({\color{blue}{\left(\frac{1}{\sqrt[3]{\frac{\frac{\frac{16}{t}}{b}}{\mathsf{fma}\left(2, a, 1\right)}}}\right)}}^{3}\right)\right) \]

    if 5.0000000000000004e286 < (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y #s(literal 2 binary64)) #s(literal 1 binary64)) z) t) #s(literal 16 binary64)))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a #s(literal 2 binary64)) #s(literal 1 binary64)) b) t) #s(literal 16 binary64))))

    1. Initial program 0.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. Simplified0.9%

      \[\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)} \]
    3. Add Preprocessing
    4. Taylor expanded in b around 0 4.5%

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

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

    \[\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 5 \cdot 10^{+286}:\\ \;\;\;\;x \cdot \left(\cos \left(\left(z \cdot \mathsf{fma}\left(y, 2, 1\right)\right) \cdot \frac{t}{16}\right) \cdot \cos \left({\left(\frac{1}{\sqrt[3]{\frac{\frac{\frac{16}{t}}{b}}{\mathsf{fma}\left(2, a, 1\right)}}}\right)}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 31.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \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^{+286}:\\ \;\;\;\;\left(x \cdot \cos \left(\frac{z \cdot t}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(b \cdot \left(t \cdot 0.0625\right)\right)}\right)}^{2}\right)}^{1.5}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(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)))
      5e+286)
   (*
    (* x (cos (/ (* z t) 16.0)))
    (cos (pow (pow (cbrt (* (fma 2.0 a 1.0) (* b (* t 0.0625)))) 2.0) 1.5)))
   x))
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))) <= 5e+286) {
		tmp = (x * cos(((z * t) / 16.0))) * cos(pow(pow(cbrt((fma(2.0, a, 1.0) * (b * (t * 0.0625)))), 2.0), 1.5));
	} else {
		tmp = x;
	}
	return tmp;
}
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))) <= 5e+286)
		tmp = Float64(Float64(x * cos(Float64(Float64(z * t) / 16.0))) * cos(((cbrt(Float64(fma(2.0, a, 1.0) * Float64(b * Float64(t * 0.0625)))) ^ 2.0) ^ 1.5)));
	else
		tmp = x;
	end
	return tmp
end
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], 5e+286], N[(N[(x * N[Cos[N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[Power[N[Power[N[Power[N[(N[(2.0 * a + 1.0), $MachinePrecision] * N[(b * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision], 1.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\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^{+286}:\\
\;\;\;\;\left(x \cdot \cos \left(\frac{z \cdot t}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(b \cdot \left(t \cdot 0.0625\right)\right)}\right)}^{2}\right)}^{1.5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y #s(literal 2 binary64)) #s(literal 1 binary64)) z) t) #s(literal 16 binary64)))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a #s(literal 2 binary64)) #s(literal 1 binary64)) b) t) #s(literal 16 binary64)))) < 5.0000000000000004e286

    1. Initial program 48.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. Add Preprocessing
    3. Taylor expanded in y around 0 47.9%

      \[\leadsto \left(x \cdot \cos \left(\frac{\color{blue}{t \cdot z}}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
    4. Step-by-step derivation
      1. fma-define47.9%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\left(\color{blue}{\mathsf{fma}\left(a, 2, 1\right)} \cdot b\right) \cdot t}{16}\right) \]
      2. associate-*r*47.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\color{blue}{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}}{16}\right) \]
      3. rem-cube-cbrt47.9%

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

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left(e^{\log \left(\frac{{\left(\sqrt[3]{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}\right)}^{3}}{16}\right)}\right)} \]
      5. rem-cube-cbrt28.2%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(\frac{\color{blue}{\mathsf{fma}\left(a, 2, 1\right) \cdot \left(b \cdot t\right)}}{16}\right)}\right) \]
      6. associate-*r*24.8%

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

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(\frac{\left(\color{blue}{\left(a \cdot 2 + 1\right)} \cdot b\right) \cdot t}{16}\right)}\right) \]
      8. associate-/l*24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \color{blue}{\left(\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot \frac{t}{16}\right)}}\right) \]
      9. fma-define24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(\left(\color{blue}{\mathsf{fma}\left(a, 2, 1\right)} \cdot b\right) \cdot \frac{t}{16}\right)}\right) \]
      10. *-commutative24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(\color{blue}{\left(b \cdot \mathsf{fma}\left(a, 2, 1\right)\right)} \cdot \frac{t}{16}\right)}\right) \]
      11. associate-*r*24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \color{blue}{\left(b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \frac{t}{16}\right)\right)}}\right) \]
      12. div-inv24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \color{blue}{\left(t \cdot \frac{1}{16}\right)}\right)\right)}\right) \]
      13. metadata-eval24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \left(t \cdot \color{blue}{0.0625}\right)\right)\right)}\right) \]
      14. associate-*r*24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(b \cdot \color{blue}{\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot t\right) \cdot 0.0625\right)}\right)}\right) \]
      15. fma-define24.8%

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

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(b \cdot \left(\left(\left(\color{blue}{2 \cdot a} + 1\right) \cdot t\right) \cdot 0.0625\right)\right)}\right) \]
      17. fma-define24.8%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(e^{\log \left(b \cdot \left(\left(\color{blue}{\mathsf{fma}\left(2, a, 1\right)} \cdot t\right) \cdot 0.0625\right)\right)}\right) \]
    5. Applied egg-rr24.8%

      \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left(e^{\log \left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}\right)} \]
    6. Step-by-step derivation
      1. rem-exp-log47.2%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)} \]
      2. rem-cube-cbrt48.0%

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

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\color{blue}{\left({\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333}\right)}}^{3}\right) \]
      4. sqr-pow24.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left({\left({\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left({\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      5. pow-prod-down24.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left({\left({\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333} \cdot {\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333}\right)}^{\left(\frac{3}{2}\right)}\right)} \]
      6. pow224.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\color{blue}{\left({\left({\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333}\right)}^{2}\right)}}^{\left(\frac{3}{2}\right)}\right) \]
      7. rem-cbrt-cube25.1%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\left({\color{blue}{\left(\sqrt[3]{{\left({\left(b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)\right)}^{0.3333333333333333}\right)}^{3}}\right)}}^{2}\right)}^{\left(\frac{3}{2}\right)}\right) \]
      8. unpow1/347.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{{\color{blue}{\left(\sqrt[3]{b \cdot \left(\left(\mathsf{fma}\left(2, a, 1\right) \cdot t\right) \cdot 0.0625\right)}\right)}}^{3}}\right)}^{2}\right)}^{\left(\frac{3}{2}\right)}\right) \]
      9. rem-cube-cbrt48.1%

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

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

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

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

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

      \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \color{blue}{\left({\left({\left(\sqrt[3]{b \cdot \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, a, 1\right)\right)}\right)}^{2}\right)}^{1.5}\right)} \]
    8. Step-by-step derivation
      1. associate-*r*48.7%

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

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

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\left(\left(0.0625 \cdot t\right) \cdot b\right) \cdot \color{blue}{\left(2 \cdot a + 1\right)}}\right)}^{2}\right)}^{1.5}\right) \]
      4. +-commutative48.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\left(\left(0.0625 \cdot t\right) \cdot b\right) \cdot \color{blue}{\left(1 + 2 \cdot a\right)}}\right)}^{2}\right)}^{1.5}\right) \]
      5. *-commutative48.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\color{blue}{\left(1 + 2 \cdot a\right) \cdot \left(\left(0.0625 \cdot t\right) \cdot b\right)}}\right)}^{2}\right)}^{1.5}\right) \]
      6. +-commutative48.7%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\color{blue}{\left(2 \cdot a + 1\right)} \cdot \left(\left(0.0625 \cdot t\right) \cdot b\right)}\right)}^{2}\right)}^{1.5}\right) \]
      7. fma-undefine48.7%

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

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

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

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

    if 5.0000000000000004e286 < (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y #s(literal 2 binary64)) #s(literal 1 binary64)) z) t) #s(literal 16 binary64)))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a #s(literal 2 binary64)) #s(literal 1 binary64)) b) t) #s(literal 16 binary64))))

    1. Initial program 0.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. Simplified0.9%

      \[\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)} \]
    3. Add Preprocessing
    4. Taylor expanded in b around 0 4.5%

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

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

    \[\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 5 \cdot 10^{+286}:\\ \;\;\;\;\left(x \cdot \cos \left(\frac{z \cdot t}{16}\right)\right) \cdot \cos \left({\left({\left(\sqrt[3]{\mathsf{fma}\left(2, a, 1\right) \cdot \left(b \cdot \left(t \cdot 0.0625\right)\right)}\right)}^{2}\right)}^{1.5}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 30.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq 1.35 \cdot 10^{-33}:\\ \;\;\;\;x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot 0.0625\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \left(\left(t \cdot 0.0625\right) \cdot \mathsf{fma}\left(a, 2, 1\right)\right)}\right)}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= t 1.35e-33)
   (*
    x
    (*
     (cos (* (* z t) 0.0625))
     (cos (pow (cbrt (* b (* (* t 0.0625) (fma a 2.0 1.0)))) 3.0))))
   x))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (t <= 1.35e-33) {
		tmp = x * (cos(((z * t) * 0.0625)) * cos(pow(cbrt((b * ((t * 0.0625) * fma(a, 2.0, 1.0)))), 3.0)));
	} else {
		tmp = x;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (t <= 1.35e-33)
		tmp = Float64(x * Float64(cos(Float64(Float64(z * t) * 0.0625)) * cos((cbrt(Float64(b * Float64(Float64(t * 0.0625) * fma(a, 2.0, 1.0)))) ^ 3.0))));
	else
		tmp = x;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 1.35e-33], N[(x * N[(N[Cos[N[(N[(z * t), $MachinePrecision] * 0.0625), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[Power[N[(b * N[(N[(t * 0.0625), $MachinePrecision] * N[(a * 2.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

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

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


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

    1. Initial program 34.2%

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

      \[\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)} \]
    3. Add Preprocessing
    4. Applied egg-rr34.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(\sqrt[3]{b \cdot \left(\mathsf{fma}\left(a, 2, 1\right) \cdot \left(t \cdot 0.0625\right)\right)}\right)}^{3}\right)}\right) \]
    5. Taylor expanded in y around 0 36.0%

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

    if 1.35e-33 < t

    1. Initial program 7.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. Simplified7.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)} \]
    3. Add Preprocessing
    4. Taylor expanded in b around 0 10.4%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification29.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 1.35 \cdot 10^{-33}:\\ \;\;\;\;x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot 0.0625\right) \cdot \cos \left({\left(\sqrt[3]{b \cdot \left(\left(t \cdot 0.0625\right) \cdot \mathsf{fma}\left(a, 2, 1\right)\right)}\right)}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 30.2% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 34.2%

      \[\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. Add Preprocessing
    3. Taylor expanded in y around 0 35.2%

      \[\leadsto \left(x \cdot \cos \left(\frac{\color{blue}{t \cdot z}}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
    4. Step-by-step derivation
      1. add-cube-cbrt35.4%

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

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(\frac{\color{blue}{{\left(\sqrt[3]{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}\right)}^{3}}}{16}\right) \]
      3. associate-*l*36.5%

        \[\leadsto \left(x \cdot \cos \left(\frac{t \cdot z}{16}\right)\right) \cdot \cos \left(\frac{{\left(\sqrt[3]{\color{blue}{\left(a \cdot 2 + 1\right) \cdot \left(b \cdot t\right)}}\right)}^{3}}{16}\right) \]
      4. fma-define36.5%

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

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

    if 6.99999999999999992e-35 < t

    1. Initial program 7.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. Simplified7.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)} \]
    3. Add Preprocessing
    4. Taylor expanded in b around 0 10.4%

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

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

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

Alternative 5: 31.0% accurate, 225.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
	return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x;
}
def code(x, y, z, t, a, b):
	return x
function code(x, y, z, t, a, b)
	return x
end
function tmp = code(x, y, z, t, a, b)
	tmp = x;
end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}

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

    \[\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. Simplified26.5%

    \[\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)} \]
  3. Add Preprocessing
  4. Taylor expanded in b around 0 27.6%

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification29.5%

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 30.5% 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 2024095 
(FPCore (x y z t a b)
  :name "Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1"
  :precision binary64

  :alt
  (* 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))))