mixedcos

Percentage Accurate: 66.1% → 98.4%
Time: 4.8s
Alternatives: 9
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
	return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c, s)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
	return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s):
	return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s)
	return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x)))
end
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x));
end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\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 9 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: 66.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
	return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c, s)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
	return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s):
	return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s)
	return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x)))
end
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x));
end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}

Alternative 1: 98.4% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;\frac{t\_0}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)} \leq 0:\\ \;\;\;\;\frac{\frac{\frac{{\cos x}^{2}}{c\_m} - \frac{{\sin x}^{2}}{c\_m}}{s\_m \cdot x}}{\left(s\_m \cdot x\right) \cdot c\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{{\left(\left(s\_m \cdot c\_m\right) \cdot x\right)}^{2}}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (cos (* 2.0 x))))
   (if (<= (/ t_0 (* (pow c_m 2.0) (* (* x (pow s_m 2.0)) x))) 0.0)
     (/
      (/ (- (/ (pow (cos x) 2.0) c_m) (/ (pow (sin x) 2.0) c_m)) (* s_m x))
      (* (* s_m x) c_m))
     (/ t_0 (pow (* (* s_m c_m) x) 2.0)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = cos((2.0 * x));
	double tmp;
	if ((t_0 / (pow(c_m, 2.0) * ((x * pow(s_m, 2.0)) * x))) <= 0.0) {
		tmp = (((pow(cos(x), 2.0) / c_m) - (pow(sin(x), 2.0) / c_m)) / (s_m * x)) / ((s_m * x) * c_m);
	} else {
		tmp = t_0 / pow(((s_m * c_m) * x), 2.0);
	}
	return tmp;
}
c_m =     private
s_m =     private
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c_m, s_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos((2.0d0 * x))
    if ((t_0 / ((c_m ** 2.0d0) * ((x * (s_m ** 2.0d0)) * x))) <= 0.0d0) then
        tmp = ((((cos(x) ** 2.0d0) / c_m) - ((sin(x) ** 2.0d0) / c_m)) / (s_m * x)) / ((s_m * x) * c_m)
    else
        tmp = t_0 / (((s_m * c_m) * x) ** 2.0d0)
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = Math.cos((2.0 * x));
	double tmp;
	if ((t_0 / (Math.pow(c_m, 2.0) * ((x * Math.pow(s_m, 2.0)) * x))) <= 0.0) {
		tmp = (((Math.pow(Math.cos(x), 2.0) / c_m) - (Math.pow(Math.sin(x), 2.0) / c_m)) / (s_m * x)) / ((s_m * x) * c_m);
	} else {
		tmp = t_0 / Math.pow(((s_m * c_m) * x), 2.0);
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = math.cos((2.0 * x))
	tmp = 0
	if (t_0 / (math.pow(c_m, 2.0) * ((x * math.pow(s_m, 2.0)) * x))) <= 0.0:
		tmp = (((math.pow(math.cos(x), 2.0) / c_m) - (math.pow(math.sin(x), 2.0) / c_m)) / (s_m * x)) / ((s_m * x) * c_m)
	else:
		tmp = t_0 / math.pow(((s_m * c_m) * x), 2.0)
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = cos(Float64(2.0 * x))
	tmp = 0.0
	if (Float64(t_0 / Float64((c_m ^ 2.0) * Float64(Float64(x * (s_m ^ 2.0)) * x))) <= 0.0)
		tmp = Float64(Float64(Float64(Float64((cos(x) ^ 2.0) / c_m) - Float64((sin(x) ^ 2.0) / c_m)) / Float64(s_m * x)) / Float64(Float64(s_m * x) * c_m));
	else
		tmp = Float64(t_0 / (Float64(Float64(s_m * c_m) * x) ^ 2.0));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = cos((2.0 * x));
	tmp = 0.0;
	if ((t_0 / ((c_m ^ 2.0) * ((x * (s_m ^ 2.0)) * x))) <= 0.0)
		tmp = ((((cos(x) ^ 2.0) / c_m) - ((sin(x) ^ 2.0) / c_m)) / (s_m * x)) / ((s_m * x) * c_m);
	else
		tmp = t_0 / (((s_m * c_m) * x) ^ 2.0);
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / c$95$m), $MachinePrecision] - N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * x), $MachinePrecision]), $MachinePrecision] / N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[Power[N[(N[(s$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;\frac{t\_0}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)} \leq 0:\\
\;\;\;\;\frac{\frac{\frac{{\cos x}^{2}}{c\_m} - \frac{{\sin x}^{2}}{c\_m}}{s\_m \cdot x}}{\left(s\_m \cdot x\right) \cdot c\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{{\left(\left(s\_m \cdot c\_m\right) \cdot x\right)}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < 0.0

    1. Initial program 76.8%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6495.9

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites95.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      2. lift-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      3. cos-2N/A

        \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      4. unpow2N/A

        \[\leadsto \frac{\color{blue}{{\cos x}^{2}} - \sin x \cdot \sin x}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      5. unpow2N/A

        \[\leadsto \frac{{\cos x}^{2} - \color{blue}{{\sin x}^{2}}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      6. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{{\cos x}^{2} - {\sin x}^{2}}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      7. lift-pow.f64N/A

        \[\leadsto \frac{\color{blue}{{\cos x}^{2}} - {\sin x}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      8. lift-cos.f64N/A

        \[\leadsto \frac{{\color{blue}{\cos x}}^{2} - {\sin x}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\color{blue}{\sin x}}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      10. lift-pow.f6495.8

        \[\leadsto \frac{{\cos x}^{2} - \color{blue}{{\sin x}^{2}}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
    6. Applied rewrites95.8%

      \[\leadsto \frac{\color{blue}{{\cos x}^{2} - {\sin x}^{2}}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\cos x}^{2} - {\sin x}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{{\cos x}^{2} - {\sin x}^{2}}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{{\color{blue}{\cos x}}^{2} - {\sin x}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\color{blue}{{\cos x}^{2}} - {\sin x}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - \color{blue}{{\sin x}^{2}}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\color{blue}{\sin x}}^{2}}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}} \]
      7. lift-pow.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{2}} \]
      10. *-commutativeN/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
      11. associate-*r*N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}}^{2}} \]
      13. pow2N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\left(\color{blue}{\left(s \cdot x\right)} \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)} \cdot \left(\left(s \cdot x\right) \cdot c\right)} \]
      17. lift-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\color{blue}{\left(s \cdot x\right)} \cdot c\right)} \]
      18. lift-*.f64N/A

        \[\leadsto \frac{{\cos x}^{2} - {\sin x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}} \]
    8. Applied rewrites92.9%

      \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{\left(s \cdot x\right) \cdot c} - \frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c}} \]
    9. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{{\cos x}^{2}}{\left(s \cdot x\right) \cdot c} - \frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}}{\left(s \cdot x\right) \cdot c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{{\cos x}^{2}}{\left(s \cdot x\right) \cdot c}} - \frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{\frac{{\color{blue}{\cos x}}^{2}}{\left(s \cdot x\right) \cdot c} - \frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      4. lift-pow.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{{\cos x}^{2}}}{\left(s \cdot x\right) \cdot c} - \frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      5. lift-/.f64N/A

        \[\leadsto \frac{\frac{{\cos x}^{2}}{\left(s \cdot x\right) \cdot c} - \color{blue}{\frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}}{\left(s \cdot x\right) \cdot c} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\cos x}^{2}}{\left(s \cdot x\right) \cdot c} - \frac{\color{blue}{{\sin x}^{2}}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      7. lift-sin.f64N/A

        \[\leadsto \frac{\frac{{\cos x}^{2}}{\left(s \cdot x\right) \cdot c} - \frac{{\color{blue}{\sin x}}^{2}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      8. frac-2negN/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left({\cos x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}} - \frac{{\sin x}^{2}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      9. frac-2negN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left({\cos x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)} - \color{blue}{\frac{\mathsf{neg}\left({\sin x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}}}{\left(s \cdot x\right) \cdot c} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left({\cos x}^{2}\right)}{\mathsf{neg}\left(\color{blue}{\left(s \cdot x\right) \cdot c}\right)} - \frac{\mathsf{neg}\left({\sin x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}}{\left(s \cdot x\right) \cdot c} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left({\cos x}^{2}\right)}{\mathsf{neg}\left(\color{blue}{\left(s \cdot x\right)} \cdot c\right)} - \frac{\mathsf{neg}\left({\sin x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}}{\left(s \cdot x\right) \cdot c} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left({\cos x}^{2}\right)}{\mathsf{neg}\left(\color{blue}{c \cdot \left(s \cdot x\right)}\right)} - \frac{\mathsf{neg}\left({\sin x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}}{\left(s \cdot x\right) \cdot c} \]
      13. frac-2negN/A

        \[\leadsto \frac{\color{blue}{\frac{{\cos x}^{2}}{c \cdot \left(s \cdot x\right)}} - \frac{\mathsf{neg}\left({\sin x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}}{\left(s \cdot x\right) \cdot c} \]
      14. associate-/r*N/A

        \[\leadsto \frac{\color{blue}{\frac{\frac{{\cos x}^{2}}{c}}{s \cdot x}} - \frac{\mathsf{neg}\left({\sin x}^{2}\right)}{\mathsf{neg}\left(\left(s \cdot x\right) \cdot c\right)}}{\left(s \cdot x\right) \cdot c} \]
    10. Applied rewrites99.6%

      \[\leadsto \frac{\color{blue}{\frac{\frac{{\cos x}^{2}}{c} - \frac{{\sin x}^{2}}{c}}{s \cdot x}}}{\left(s \cdot x\right) \cdot c} \]

    if 0.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 57.7%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6499.6

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites99.6%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 98.0% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \cos \left(2 \cdot x\right)\\ t_1 := \frac{1}{\left(s\_m \cdot x\right) \cdot c\_m}\\ \mathbf{if}\;x \leq 2 \cdot 10^{+16}:\\ \;\;\;\;\frac{t\_0}{\frac{1}{t\_1 \cdot t\_1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{{\left(s\_m \cdot {\left(x \cdot c\_m\right)}^{1}\right)}^{2}}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (cos (* 2.0 x))) (t_1 (/ 1.0 (* (* s_m x) c_m))))
   (if (<= x 2e+16)
     (/ t_0 (/ 1.0 (* t_1 t_1)))
     (/ t_0 (pow (* s_m (pow (* x c_m) 1.0)) 2.0)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = cos((2.0 * x));
	double t_1 = 1.0 / ((s_m * x) * c_m);
	double tmp;
	if (x <= 2e+16) {
		tmp = t_0 / (1.0 / (t_1 * t_1));
	} else {
		tmp = t_0 / pow((s_m * pow((x * c_m), 1.0)), 2.0);
	}
	return tmp;
}
c_m =     private
s_m =     private
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c_m, s_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((2.0d0 * x))
    t_1 = 1.0d0 / ((s_m * x) * c_m)
    if (x <= 2d+16) then
        tmp = t_0 / (1.0d0 / (t_1 * t_1))
    else
        tmp = t_0 / ((s_m * ((x * c_m) ** 1.0d0)) ** 2.0d0)
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = Math.cos((2.0 * x));
	double t_1 = 1.0 / ((s_m * x) * c_m);
	double tmp;
	if (x <= 2e+16) {
		tmp = t_0 / (1.0 / (t_1 * t_1));
	} else {
		tmp = t_0 / Math.pow((s_m * Math.pow((x * c_m), 1.0)), 2.0);
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = math.cos((2.0 * x))
	t_1 = 1.0 / ((s_m * x) * c_m)
	tmp = 0
	if x <= 2e+16:
		tmp = t_0 / (1.0 / (t_1 * t_1))
	else:
		tmp = t_0 / math.pow((s_m * math.pow((x * c_m), 1.0)), 2.0)
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = cos(Float64(2.0 * x))
	t_1 = Float64(1.0 / Float64(Float64(s_m * x) * c_m))
	tmp = 0.0
	if (x <= 2e+16)
		tmp = Float64(t_0 / Float64(1.0 / Float64(t_1 * t_1)));
	else
		tmp = Float64(t_0 / (Float64(s_m * (Float64(x * c_m) ^ 1.0)) ^ 2.0));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = cos((2.0 * x));
	t_1 = 1.0 / ((s_m * x) * c_m);
	tmp = 0.0;
	if (x <= 2e+16)
		tmp = t_0 / (1.0 / (t_1 * t_1));
	else
		tmp = t_0 / ((s_m * ((x * c_m) ^ 1.0)) ^ 2.0);
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2e+16], N[(t$95$0 / N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[Power[N[(s$95$m * N[Power[N[(x * c$95$m), $MachinePrecision], 1.0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
t_1 := \frac{1}{\left(s\_m \cdot x\right) \cdot c\_m}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+16}:\\
\;\;\;\;\frac{t\_0}{\frac{1}{t\_1 \cdot t\_1}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{{\left(s\_m \cdot {\left(x \cdot c\_m\right)}^{1}\right)}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2e16

    1. Initial program 67.3%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6497.6

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites97.6%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    5. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{2}} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
      5. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}}^{2}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\left(s \cdot x\right) \cdot c\right)}^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)}}} \]
      8. pow-negN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\frac{1}{{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}}}} \]
      9. metadata-evalN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{{\left(\left(s \cdot x\right) \cdot c\right)}^{\color{blue}{\left(\mathsf{neg}\left(2\right)\right)}}}} \]
      10. pow-flipN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\color{blue}{\frac{1}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}}}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}}}} \]
      12. unpow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1}{\color{blue}{{c}^{2} \cdot {\left(s \cdot x\right)}^{2}}}}} \]
      13. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot {x}^{2}\right)}}}} \]
      14. lower-/.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\frac{1}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}}}} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{\color{blue}{1 \cdot 1}}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}}}} \]
      17. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{{\left(s \cdot x\right)}^{2}} \cdot {c}^{2}}}} \]
      18. unpow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}}}} \]
      19. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}}}} \]
      20. times-fracN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\color{blue}{\frac{1}{\left(s \cdot x\right) \cdot c} \cdot \frac{1}{\left(s \cdot x\right) \cdot c}}}} \]
      21. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\color{blue}{\frac{1}{\left(s \cdot x\right) \cdot c} \cdot \frac{1}{\left(s \cdot x\right) \cdot c}}}} \]
    6. Applied rewrites97.6%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\frac{1}{\frac{1}{\left(s \cdot x\right) \cdot c} \cdot \frac{1}{\left(s \cdot x\right) \cdot c}}}} \]

    if 2e16 < x

    1. Initial program 64.8%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6498.7

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites98.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{2}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}}^{2}} \]
      6. unpow1N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left({\left(\left(s \cdot x\right) \cdot c\right)}^{1}\right)}}^{2}} \]
      7. associate-*l*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left({\color{blue}{\left(s \cdot \left(x \cdot c\right)\right)}}^{1}\right)}^{2}} \]
      8. unpow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left({s}^{1} \cdot {\left(x \cdot c\right)}^{1}\right)}}^{2}} \]
      9. unpow1N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{s} \cdot {\left(x \cdot c\right)}^{1}\right)}^{2}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(s \cdot {\left(x \cdot c\right)}^{1}\right)}}^{2}} \]
      11. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(s \cdot \color{blue}{{\left(x \cdot c\right)}^{1}}\right)}^{2}} \]
      12. lower-*.f6498.6

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(s \cdot {\color{blue}{\left(x \cdot c\right)}}^{1}\right)}^{2}} \]
    6. Applied rewrites98.6%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(s \cdot {\left(x \cdot c\right)}^{1}\right)}}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 96.7% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \frac{\cos \left(2 \cdot x\right)}{{\left(\left(s\_m \cdot c\_m\right) \cdot x\right)}^{2}} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (/ (cos (* 2.0 x)) (pow (* (* s_m c_m) x) 2.0)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	return cos((2.0 * x)) / pow(((s_m * c_m) * x), 2.0);
}
c_m =     private
s_m =     private
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c_m, s_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    code = cos((2.0d0 * x)) / (((s_m * c_m) * x) ** 2.0d0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	return Math.cos((2.0 * x)) / Math.pow(((s_m * c_m) * x), 2.0);
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	return math.cos((2.0 * x)) / math.pow(((s_m * c_m) * x), 2.0)
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	return Float64(cos(Float64(2.0 * x)) / (Float64(Float64(s_m * c_m) * x) ^ 2.0))
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	tmp = cos((2.0 * x)) / (((s_m * c_m) * x) ^ 2.0);
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[Power[N[(N[(s$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\cos \left(2 \cdot x\right)}{{\left(\left(s\_m \cdot c\_m\right) \cdot x\right)}^{2}}
\end{array}
Derivation
  1. Initial program 66.6%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
    6. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
    7. associate-*r*N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
    8. unpow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
    9. associate-*r*N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
    10. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
    11. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    12. lower-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    13. lower-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
    14. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    15. lower-*.f6497.9

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
  4. Applied rewrites97.9%

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
  5. Add Preprocessing

Alternative 4: 96.6% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \frac{1}{\left(s\_m \cdot x\right) \cdot c\_m}\\ \frac{\cos \left(2 \cdot x\right)}{\frac{1}{t\_0 \cdot t\_0}} \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* (* s_m x) c_m))))
   (/ (cos (* 2.0 x)) (/ 1.0 (* t_0 t_0)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = 1.0 / ((s_m * x) * c_m);
	return cos((2.0 * x)) / (1.0 / (t_0 * t_0));
}
c_m =     private
s_m =     private
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c_m, s_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    t_0 = 1.0d0 / ((s_m * x) * c_m)
    code = cos((2.0d0 * x)) / (1.0d0 / (t_0 * t_0))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = 1.0 / ((s_m * x) * c_m);
	return Math.cos((2.0 * x)) / (1.0 / (t_0 * t_0));
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = 1.0 / ((s_m * x) * c_m)
	return math.cos((2.0 * x)) / (1.0 / (t_0 * t_0))
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(1.0 / Float64(Float64(s_m * x) * c_m))
	return Float64(cos(Float64(2.0 * x)) / Float64(1.0 / Float64(t_0 * t_0)))
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	t_0 = 1.0 / ((s_m * x) * c_m);
	tmp = cos((2.0 * x)) / (1.0 / (t_0 * t_0));
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(1.0 / N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \frac{1}{\left(s\_m \cdot x\right) \cdot c\_m}\\
\frac{\cos \left(2 \cdot x\right)}{\frac{1}{t\_0 \cdot t\_0}}
\end{array}
\end{array}
Derivation
  1. Initial program 66.6%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
    6. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
    7. associate-*r*N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
    8. unpow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
    9. associate-*r*N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
    10. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
    11. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    12. lower-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    13. lower-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
    14. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    15. lower-*.f6497.9

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
  4. Applied rewrites97.9%

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
  5. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{2}} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
    5. associate-*r*N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
    6. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}}^{2}} \]
    7. metadata-evalN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\left(s \cdot x\right) \cdot c\right)}^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)}}} \]
    8. pow-negN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\frac{1}{{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}}}} \]
    9. metadata-evalN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{{\left(\left(s \cdot x\right) \cdot c\right)}^{\color{blue}{\left(\mathsf{neg}\left(2\right)\right)}}}} \]
    10. pow-flipN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\color{blue}{\frac{1}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}}}} \]
    11. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}}}} \]
    12. unpow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1}{\color{blue}{{c}^{2} \cdot {\left(s \cdot x\right)}^{2}}}}} \]
    13. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot {x}^{2}\right)}}}} \]
    14. lower-/.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\frac{1}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}}}} \]
    15. metadata-evalN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{\color{blue}{1 \cdot 1}}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}}} \]
    16. *-commutativeN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}}}} \]
    17. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{{\left(s \cdot x\right)}^{2}} \cdot {c}^{2}}}} \]
    18. unpow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}}}} \]
    19. unpow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\frac{1 \cdot 1}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}}}} \]
    20. times-fracN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\color{blue}{\frac{1}{\left(s \cdot x\right) \cdot c} \cdot \frac{1}{\left(s \cdot x\right) \cdot c}}}} \]
    21. lower-*.f64N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\frac{1}{\color{blue}{\frac{1}{\left(s \cdot x\right) \cdot c} \cdot \frac{1}{\left(s \cdot x\right) \cdot c}}}} \]
  6. Applied rewrites97.4%

    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\frac{1}{\frac{1}{\left(s \cdot x\right) \cdot c} \cdot \frac{1}{\left(s \cdot x\right) \cdot c}}}} \]
  7. Add Preprocessing

Alternative 5: 92.6% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\ t_1 := t\_0 \cdot t\_0\\ t_2 := \cos \left(2 \cdot x\right)\\ t_3 := \frac{t\_2}{\left(\left(\left(\left(s\_m \cdot s\_m\right) \cdot x\right) \cdot x\right) \cdot c\_m\right) \cdot c\_m}\\ t_4 := \frac{t\_2}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)}\\ t_5 := \frac{{\cos x}^{2}}{t\_1} - \frac{{\sin x}^{2}}{t\_1}\\ \mathbf{if}\;t\_4 \leq -\infty:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_4 \leq 4 \cdot 10^{+243}:\\ \;\;\;\;t\_5\\ \mathbf{elif}\;t\_4 \leq \infty:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;t\_5\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* (* s_m x) c_m))
        (t_1 (* t_0 t_0))
        (t_2 (cos (* 2.0 x)))
        (t_3 (/ t_2 (* (* (* (* (* s_m s_m) x) x) c_m) c_m)))
        (t_4 (/ t_2 (* (pow c_m 2.0) (* (* x (pow s_m 2.0)) x))))
        (t_5 (- (/ (pow (cos x) 2.0) t_1) (/ (pow (sin x) 2.0) t_1))))
   (if (<= t_4 (- INFINITY))
     t_3
     (if (<= t_4 4e+243) t_5 (if (<= t_4 INFINITY) t_3 t_5)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = (s_m * x) * c_m;
	double t_1 = t_0 * t_0;
	double t_2 = cos((2.0 * x));
	double t_3 = t_2 / (((((s_m * s_m) * x) * x) * c_m) * c_m);
	double t_4 = t_2 / (pow(c_m, 2.0) * ((x * pow(s_m, 2.0)) * x));
	double t_5 = (pow(cos(x), 2.0) / t_1) - (pow(sin(x), 2.0) / t_1);
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = t_3;
	} else if (t_4 <= 4e+243) {
		tmp = t_5;
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = t_3;
	} else {
		tmp = t_5;
	}
	return tmp;
}
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = (s_m * x) * c_m;
	double t_1 = t_0 * t_0;
	double t_2 = Math.cos((2.0 * x));
	double t_3 = t_2 / (((((s_m * s_m) * x) * x) * c_m) * c_m);
	double t_4 = t_2 / (Math.pow(c_m, 2.0) * ((x * Math.pow(s_m, 2.0)) * x));
	double t_5 = (Math.pow(Math.cos(x), 2.0) / t_1) - (Math.pow(Math.sin(x), 2.0) / t_1);
	double tmp;
	if (t_4 <= -Double.POSITIVE_INFINITY) {
		tmp = t_3;
	} else if (t_4 <= 4e+243) {
		tmp = t_5;
	} else if (t_4 <= Double.POSITIVE_INFINITY) {
		tmp = t_3;
	} else {
		tmp = t_5;
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = (s_m * x) * c_m
	t_1 = t_0 * t_0
	t_2 = math.cos((2.0 * x))
	t_3 = t_2 / (((((s_m * s_m) * x) * x) * c_m) * c_m)
	t_4 = t_2 / (math.pow(c_m, 2.0) * ((x * math.pow(s_m, 2.0)) * x))
	t_5 = (math.pow(math.cos(x), 2.0) / t_1) - (math.pow(math.sin(x), 2.0) / t_1)
	tmp = 0
	if t_4 <= -math.inf:
		tmp = t_3
	elif t_4 <= 4e+243:
		tmp = t_5
	elif t_4 <= math.inf:
		tmp = t_3
	else:
		tmp = t_5
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(Float64(s_m * x) * c_m)
	t_1 = Float64(t_0 * t_0)
	t_2 = cos(Float64(2.0 * x))
	t_3 = Float64(t_2 / Float64(Float64(Float64(Float64(Float64(s_m * s_m) * x) * x) * c_m) * c_m))
	t_4 = Float64(t_2 / Float64((c_m ^ 2.0) * Float64(Float64(x * (s_m ^ 2.0)) * x)))
	t_5 = Float64(Float64((cos(x) ^ 2.0) / t_1) - Float64((sin(x) ^ 2.0) / t_1))
	tmp = 0.0
	if (t_4 <= Float64(-Inf))
		tmp = t_3;
	elseif (t_4 <= 4e+243)
		tmp = t_5;
	elseif (t_4 <= Inf)
		tmp = t_3;
	else
		tmp = t_5;
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = (s_m * x) * c_m;
	t_1 = t_0 * t_0;
	t_2 = cos((2.0 * x));
	t_3 = t_2 / (((((s_m * s_m) * x) * x) * c_m) * c_m);
	t_4 = t_2 / ((c_m ^ 2.0) * ((x * (s_m ^ 2.0)) * x));
	t_5 = ((cos(x) ^ 2.0) / t_1) - ((sin(x) ^ 2.0) / t_1);
	tmp = 0.0;
	if (t_4 <= -Inf)
		tmp = t_3;
	elseif (t_4 <= 4e+243)
		tmp = t_5;
	elseif (t_4 <= Inf)
		tmp = t_3;
	else
		tmp = t_5;
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[(N[(N[(N[(N[(s$95$m * s$95$m), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * c$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] - N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], t$95$3, If[LessEqual[t$95$4, 4e+243], t$95$5, If[LessEqual[t$95$4, Infinity], t$95$3, t$95$5]]]]]]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
t_1 := t\_0 \cdot t\_0\\
t_2 := \cos \left(2 \cdot x\right)\\
t_3 := \frac{t\_2}{\left(\left(\left(\left(s\_m \cdot s\_m\right) \cdot x\right) \cdot x\right) \cdot c\_m\right) \cdot c\_m}\\
t_4 := \frac{t\_2}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)}\\
t_5 := \frac{{\cos x}^{2}}{t\_1} - \frac{{\sin x}^{2}}{t\_1}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_4 \leq 4 \cdot 10^{+243}:\\
\;\;\;\;t\_5\\

\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;t\_3\\

\mathbf{else}:\\
\;\;\;\;t\_5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -inf.0 or 4.0000000000000003e243 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0

    1. Initial program 78.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}} \]
      10. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left({s}^{2} \cdot {x}^{2}\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
      11. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left({s}^{2} \cdot {x}^{2}\right) \cdot c\right) \cdot c}} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left({s}^{2} \cdot {x}^{2}\right) \cdot c\right) \cdot c}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left({s}^{2} \cdot {x}^{2}\right) \cdot c\right)} \cdot c} \]
      14. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot c\right) \cdot c} \]
      15. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(\left({s}^{2} \cdot x\right) \cdot x\right)} \cdot c\right) \cdot c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right) \cdot c\right) \cdot c} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot c\right) \cdot c} \]
      18. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right) \cdot c\right) \cdot c} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right) \cdot c\right) \cdot c} \]
      20. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(\color{blue}{\left(s \cdot s\right)} \cdot x\right) \cdot x\right) \cdot c\right) \cdot c} \]
      21. lower-*.f6482.5

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(\color{blue}{\left(s \cdot s\right)} \cdot x\right) \cdot x\right) \cdot c\right) \cdot c} \]
    4. Applied rewrites82.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c}} \]

    if -inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < 4.0000000000000003e243 or +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 59.8%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6498.5

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites98.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    5. Applied rewrites89.2%

      \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)} - \frac{{\sin x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 89.9% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\ t_1 := t\_0 \cdot t\_0\\ t_2 := \cos \left(2 \cdot x\right)\\ t_3 := \frac{t\_2}{\left(\left(\left(c\_m \cdot c\_m\right) \cdot x\right) \cdot \left(s\_m \cdot s\_m\right)\right) \cdot x}\\ t_4 := \frac{t\_2}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)}\\ t_5 := \frac{{\cos x}^{2}}{t\_1} - \frac{{\sin x}^{2}}{t\_1}\\ \mathbf{if}\;t\_4 \leq -\infty:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_4 \leq 5 \cdot 10^{+283}:\\ \;\;\;\;t\_5\\ \mathbf{elif}\;t\_4 \leq \infty:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;t\_5\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* (* s_m x) c_m))
        (t_1 (* t_0 t_0))
        (t_2 (cos (* 2.0 x)))
        (t_3 (/ t_2 (* (* (* (* c_m c_m) x) (* s_m s_m)) x)))
        (t_4 (/ t_2 (* (pow c_m 2.0) (* (* x (pow s_m 2.0)) x))))
        (t_5 (- (/ (pow (cos x) 2.0) t_1) (/ (pow (sin x) 2.0) t_1))))
   (if (<= t_4 (- INFINITY))
     t_3
     (if (<= t_4 5e+283) t_5 (if (<= t_4 INFINITY) t_3 t_5)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = (s_m * x) * c_m;
	double t_1 = t_0 * t_0;
	double t_2 = cos((2.0 * x));
	double t_3 = t_2 / ((((c_m * c_m) * x) * (s_m * s_m)) * x);
	double t_4 = t_2 / (pow(c_m, 2.0) * ((x * pow(s_m, 2.0)) * x));
	double t_5 = (pow(cos(x), 2.0) / t_1) - (pow(sin(x), 2.0) / t_1);
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = t_3;
	} else if (t_4 <= 5e+283) {
		tmp = t_5;
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = t_3;
	} else {
		tmp = t_5;
	}
	return tmp;
}
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = (s_m * x) * c_m;
	double t_1 = t_0 * t_0;
	double t_2 = Math.cos((2.0 * x));
	double t_3 = t_2 / ((((c_m * c_m) * x) * (s_m * s_m)) * x);
	double t_4 = t_2 / (Math.pow(c_m, 2.0) * ((x * Math.pow(s_m, 2.0)) * x));
	double t_5 = (Math.pow(Math.cos(x), 2.0) / t_1) - (Math.pow(Math.sin(x), 2.0) / t_1);
	double tmp;
	if (t_4 <= -Double.POSITIVE_INFINITY) {
		tmp = t_3;
	} else if (t_4 <= 5e+283) {
		tmp = t_5;
	} else if (t_4 <= Double.POSITIVE_INFINITY) {
		tmp = t_3;
	} else {
		tmp = t_5;
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = (s_m * x) * c_m
	t_1 = t_0 * t_0
	t_2 = math.cos((2.0 * x))
	t_3 = t_2 / ((((c_m * c_m) * x) * (s_m * s_m)) * x)
	t_4 = t_2 / (math.pow(c_m, 2.0) * ((x * math.pow(s_m, 2.0)) * x))
	t_5 = (math.pow(math.cos(x), 2.0) / t_1) - (math.pow(math.sin(x), 2.0) / t_1)
	tmp = 0
	if t_4 <= -math.inf:
		tmp = t_3
	elif t_4 <= 5e+283:
		tmp = t_5
	elif t_4 <= math.inf:
		tmp = t_3
	else:
		tmp = t_5
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(Float64(s_m * x) * c_m)
	t_1 = Float64(t_0 * t_0)
	t_2 = cos(Float64(2.0 * x))
	t_3 = Float64(t_2 / Float64(Float64(Float64(Float64(c_m * c_m) * x) * Float64(s_m * s_m)) * x))
	t_4 = Float64(t_2 / Float64((c_m ^ 2.0) * Float64(Float64(x * (s_m ^ 2.0)) * x)))
	t_5 = Float64(Float64((cos(x) ^ 2.0) / t_1) - Float64((sin(x) ^ 2.0) / t_1))
	tmp = 0.0
	if (t_4 <= Float64(-Inf))
		tmp = t_3;
	elseif (t_4 <= 5e+283)
		tmp = t_5;
	elseif (t_4 <= Inf)
		tmp = t_3;
	else
		tmp = t_5;
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = (s_m * x) * c_m;
	t_1 = t_0 * t_0;
	t_2 = cos((2.0 * x));
	t_3 = t_2 / ((((c_m * c_m) * x) * (s_m * s_m)) * x);
	t_4 = t_2 / ((c_m ^ 2.0) * ((x * (s_m ^ 2.0)) * x));
	t_5 = ((cos(x) ^ 2.0) / t_1) - ((sin(x) ^ 2.0) / t_1);
	tmp = 0.0;
	if (t_4 <= -Inf)
		tmp = t_3;
	elseif (t_4 <= 5e+283)
		tmp = t_5;
	elseif (t_4 <= Inf)
		tmp = t_3;
	else
		tmp = t_5;
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[(N[(N[(N[(c$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision] * N[(s$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] - N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], t$95$3, If[LessEqual[t$95$4, 5e+283], t$95$5, If[LessEqual[t$95$4, Infinity], t$95$3, t$95$5]]]]]]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
t_1 := t\_0 \cdot t\_0\\
t_2 := \cos \left(2 \cdot x\right)\\
t_3 := \frac{t\_2}{\left(\left(\left(c\_m \cdot c\_m\right) \cdot x\right) \cdot \left(s\_m \cdot s\_m\right)\right) \cdot x}\\
t_4 := \frac{t\_2}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)}\\
t_5 := \frac{{\cos x}^{2}}{t\_1} - \frac{{\sin x}^{2}}{t\_1}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{+283}:\\
\;\;\;\;t\_5\\

\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;t\_3\\

\mathbf{else}:\\
\;\;\;\;t\_5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -inf.0 or 5.0000000000000004e283 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0

    1. Initial program 78.3%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}} \]
      7. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}} \]
      8. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left({c}^{2} \cdot x\right) \cdot {s}^{2}\right)} \cdot x} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left({c}^{2} \cdot x\right) \cdot {s}^{2}\right)} \cdot x} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left({c}^{2} \cdot x\right)} \cdot {s}^{2}\right) \cdot x} \]
      11. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left(c \cdot c\right)} \cdot x\right) \cdot {s}^{2}\right) \cdot x} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left(c \cdot c\right)} \cdot x\right) \cdot {s}^{2}\right) \cdot x} \]
      13. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right) \cdot x} \]
      14. lower-*.f6483.3

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right) \cdot x} \]
    4. Applied rewrites83.3%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot s\right)\right) \cdot x}} \]

    if -inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < 5.0000000000000004e283 or +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 60.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6498.5

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites98.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    5. Applied rewrites89.3%

      \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)} - \frac{{\sin x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 85.2% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)}\\ t_1 := \left(s\_m \cdot x\right) \cdot c\_m\\ t_2 := t\_1 \cdot t\_1\\ t_3 := \frac{{\cos x}^{2}}{t\_2} - \frac{{\sin x}^{2}}{t\_2}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{+243}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\frac{\frac{\sin \left(\mathsf{fma}\left(x, 2, \frac{\pi}{2}\right)\right)}{{\left(c\_m \cdot s\_m\right)}^{2}}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* (* x (pow s_m 2.0)) x))))
        (t_1 (* (* s_m x) c_m))
        (t_2 (* t_1 t_1))
        (t_3 (- (/ (pow (cos x) 2.0) t_2) (/ (pow (sin x) 2.0) t_2))))
   (if (<= t_0 4e+243)
     t_3
     (if (<= t_0 INFINITY)
       (/ (/ (sin (fma x 2.0 (/ PI 2.0))) (pow (* c_m s_m) 2.0)) (* x x))
       t_3))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = cos((2.0 * x)) / (pow(c_m, 2.0) * ((x * pow(s_m, 2.0)) * x));
	double t_1 = (s_m * x) * c_m;
	double t_2 = t_1 * t_1;
	double t_3 = (pow(cos(x), 2.0) / t_2) - (pow(sin(x), 2.0) / t_2);
	double tmp;
	if (t_0 <= 4e+243) {
		tmp = t_3;
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = (sin(fma(x, 2.0, (((double) M_PI) / 2.0))) / pow((c_m * s_m), 2.0)) / (x * x);
	} else {
		tmp = t_3;
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(Float64(x * (s_m ^ 2.0)) * x)))
	t_1 = Float64(Float64(s_m * x) * c_m)
	t_2 = Float64(t_1 * t_1)
	t_3 = Float64(Float64((cos(x) ^ 2.0) / t_2) - Float64((sin(x) ^ 2.0) / t_2))
	tmp = 0.0
	if (t_0 <= 4e+243)
		tmp = t_3;
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(sin(fma(x, 2.0, Float64(pi / 2.0))) / (Float64(c_m * s_m) ^ 2.0)) / Float64(x * x));
	else
		tmp = t_3;
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$2), $MachinePrecision] - N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+243], t$95$3, If[LessEqual[t$95$0, Infinity], N[(N[(N[Sin[N[(x * 2.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Power[N[(c$95$m * s$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)}\\
t_1 := \left(s\_m \cdot x\right) \cdot c\_m\\
t_2 := t\_1 \cdot t\_1\\
t_3 := \frac{{\cos x}^{2}}{t\_2} - \frac{{\sin x}^{2}}{t\_2}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+243}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\frac{\sin \left(\mathsf{fma}\left(x, 2, \frac{\pi}{2}\right)\right)}{{\left(c\_m \cdot s\_m\right)}^{2}}}{x \cdot x}\\

\mathbf{else}:\\
\;\;\;\;t\_3\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < 4.0000000000000003e243 or +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 59.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      8. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{{x}^{2}}\right)} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      10. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot {x}^{2}} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
      15. lower-*.f6497.1

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    4. Applied rewrites97.1%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}} \]
    5. Applied rewrites84.2%

      \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)} - \frac{{\sin x}^{2}}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]

    if 4.0000000000000003e243 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0

    1. Initial program 83.3%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      4. cos-2N/A

        \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      9. lift-pow.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      10. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot x\right)}\right) \cdot x} \]
      12. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)} \cdot x} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      14. unpow2N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      15. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
      16. div-subN/A

        \[\leadsto \color{blue}{\frac{\cos x \cdot \cos x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} - \frac{\sin x \cdot \sin x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Applied rewrites5.4%

      \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c} - \frac{{\sin x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c}} \]
    5. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{{c}^{2} \cdot {s}^{2}} - \frac{{\sin x}^{2}}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Applied rewrites82.9%

      \[\leadsto \color{blue}{\frac{\frac{\sin \left(\mathsf{fma}\left(x, 2, \frac{\pi}{2}\right)\right)}{{\left(c \cdot s\right)}^{2}}}{x \cdot x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 71.2% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := {\left(c\_m \cdot x\right)}^{1}\\ t_1 := t\_0 \cdot t\_0\\ \mathbf{if}\;x \leq 2.7 \cdot 10^{+93}:\\ \;\;\;\;\frac{\frac{\sin \left(\mathsf{fma}\left(x, 2, \frac{\pi}{2}\right)\right)}{{\left(c\_m \cdot s\_m\right)}^{2}}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{\cos x}^{2}}{t\_1}}{s\_m \cdot s\_m} - \frac{\frac{{\sin x}^{2}}{t\_1}}{s\_m \cdot s\_m}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (pow (* c_m x) 1.0)) (t_1 (* t_0 t_0)))
   (if (<= x 2.7e+93)
     (/ (/ (sin (fma x 2.0 (/ PI 2.0))) (pow (* c_m s_m) 2.0)) (* x x))
     (-
      (/ (/ (pow (cos x) 2.0) t_1) (* s_m s_m))
      (/ (/ (pow (sin x) 2.0) t_1) (* s_m s_m))))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = pow((c_m * x), 1.0);
	double t_1 = t_0 * t_0;
	double tmp;
	if (x <= 2.7e+93) {
		tmp = (sin(fma(x, 2.0, (((double) M_PI) / 2.0))) / pow((c_m * s_m), 2.0)) / (x * x);
	} else {
		tmp = ((pow(cos(x), 2.0) / t_1) / (s_m * s_m)) - ((pow(sin(x), 2.0) / t_1) / (s_m * s_m));
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * x) ^ 1.0
	t_1 = Float64(t_0 * t_0)
	tmp = 0.0
	if (x <= 2.7e+93)
		tmp = Float64(Float64(sin(fma(x, 2.0, Float64(pi / 2.0))) / (Float64(c_m * s_m) ^ 2.0)) / Float64(x * x));
	else
		tmp = Float64(Float64(Float64((cos(x) ^ 2.0) / t_1) / Float64(s_m * s_m)) - Float64(Float64((sin(x) ^ 2.0) / t_1) / Float64(s_m * s_m)));
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Power[N[(c$95$m * x), $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, If[LessEqual[x, 2.7e+93], N[(N[(N[Sin[N[(x * 2.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Power[N[(c$95$m * s$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] / N[(s$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] / N[(s$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := {\left(c\_m \cdot x\right)}^{1}\\
t_1 := t\_0 \cdot t\_0\\
\mathbf{if}\;x \leq 2.7 \cdot 10^{+93}:\\
\;\;\;\;\frac{\frac{\sin \left(\mathsf{fma}\left(x, 2, \frac{\pi}{2}\right)\right)}{{\left(c\_m \cdot s\_m\right)}^{2}}}{x \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{{\cos x}^{2}}{t\_1}}{s\_m \cdot s\_m} - \frac{\frac{{\sin x}^{2}}{t\_1}}{s\_m \cdot s\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.6999999999999999e93

    1. Initial program 68.3%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      4. cos-2N/A

        \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      9. lift-pow.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      10. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot x\right)}\right) \cdot x} \]
      12. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)} \cdot x} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      14. unpow2N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      15. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
      16. div-subN/A

        \[\leadsto \color{blue}{\frac{\cos x \cdot \cos x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} - \frac{\sin x \cdot \sin x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Applied rewrites39.6%

      \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c} - \frac{{\sin x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c}} \]
    5. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{{c}^{2} \cdot {s}^{2}} - \frac{{\sin x}^{2}}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Applied rewrites74.0%

      \[\leadsto \color{blue}{\frac{\frac{\sin \left(\mathsf{fma}\left(x, 2, \frac{\pi}{2}\right)\right)}{{\left(c \cdot s\right)}^{2}}}{x \cdot x}} \]

    if 2.6999999999999999e93 < x

    1. Initial program 59.6%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      4. cos-2N/A

        \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
      9. lift-pow.f64N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
      10. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot x\right)}\right) \cdot x} \]
      12. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)} \cdot x} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      14. unpow2N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      15. associate-*r*N/A

        \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
      16. div-subN/A

        \[\leadsto \color{blue}{\frac{\cos x \cdot \cos x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} - \frac{\sin x \cdot \sin x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Applied rewrites57.4%

      \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c} - \frac{{\sin x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c}} \]
    5. Taylor expanded in s around 0

      \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{{c}^{2} \cdot {x}^{2}} - \frac{{\sin x}^{2}}{{c}^{2} \cdot {x}^{2}}}{{s}^{2}}} \]
    6. Applied rewrites69.3%

      \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{{\left(c \cdot x\right)}^{1} \cdot {\left(c \cdot x\right)}^{1}}}{s \cdot s} - \frac{\frac{{\sin x}^{2}}{{\left(c \cdot x\right)}^{1} \cdot {\left(c \cdot x\right)}^{1}}}{s \cdot s}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 48.8% accurate, N/A× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := {\left(c\_m \cdot x\right)}^{1}\\ t_1 := t\_0 \cdot t\_0\\ \frac{\frac{{\cos x}^{2}}{t\_1}}{s\_m \cdot s\_m} - \frac{\frac{{\sin x}^{2}}{t\_1}}{s\_m \cdot s\_m} \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (pow (* c_m x) 1.0)) (t_1 (* t_0 t_0)))
   (-
    (/ (/ (pow (cos x) 2.0) t_1) (* s_m s_m))
    (/ (/ (pow (sin x) 2.0) t_1) (* s_m s_m)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = pow((c_m * x), 1.0);
	double t_1 = t_0 * t_0;
	return ((pow(cos(x), 2.0) / t_1) / (s_m * s_m)) - ((pow(sin(x), 2.0) / t_1) / (s_m * s_m));
}
c_m =     private
s_m =     private
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, c_m, s_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: t_1
    t_0 = (c_m * x) ** 1.0d0
    t_1 = t_0 * t_0
    code = (((cos(x) ** 2.0d0) / t_1) / (s_m * s_m)) - (((sin(x) ** 2.0d0) / t_1) / (s_m * s_m))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = Math.pow((c_m * x), 1.0);
	double t_1 = t_0 * t_0;
	return ((Math.pow(Math.cos(x), 2.0) / t_1) / (s_m * s_m)) - ((Math.pow(Math.sin(x), 2.0) / t_1) / (s_m * s_m));
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = math.pow((c_m * x), 1.0)
	t_1 = t_0 * t_0
	return ((math.pow(math.cos(x), 2.0) / t_1) / (s_m * s_m)) - ((math.pow(math.sin(x), 2.0) / t_1) / (s_m * s_m))
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * x) ^ 1.0
	t_1 = Float64(t_0 * t_0)
	return Float64(Float64(Float64((cos(x) ^ 2.0) / t_1) / Float64(s_m * s_m)) - Float64(Float64((sin(x) ^ 2.0) / t_1) / Float64(s_m * s_m)))
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	t_0 = (c_m * x) ^ 1.0;
	t_1 = t_0 * t_0;
	tmp = (((cos(x) ^ 2.0) / t_1) / (s_m * s_m)) - (((sin(x) ^ 2.0) / t_1) / (s_m * s_m));
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Power[N[(c$95$m * x), $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, N[(N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] / N[(s$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] / N[(s$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := {\left(c\_m \cdot x\right)}^{1}\\
t_1 := t\_0 \cdot t\_0\\
\frac{\frac{{\cos x}^{2}}{t\_1}}{s\_m \cdot s\_m} - \frac{\frac{{\sin x}^{2}}{t\_1}}{s\_m \cdot s\_m}
\end{array}
\end{array}
Derivation
  1. Initial program 66.6%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. lift-cos.f64N/A

      \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    4. cos-2N/A

      \[\leadsto \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. lift-pow.f64N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    8. lift-*.f64N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot {s}^{2}\right)} \cdot x\right)} \]
    9. lift-pow.f64N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{{c}^{2} \cdot \left(\left(x \cdot \color{blue}{{s}^{2}}\right) \cdot x\right)} \]
    10. associate-*r*N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right) \cdot x}} \]
    11. *-commutativeN/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot x\right)}\right) \cdot x} \]
    12. associate-*r*N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)} \cdot x} \]
    13. associate-*r*N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
    14. unpow2N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
    15. associate-*r*N/A

      \[\leadsto \frac{\cos x \cdot \cos x - \sin x \cdot \sin x}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    16. div-subN/A

      \[\leadsto \color{blue}{\frac{\cos x \cdot \cos x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} - \frac{\sin x \cdot \sin x}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  4. Applied rewrites42.9%

    \[\leadsto \color{blue}{\frac{{\cos x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c} - \frac{{\sin x}^{2}}{\left(\left(\left(\left(s \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\right) \cdot c}} \]
  5. Taylor expanded in s around 0

    \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{{c}^{2} \cdot {x}^{2}} - \frac{{\sin x}^{2}}{{c}^{2} \cdot {x}^{2}}}{{s}^{2}}} \]
  6. Applied rewrites47.1%

    \[\leadsto \color{blue}{\frac{\frac{{\cos x}^{2}}{{\left(c \cdot x\right)}^{1} \cdot {\left(c \cdot x\right)}^{1}}}{s \cdot s} - \frac{\frac{{\sin x}^{2}}{{\left(c \cdot x\right)}^{1} \cdot {\left(c \cdot x\right)}^{1}}}{s \cdot s}} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025065 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))