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

Percentage Accurate: 27.0% → 31.5%
Time: 14.9s
Alternatives: 4
Speedup: 13.5×

Specification

?
\[\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) \]
(FPCore (x y z t a b)
  :precision binary64
  :pre TRUE
  (*
 (* 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)
use fmin_fmax_functions
    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]
f(x, y, z, t, a, b):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf],
	t in [-inf, +inf],
	a in [-inf, +inf],
	b in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z, t, a, b: real): real =
	(x * (cos((((((y * (2)) + (1)) * z) * t) / (16))))) * (cos((((((a * (2)) + (1)) * b) * t) / (16))))
END code
\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)

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 4 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.0% accurate, 1.0× speedup?

\[\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) \]
(FPCore (x y z t a b)
  :precision binary64
  :pre TRUE
  (*
 (* 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)
use fmin_fmax_functions
    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]
f(x, y, z, t, a, b):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf],
	t in [-inf, +inf],
	a in [-inf, +inf],
	b in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z, t, a, b: real): real =
	(x * (cos((((((y * (2)) + (1)) * z) * t) / (16))))) * (cos((((((a * (2)) + (1)) * b) * t) / (16))))
END code
\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)

Alternative 1: 31.5% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot \left|t\right|}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot \left|t\right|}{16}\right) \leq 10^{+288}:\\ \;\;\;\;\left(x \cdot \sin \left(\mathsf{fma}\left(\left|t\right| \cdot 0.0625, z \cdot \mathsf{fma}\left(2, y, 1\right), \pi \cdot 0.5\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot \left|t\right|, 0.0625, \pi \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{2}{2}\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  :pre TRUE
  (if (<=
     (*
      (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) (fabs t)) 16.0)))
      (cos (/ (* (* (+ (* a 2.0) 1.0) b) (fabs t)) 16.0)))
     1e+288)
  (*
   (*
    x
    (sin (fma (* (fabs t) 0.0625) (* z (fma 2.0 y 1.0)) (* PI 0.5))))
   (sin (fma (* (* (fma a 2.0 1.0) b) (fabs t)) 0.0625 (* PI 0.5))))
  (* x (/ 2.0 2.0))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * cos((((((y * 2.0) + 1.0) * z) * fabs(t)) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * fabs(t)) / 16.0))) <= 1e+288) {
		tmp = (x * sin(fma((fabs(t) * 0.0625), (z * fma(2.0, y, 1.0)), (((double) M_PI) * 0.5)))) * sin(fma(((fma(a, 2.0, 1.0) * b) * fabs(t)), 0.0625, (((double) M_PI) * 0.5)));
	} else {
		tmp = x * (2.0 / 2.0);
	}
	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) * abs(t)) / 16.0))) * cos(Float64(Float64(Float64(Float64(Float64(a * 2.0) + 1.0) * b) * abs(t)) / 16.0))) <= 1e+288)
		tmp = Float64(Float64(x * sin(fma(Float64(abs(t) * 0.0625), Float64(z * fma(2.0, y, 1.0)), Float64(pi * 0.5)))) * sin(fma(Float64(Float64(fma(a, 2.0, 1.0) * b) * abs(t)), 0.0625, Float64(pi * 0.5))));
	else
		tmp = Float64(x * Float64(2.0 / 2.0));
	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] * N[Abs[t], $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(N[(N[(N[(a * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] * N[Abs[t], $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e+288], N[(N[(x * N[Sin[N[(N[(N[Abs[t], $MachinePrecision] * 0.0625), $MachinePrecision] * N[(z * N[(2.0 * y + 1.0), $MachinePrecision]), $MachinePrecision] + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(N[(N[(a * 2.0 + 1.0), $MachinePrecision] * b), $MachinePrecision] * N[Abs[t], $MachinePrecision]), $MachinePrecision] * 0.0625 + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / 2.0), $MachinePrecision]), $MachinePrecision]]
f(x, y, z, t, a, b):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf],
	t in [-inf, +inf],
	a in [-inf, +inf],
	b in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z, t, a, b: real): real =
	LET tmp = IF (((x * (cos((((((y * (2)) + (1)) * z) * (abs(t))) / (16))))) * (cos((((((a * (2)) + (1)) * b) * (abs(t))) / (16))))) <= (1000000000000000007630473539575035660514778335511710750780086664439969510636494954611131549135839186513983455555395220895687860544809584999829725260594873271087399626486606146442550988840016917394626449536395208620267012778077787723395914064607119962069483324573977857832138825282954985472)) THEN ((x * (sin(((((abs(t)) * (625e-4)) * (z * (((2) * y) + (1)))) + ((4 * atan(1)) * (5e-1)))))) * (sin(((((((a * (2)) + (1)) * b) * (abs(t))) * (625e-4)) + ((4 * atan(1)) * (5e-1)))))) ELSE (x * ((2) / (2))) ENDIF IN
	tmp
END code
\begin{array}{l}
\mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot \left|t\right|}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot \left|t\right|}{16}\right) \leq 10^{+288}:\\
\;\;\;\;\left(x \cdot \sin \left(\mathsf{fma}\left(\left|t\right| \cdot 0.0625, z \cdot \mathsf{fma}\left(2, y, 1\right), \pi \cdot 0.5\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot \left|t\right|, 0.0625, \pi \cdot 0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{2}{2}\\


\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)))) < 1e288

    1. Initial program 27.0%

      \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
    2. Step-by-step derivation
      1. Applied rewrites26.9%

        \[\leadsto \left(x \cdot \sin \left(\mathsf{fma}\left(t \cdot 0.0625, z \cdot \mathsf{fma}\left(2, y, 1\right), \pi \cdot 0.5\right)\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. Applied rewrites26.9%

          \[\leadsto \left(x \cdot \sin \left(\mathsf{fma}\left(t \cdot 0.0625, z \cdot \mathsf{fma}\left(2, y, 1\right), \pi \cdot 0.5\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot t, 0.0625, \pi \cdot 0.5\right)\right) \]

        if 1e288 < (*.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 27.0%

          \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
        2. Taylor expanded in a around 0

          \[\leadsto x \cdot \left(\cos \left(\frac{1}{16} \cdot \left(b \cdot t\right)\right) \cdot \cos \left(\frac{1}{16} \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
        3. Step-by-step derivation
          1. Applied rewrites27.7%

            \[\leadsto x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot t\right)\right) \cdot \cos \left(0.0625 \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
          2. Applied rewrites26.7%

            \[\leadsto x \cdot \frac{\sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) - \left(b \cdot t\right) \cdot 0.0625\right) + \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) + \left(b \cdot t\right) \cdot 0.0625\right)}{2} \]
          3. Taylor expanded in t around 0

            \[\leadsto x \cdot \frac{2}{2} \]
          4. Step-by-step derivation
            1. Applied rewrites30.3%

              \[\leadsto x \cdot \frac{2}{2} \]
          5. Recombined 2 regimes into one program.
          6. Add Preprocessing

          Alternative 2: 31.1% accurate, 0.5× speedup?

          \[\begin{array}{l} \mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot \left|t\right|}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot \left|t\right|}{16}\right) \leq 10^{+288}:\\ \;\;\;\;\left(x \cdot \sin \left(\mathsf{fma}\left(0.0625, \left|t\right| \cdot z, 0.5 \cdot \pi\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot \left|t\right|, 0.0625, 1.5707963267948966\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{2}{2}\\ \end{array} \]
          (FPCore (x y z t a b)
            :precision binary64
            :pre TRUE
            (if (<=
               (*
                (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) (fabs t)) 16.0)))
                (cos (/ (* (* (+ (* a 2.0) 1.0) b) (fabs t)) 16.0)))
               1e+288)
            (*
             (* x (sin (fma 0.0625 (* (fabs t) z) (* 0.5 PI))))
             (sin
              (fma
               (* (* (fma a 2.0 1.0) b) (fabs t))
               0.0625
               1.5707963267948966)))
            (* x (/ 2.0 2.0))))
          double code(double x, double y, double z, double t, double a, double b) {
          	double tmp;
          	if (((x * cos((((((y * 2.0) + 1.0) * z) * fabs(t)) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * fabs(t)) / 16.0))) <= 1e+288) {
          		tmp = (x * sin(fma(0.0625, (fabs(t) * z), (0.5 * ((double) M_PI))))) * sin(fma(((fma(a, 2.0, 1.0) * b) * fabs(t)), 0.0625, 1.5707963267948966));
          	} else {
          		tmp = x * (2.0 / 2.0);
          	}
          	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) * abs(t)) / 16.0))) * cos(Float64(Float64(Float64(Float64(Float64(a * 2.0) + 1.0) * b) * abs(t)) / 16.0))) <= 1e+288)
          		tmp = Float64(Float64(x * sin(fma(0.0625, Float64(abs(t) * z), Float64(0.5 * pi)))) * sin(fma(Float64(Float64(fma(a, 2.0, 1.0) * b) * abs(t)), 0.0625, 1.5707963267948966)));
          	else
          		tmp = Float64(x * Float64(2.0 / 2.0));
          	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] * N[Abs[t], $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(N[(N[(N[(a * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] * N[Abs[t], $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1e+288], N[(N[(x * N[Sin[N[(0.0625 * N[(N[Abs[t], $MachinePrecision] * z), $MachinePrecision] + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(N[(N[(a * 2.0 + 1.0), $MachinePrecision] * b), $MachinePrecision] * N[Abs[t], $MachinePrecision]), $MachinePrecision] * 0.0625 + 1.5707963267948966), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / 2.0), $MachinePrecision]), $MachinePrecision]]
          
          f(x, y, z, t, a, b):
          	x in [-inf, +inf],
          	y in [-inf, +inf],
          	z in [-inf, +inf],
          	t in [-inf, +inf],
          	a in [-inf, +inf],
          	b in [-inf, +inf]
          code: THEORY
          BEGIN
          f(x, y, z, t, a, b: real): real =
          	LET tmp = IF (((x * (cos((((((y * (2)) + (1)) * z) * (abs(t))) / (16))))) * (cos((((((a * (2)) + (1)) * b) * (abs(t))) / (16))))) <= (1000000000000000007630473539575035660514778335511710750780086664439969510636494954611131549135839186513983455555395220895687860544809584999829725260594873271087399626486606146442550988840016917394626449536395208620267012778077787723395914064607119962069483324573977857832138825282954985472)) THEN ((x * (sin((((625e-4) * ((abs(t)) * z)) + ((5e-1) * (4 * atan(1))))))) * (sin(((((((a * (2)) + (1)) * b) * (abs(t))) * (625e-4)) + (15707963267948965579989817342720925807952880859375e-49))))) ELSE (x * ((2) / (2))) ENDIF IN
          	tmp
          END code
          \begin{array}{l}
          \mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot \left|t\right|}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot \left|t\right|}{16}\right) \leq 10^{+288}:\\
          \;\;\;\;\left(x \cdot \sin \left(\mathsf{fma}\left(0.0625, \left|t\right| \cdot z, 0.5 \cdot \pi\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot \left|t\right|, 0.0625, 1.5707963267948966\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;x \cdot \frac{2}{2}\\
          
          
          \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)))) < 1e288

            1. Initial program 27.0%

              \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
            2. Step-by-step derivation
              1. Applied rewrites26.9%

                \[\leadsto \left(x \cdot \sin \left(\mathsf{fma}\left(t \cdot 0.0625, z \cdot \mathsf{fma}\left(2, y, 1\right), \pi \cdot 0.5\right)\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. Applied rewrites26.9%

                  \[\leadsto \left(x \cdot \sin \left(\mathsf{fma}\left(t \cdot 0.0625, z \cdot \mathsf{fma}\left(2, y, 1\right), \pi \cdot 0.5\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot t, 0.0625, \pi \cdot 0.5\right)\right) \]
                2. Taylor expanded in y around 0

                  \[\leadsto \left(x \cdot \sin \left(\frac{1}{16} \cdot \left(t \cdot z\right) + \frac{1}{2} \cdot \pi\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot t, 0.0625, \pi \cdot 0.5\right)\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites27.7%

                    \[\leadsto \left(x \cdot \sin \left(\mathsf{fma}\left(0.0625, t \cdot z, 0.5 \cdot \pi\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot t, 0.0625, \pi \cdot 0.5\right)\right) \]
                  2. Evaluated real constant27.7%

                    \[\leadsto \left(x \cdot \sin \left(\mathsf{fma}\left(0.0625, t \cdot z, 0.5 \cdot \pi\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(\left(\mathsf{fma}\left(a, 2, 1\right) \cdot b\right) \cdot t, 0.0625, 1.5707963267948966\right)\right) \]

                  if 1e288 < (*.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 27.0%

                    \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
                  2. Taylor expanded in a around 0

                    \[\leadsto x \cdot \left(\cos \left(\frac{1}{16} \cdot \left(b \cdot t\right)\right) \cdot \cos \left(\frac{1}{16} \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                  3. Step-by-step derivation
                    1. Applied rewrites27.7%

                      \[\leadsto x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot t\right)\right) \cdot \cos \left(0.0625 \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                    2. Applied rewrites26.7%

                      \[\leadsto x \cdot \frac{\sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) - \left(b \cdot t\right) \cdot 0.0625\right) + \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) + \left(b \cdot t\right) \cdot 0.0625\right)}{2} \]
                    3. Taylor expanded in t around 0

                      \[\leadsto x \cdot \frac{2}{2} \]
                    4. Step-by-step derivation
                      1. Applied rewrites30.3%

                        \[\leadsto x \cdot \frac{2}{2} \]
                    5. Recombined 2 regimes into one program.
                    6. Add Preprocessing

                    Alternative 3: 30.9% accurate, 1.0× speedup?

                    \[\begin{array}{l} \mathbf{if}\;\left|t\right| \leq 2.864484426612483 \cdot 10^{-41}:\\ \;\;\;\;x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot \left|t\right|\right)\right) \cdot \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot \left|t\right|\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{2}{2}\\ \end{array} \]
                    (FPCore (x y z t a b)
                      :precision binary64
                      :pre TRUE
                      (if (<= (fabs t) 2.864484426612483e-41)
                      (*
                       x
                       (*
                        (cos (* 0.0625 (* b (fabs t))))
                        (sin (fma PI 0.5 (* (* (* 0.0625 (fabs t)) (fma 2.0 y 1.0)) z)))))
                      (* x (/ 2.0 2.0))))
                    double code(double x, double y, double z, double t, double a, double b) {
                    	double tmp;
                    	if (fabs(t) <= 2.864484426612483e-41) {
                    		tmp = x * (cos((0.0625 * (b * fabs(t)))) * sin(fma(((double) M_PI), 0.5, (((0.0625 * fabs(t)) * fma(2.0, y, 1.0)) * z))));
                    	} else {
                    		tmp = x * (2.0 / 2.0);
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z, t, a, b)
                    	tmp = 0.0
                    	if (abs(t) <= 2.864484426612483e-41)
                    		tmp = Float64(x * Float64(cos(Float64(0.0625 * Float64(b * abs(t)))) * sin(fma(pi, 0.5, Float64(Float64(Float64(0.0625 * abs(t)) * fma(2.0, y, 1.0)) * z)))));
                    	else
                    		tmp = Float64(x * Float64(2.0 / 2.0));
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[Abs[t], $MachinePrecision], 2.864484426612483e-41], N[(x * N[(N[Cos[N[(0.0625 * N[(b * N[Abs[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(Pi * 0.5 + N[(N[(N[(0.0625 * N[Abs[t], $MachinePrecision]), $MachinePrecision] * N[(2.0 * y + 1.0), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / 2.0), $MachinePrecision]), $MachinePrecision]]
                    
                    f(x, y, z, t, a, b):
                    	x in [-inf, +inf],
                    	y in [-inf, +inf],
                    	z in [-inf, +inf],
                    	t in [-inf, +inf],
                    	a in [-inf, +inf],
                    	b in [-inf, +inf]
                    code: THEORY
                    BEGIN
                    f(x, y, z, t, a, b: real): real =
                    	LET tmp = IF ((abs(t)) <= (28644844266124828983549621919316975406196140503556268027475564542582254570688733394112242861412399625060942742749148237635381519794464111328125e-183)) THEN (x * ((cos(((625e-4) * (b * (abs(t)))))) * (sin((((4 * atan(1)) * (5e-1)) + ((((625e-4) * (abs(t))) * (((2) * y) + (1))) * z)))))) ELSE (x * ((2) / (2))) ENDIF IN
                    	tmp
                    END code
                    \begin{array}{l}
                    \mathbf{if}\;\left|t\right| \leq 2.864484426612483 \cdot 10^{-41}:\\
                    \;\;\;\;x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot \left|t\right|\right)\right) \cdot \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot \left|t\right|\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right)\right)\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;x \cdot \frac{2}{2}\\
                    
                    
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if t < 2.8644844266124829e-41

                      1. Initial program 27.0%

                        \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
                      2. Taylor expanded in a around 0

                        \[\leadsto x \cdot \left(\cos \left(\frac{1}{16} \cdot \left(b \cdot t\right)\right) \cdot \cos \left(\frac{1}{16} \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                      3. Step-by-step derivation
                        1. Applied rewrites27.7%

                          \[\leadsto x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot t\right)\right) \cdot \cos \left(0.0625 \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                        2. Applied rewrites27.7%

                          \[\leadsto x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot t\right)\right) \cdot \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right)\right)\right) \]

                        if 2.8644844266124829e-41 < t

                        1. Initial program 27.0%

                          \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
                        2. Taylor expanded in a around 0

                          \[\leadsto x \cdot \left(\cos \left(\frac{1}{16} \cdot \left(b \cdot t\right)\right) \cdot \cos \left(\frac{1}{16} \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites27.7%

                            \[\leadsto x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot t\right)\right) \cdot \cos \left(0.0625 \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                          2. Applied rewrites26.7%

                            \[\leadsto x \cdot \frac{\sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) - \left(b \cdot t\right) \cdot 0.0625\right) + \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) + \left(b \cdot t\right) \cdot 0.0625\right)}{2} \]
                          3. Taylor expanded in t around 0

                            \[\leadsto x \cdot \frac{2}{2} \]
                          4. Step-by-step derivation
                            1. Applied rewrites30.3%

                              \[\leadsto x \cdot \frac{2}{2} \]
                          5. Recombined 2 regimes into one program.
                          6. Add Preprocessing

                          Alternative 4: 30.3% accurate, 13.5× speedup?

                          \[x \cdot \frac{2}{2} \]
                          (FPCore (x y z t a b)
                            :precision binary64
                            :pre TRUE
                            (* x (/ 2.0 2.0)))
                          double code(double x, double y, double z, double t, double a, double b) {
                          	return x * (2.0 / 2.0);
                          }
                          
                          real(8) function code(x, y, z, t, a, b)
                          use fmin_fmax_functions
                              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 * (2.0d0 / 2.0d0)
                          end function
                          
                          public static double code(double x, double y, double z, double t, double a, double b) {
                          	return x * (2.0 / 2.0);
                          }
                          
                          def code(x, y, z, t, a, b):
                          	return x * (2.0 / 2.0)
                          
                          function code(x, y, z, t, a, b)
                          	return Float64(x * Float64(2.0 / 2.0))
                          end
                          
                          function tmp = code(x, y, z, t, a, b)
                          	tmp = x * (2.0 / 2.0);
                          end
                          
                          code[x_, y_, z_, t_, a_, b_] := N[(x * N[(2.0 / 2.0), $MachinePrecision]), $MachinePrecision]
                          
                          f(x, y, z, t, a, b):
                          	x in [-inf, +inf],
                          	y in [-inf, +inf],
                          	z in [-inf, +inf],
                          	t in [-inf, +inf],
                          	a in [-inf, +inf],
                          	b in [-inf, +inf]
                          code: THEORY
                          BEGIN
                          f(x, y, z, t, a, b: real): real =
                          	x * ((2) / (2))
                          END code
                          x \cdot \frac{2}{2}
                          
                          Derivation
                          1. Initial program 27.0%

                            \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
                          2. Taylor expanded in a around 0

                            \[\leadsto x \cdot \left(\cos \left(\frac{1}{16} \cdot \left(b \cdot t\right)\right) \cdot \cos \left(\frac{1}{16} \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites27.7%

                              \[\leadsto x \cdot \left(\cos \left(0.0625 \cdot \left(b \cdot t\right)\right) \cdot \cos \left(0.0625 \cdot \left(t \cdot \left(z \cdot \left(1 + 2 \cdot y\right)\right)\right)\right)\right) \]
                            2. Applied rewrites26.7%

                              \[\leadsto x \cdot \frac{\sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) - \left(b \cdot t\right) \cdot 0.0625\right) + \sin \left(\mathsf{fma}\left(\pi, 0.5, \left(\left(0.0625 \cdot t\right) \cdot \mathsf{fma}\left(2, y, 1\right)\right) \cdot z\right) + \left(b \cdot t\right) \cdot 0.0625\right)}{2} \]
                            3. Taylor expanded in t around 0

                              \[\leadsto x \cdot \frac{2}{2} \]
                            4. Step-by-step derivation
                              1. Applied rewrites30.3%

                                \[\leadsto x \cdot \frac{2}{2} \]
                              2. Add Preprocessing

                              Reproduce

                              ?
                              herbie shell --seed 2026092 
                              (FPCore (x y z t a b)
                                :name "Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1"
                                :precision binary64
                                (* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))