mixedcos

Percentage Accurate: 65.9% → 99.4%
Time: 2.9s
Alternatives: 10
Speedup: 2.1×

Specification

?
\[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
(FPCore (x c s)
  :precision binary64
  (/ (cos (* 2 x)) (* (pow c 2) (* (* x (pow s 2)) 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 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2], $MachinePrecision] * N[(N[(x * N[Power[s, 2], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 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: 65.9% accurate, 1.0× speedup?

\[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
(FPCore (x c s)
  :precision binary64
  (/ (cos (* 2 x)) (* (pow c 2) (* (* x (pow s 2)) 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 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2], $MachinePrecision] * N[(N[(x * N[Power[s, 2], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}

Alternative 1: 99.4% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_2 := \left(t\_0 \cdot \left|x\right|\right) \cdot t\_1\\ t_3 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left(-t\_0\right)\\ \mathbf{if}\;\left|x\right| \leq \frac{2993155353253689}{2993155353253689176481146537402947624255349848014848}:\\ \;\;\;\;\frac{1}{t\_3 \cdot t\_3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{t\_2}}{t\_2}\\ \end{array} \]
(FPCore (x c s)
  :precision binary64
  (let* ((t_0 (fmin (fabs c) (fabs s)))
       (t_1 (fmax (fabs c) (fabs s)))
       (t_2 (* (* t_0 (fabs x)) t_1))
       (t_3 (* (* t_1 (fabs x)) (- t_0))))
  (if (<=
       (fabs x)
       2993155353253689/2993155353253689176481146537402947624255349848014848)
    (/ 1 (* t_3 t_3))
    (/ (/ (cos (+ (fabs x) (fabs x))) t_2) t_2))))
double code(double x, double c, double s) {
	double t_0 = fmin(fabs(c), fabs(s));
	double t_1 = fmax(fabs(c), fabs(s));
	double t_2 = (t_0 * fabs(x)) * t_1;
	double t_3 = (t_1 * fabs(x)) * -t_0;
	double tmp;
	if (fabs(x) <= 1e-36) {
		tmp = 1.0 / (t_3 * t_3);
	} else {
		tmp = (cos((fabs(x) + fabs(x))) / t_2) / t_2;
	}
	return tmp;
}
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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = fmin(abs(c), abs(s))
    t_1 = fmax(abs(c), abs(s))
    t_2 = (t_0 * abs(x)) * t_1
    t_3 = (t_1 * abs(x)) * -t_0
    if (abs(x) <= 1d-36) then
        tmp = 1.0d0 / (t_3 * t_3)
    else
        tmp = (cos((abs(x) + abs(x))) / t_2) / t_2
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = fmin(Math.abs(c), Math.abs(s));
	double t_1 = fmax(Math.abs(c), Math.abs(s));
	double t_2 = (t_0 * Math.abs(x)) * t_1;
	double t_3 = (t_1 * Math.abs(x)) * -t_0;
	double tmp;
	if (Math.abs(x) <= 1e-36) {
		tmp = 1.0 / (t_3 * t_3);
	} else {
		tmp = (Math.cos((Math.abs(x) + Math.abs(x))) / t_2) / t_2;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = fmin(math.fabs(c), math.fabs(s))
	t_1 = fmax(math.fabs(c), math.fabs(s))
	t_2 = (t_0 * math.fabs(x)) * t_1
	t_3 = (t_1 * math.fabs(x)) * -t_0
	tmp = 0
	if math.fabs(x) <= 1e-36:
		tmp = 1.0 / (t_3 * t_3)
	else:
		tmp = (math.cos((math.fabs(x) + math.fabs(x))) / t_2) / t_2
	return tmp
function code(x, c, s)
	t_0 = fmin(abs(c), abs(s))
	t_1 = fmax(abs(c), abs(s))
	t_2 = Float64(Float64(t_0 * abs(x)) * t_1)
	t_3 = Float64(Float64(t_1 * abs(x)) * Float64(-t_0))
	tmp = 0.0
	if (abs(x) <= 1e-36)
		tmp = Float64(1.0 / Float64(t_3 * t_3));
	else
		tmp = Float64(Float64(cos(Float64(abs(x) + abs(x))) / t_2) / t_2);
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = min(abs(c), abs(s));
	t_1 = max(abs(c), abs(s));
	t_2 = (t_0 * abs(x)) * t_1;
	t_3 = (t_1 * abs(x)) * -t_0;
	tmp = 0.0;
	if (abs(x) <= 1e-36)
		tmp = 1.0 / (t_3 * t_3);
	else
		tmp = (cos((abs(x) + abs(x))) / t_2) / t_2;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * (-t$95$0)), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 2993155353253689/2993155353253689176481146537402947624255349848014848], N[(1 / N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision] / t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_2 := \left(t\_0 \cdot \left|x\right|\right) \cdot t\_1\\
t_3 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left(-t\_0\right)\\
\mathbf{if}\;\left|x\right| \leq \frac{2993155353253689}{2993155353253689176481146537402947624255349848014848}:\\
\;\;\;\;\frac{1}{t\_3 \cdot t\_3}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{t\_2}}{t\_2}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 9.9999999999999994e-37

    1. Initial program 65.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Step-by-step derivation
      1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
        15. lower-*.f6454.7%

          \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
      3. Applied rewrites54.7%

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

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

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

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

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

          \[\leadsto \frac{1}{\left(\left(s \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(c \cdot c\right)} \]
        6. unswap-sqrN/A

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

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

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

          \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
        10. sqr-neg-revN/A

          \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(c\right)\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
        11. unswap-sqrN/A

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

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

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

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

          \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
        16. lower-neg.f6477.9%

          \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(-c\right)}\right)} \]
      5. Applied rewrites77.9%

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

      if 9.9999999999999994e-37 < x

      1. Initial program 65.9%

        \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. Step-by-step derivation
        1. 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)} \]
        2. count-2-revN/A

          \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
        3. lower-+.f6465.9%

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left({c}^{2} \cdot x\right) \cdot x\right)} \cdot {s}^{2}} \]
        12. lower-*.f6466.0%

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

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

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

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

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

          \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
        18. lower-*.f6466.0%

          \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
      3. Applied rewrites66.0%

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

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

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

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

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

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

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

          \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \color{blue}{\left(c \cdot \left(x \cdot x\right)\right)}\right) \cdot \left(s \cdot s\right)} \]
        8. lower-*.f6466.6%

          \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(c \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \left(s \cdot s\right)} \]
      5. Applied rewrites66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot x\right) \cdot s}}}{\left(s \cdot c\right) \cdot x} \]
        6. lower-*.f6494.8%

          \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot x\right) \cdot s}}}{\left(s \cdot c\right) \cdot x} \]
      9. Applied rewrites94.8%

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

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

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

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

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

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

          \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\left(c \cdot x\right) \cdot s}}{\color{blue}{\left(c \cdot x\right) \cdot s}} \]
      11. Applied rewrites97.3%

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

    Alternative 2: 97.2% accurate, 0.6× speedup?

    \[\begin{array}{l} t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_2 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left(-t\_0\right)\\ \mathbf{if}\;\left|x\right| \leq \frac{2993155353253689}{5986310706507378352962293074805895248510699696029696}:\\ \;\;\;\;\frac{1}{t\_2 \cdot t\_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(\left|x\right| \cdot t\_0\right) \cdot \left(t\_1 \cdot \left(t\_1 \cdot \left(t\_0 \cdot \left|x\right|\right)\right)\right)}\\ \end{array} \]
    (FPCore (x c s)
      :precision binary64
      (let* ((t_0 (fmin (fabs c) (fabs s)))
           (t_1 (fmax (fabs c) (fabs s)))
           (t_2 (* (* t_1 (fabs x)) (- t_0))))
      (if (<=
           (fabs x)
           2993155353253689/5986310706507378352962293074805895248510699696029696)
        (/ 1 (* t_2 t_2))
        (/
         (cos (+ (fabs x) (fabs x)))
         (* (* (fabs x) t_0) (* t_1 (* t_1 (* t_0 (fabs x)))))))))
    double code(double x, double c, double s) {
    	double t_0 = fmin(fabs(c), fabs(s));
    	double t_1 = fmax(fabs(c), fabs(s));
    	double t_2 = (t_1 * fabs(x)) * -t_0;
    	double tmp;
    	if (fabs(x) <= 5e-37) {
    		tmp = 1.0 / (t_2 * t_2);
    	} else {
    		tmp = cos((fabs(x) + fabs(x))) / ((fabs(x) * t_0) * (t_1 * (t_1 * (t_0 * fabs(x)))));
    	}
    	return tmp;
    }
    
    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
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_0 = fmin(abs(c), abs(s))
        t_1 = fmax(abs(c), abs(s))
        t_2 = (t_1 * abs(x)) * -t_0
        if (abs(x) <= 5d-37) then
            tmp = 1.0d0 / (t_2 * t_2)
        else
            tmp = cos((abs(x) + abs(x))) / ((abs(x) * t_0) * (t_1 * (t_1 * (t_0 * abs(x)))))
        end if
        code = tmp
    end function
    
    public static double code(double x, double c, double s) {
    	double t_0 = fmin(Math.abs(c), Math.abs(s));
    	double t_1 = fmax(Math.abs(c), Math.abs(s));
    	double t_2 = (t_1 * Math.abs(x)) * -t_0;
    	double tmp;
    	if (Math.abs(x) <= 5e-37) {
    		tmp = 1.0 / (t_2 * t_2);
    	} else {
    		tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((Math.abs(x) * t_0) * (t_1 * (t_1 * (t_0 * Math.abs(x)))));
    	}
    	return tmp;
    }
    
    def code(x, c, s):
    	t_0 = fmin(math.fabs(c), math.fabs(s))
    	t_1 = fmax(math.fabs(c), math.fabs(s))
    	t_2 = (t_1 * math.fabs(x)) * -t_0
    	tmp = 0
    	if math.fabs(x) <= 5e-37:
    		tmp = 1.0 / (t_2 * t_2)
    	else:
    		tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((math.fabs(x) * t_0) * (t_1 * (t_1 * (t_0 * math.fabs(x)))))
    	return tmp
    
    function code(x, c, s)
    	t_0 = fmin(abs(c), abs(s))
    	t_1 = fmax(abs(c), abs(s))
    	t_2 = Float64(Float64(t_1 * abs(x)) * Float64(-t_0))
    	tmp = 0.0
    	if (abs(x) <= 5e-37)
    		tmp = Float64(1.0 / Float64(t_2 * t_2));
    	else
    		tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(abs(x) * t_0) * Float64(t_1 * Float64(t_1 * Float64(t_0 * abs(x))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, c, s)
    	t_0 = min(abs(c), abs(s));
    	t_1 = max(abs(c), abs(s));
    	t_2 = (t_1 * abs(x)) * -t_0;
    	tmp = 0.0;
    	if (abs(x) <= 5e-37)
    		tmp = 1.0 / (t_2 * t_2);
    	else
    		tmp = cos((abs(x) + abs(x))) / ((abs(x) * t_0) * (t_1 * (t_1 * (t_0 * abs(x)))));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * (-t$95$0)), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 2993155353253689/5986310706507378352962293074805895248510699696029696], N[(1 / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(t$95$1 * N[(t$95$1 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
    
    \begin{array}{l}
    t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
    t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
    t_2 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left(-t\_0\right)\\
    \mathbf{if}\;\left|x\right| \leq \frac{2993155353253689}{5986310706507378352962293074805895248510699696029696}:\\
    \;\;\;\;\frac{1}{t\_2 \cdot t\_2}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(\left|x\right| \cdot t\_0\right) \cdot \left(t\_1 \cdot \left(t\_1 \cdot \left(t\_0 \cdot \left|x\right|\right)\right)\right)}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 4.9999999999999997e-37

      1. Initial program 65.9%

        \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. Taylor expanded in x around 0

        \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      3. Step-by-step derivation
        1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
          15. lower-*.f6454.7%

            \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
        3. Applied rewrites54.7%

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

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

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

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

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

            \[\leadsto \frac{1}{\left(\left(s \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(c \cdot c\right)} \]
          6. unswap-sqrN/A

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

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

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

            \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
          10. sqr-neg-revN/A

            \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(c\right)\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
          11. unswap-sqrN/A

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

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

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

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

            \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
          16. lower-neg.f6477.9%

            \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(-c\right)}\right)} \]
        5. Applied rewrites77.9%

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

        if 4.9999999999999997e-37 < x

        1. Initial program 65.9%

          \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
        2. 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-*.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)}} \]
          3. 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}} \]
          4. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot c\right) \cdot \left(\left(\color{blue}{\left(s \cdot s\right)} \cdot x\right) \cdot c\right)} \]
          18. lower-*.f6478.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(x \cdot c\right) \cdot \left(s \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)} \]
          3. lift-+.f6492.7%

            \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(x \cdot c\right) \cdot \left(s \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)} \]
        7. Applied rewrites92.7%

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

      Alternative 3: 93.2% accurate, 0.6× speedup?

      \[\begin{array}{l} t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_2 := t\_1 \cdot \left|x\right|\\ t_3 := t\_2 \cdot \left(-t\_0\right)\\ \mathbf{if}\;\left|x\right| \leq \frac{7482888383134223}{748288838313422294120286634350736906063837462003712}:\\ \;\;\;\;\frac{1}{t\_3 \cdot t\_3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_1 \cdot \left(t\_2 \cdot \left(t\_0 \cdot \left|x\right|\right)\right)\right) \cdot t\_0}\\ \end{array} \]
      (FPCore (x c s)
        :precision binary64
        (let* ((t_0 (fmin (fabs c) (fabs s)))
             (t_1 (fmax (fabs c) (fabs s)))
             (t_2 (* t_1 (fabs x)))
             (t_3 (* t_2 (- t_0))))
        (if (<=
             (fabs x)
             7482888383134223/748288838313422294120286634350736906063837462003712)
          (/ 1 (* t_3 t_3))
          (/
           (cos (+ (fabs x) (fabs x)))
           (* (* t_1 (* t_2 (* t_0 (fabs x)))) t_0)))))
      double code(double x, double c, double s) {
      	double t_0 = fmin(fabs(c), fabs(s));
      	double t_1 = fmax(fabs(c), fabs(s));
      	double t_2 = t_1 * fabs(x);
      	double t_3 = t_2 * -t_0;
      	double tmp;
      	if (fabs(x) <= 1e-35) {
      		tmp = 1.0 / (t_3 * t_3);
      	} else {
      		tmp = cos((fabs(x) + fabs(x))) / ((t_1 * (t_2 * (t_0 * fabs(x)))) * t_0);
      	}
      	return tmp;
      }
      
      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
          real(8) :: t_0
          real(8) :: t_1
          real(8) :: t_2
          real(8) :: t_3
          real(8) :: tmp
          t_0 = fmin(abs(c), abs(s))
          t_1 = fmax(abs(c), abs(s))
          t_2 = t_1 * abs(x)
          t_3 = t_2 * -t_0
          if (abs(x) <= 1d-35) then
              tmp = 1.0d0 / (t_3 * t_3)
          else
              tmp = cos((abs(x) + abs(x))) / ((t_1 * (t_2 * (t_0 * abs(x)))) * t_0)
          end if
          code = tmp
      end function
      
      public static double code(double x, double c, double s) {
      	double t_0 = fmin(Math.abs(c), Math.abs(s));
      	double t_1 = fmax(Math.abs(c), Math.abs(s));
      	double t_2 = t_1 * Math.abs(x);
      	double t_3 = t_2 * -t_0;
      	double tmp;
      	if (Math.abs(x) <= 1e-35) {
      		tmp = 1.0 / (t_3 * t_3);
      	} else {
      		tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((t_1 * (t_2 * (t_0 * Math.abs(x)))) * t_0);
      	}
      	return tmp;
      }
      
      def code(x, c, s):
      	t_0 = fmin(math.fabs(c), math.fabs(s))
      	t_1 = fmax(math.fabs(c), math.fabs(s))
      	t_2 = t_1 * math.fabs(x)
      	t_3 = t_2 * -t_0
      	tmp = 0
      	if math.fabs(x) <= 1e-35:
      		tmp = 1.0 / (t_3 * t_3)
      	else:
      		tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((t_1 * (t_2 * (t_0 * math.fabs(x)))) * t_0)
      	return tmp
      
      function code(x, c, s)
      	t_0 = fmin(abs(c), abs(s))
      	t_1 = fmax(abs(c), abs(s))
      	t_2 = Float64(t_1 * abs(x))
      	t_3 = Float64(t_2 * Float64(-t_0))
      	tmp = 0.0
      	if (abs(x) <= 1e-35)
      		tmp = Float64(1.0 / Float64(t_3 * t_3));
      	else
      		tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(t_1 * Float64(t_2 * Float64(t_0 * abs(x)))) * t_0));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, c, s)
      	t_0 = min(abs(c), abs(s));
      	t_1 = max(abs(c), abs(s));
      	t_2 = t_1 * abs(x);
      	t_3 = t_2 * -t_0;
      	tmp = 0.0;
      	if (abs(x) <= 1e-35)
      		tmp = 1.0 / (t_3 * t_3);
      	else
      		tmp = cos((abs(x) + abs(x))) / ((t_1 * (t_2 * (t_0 * abs(x)))) * t_0);
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * (-t$95$0)), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 7482888383134223/748288838313422294120286634350736906063837462003712], N[(1 / N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(t$95$1 * N[(t$95$2 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
      t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
      t_2 := t\_1 \cdot \left|x\right|\\
      t_3 := t\_2 \cdot \left(-t\_0\right)\\
      \mathbf{if}\;\left|x\right| \leq \frac{7482888383134223}{748288838313422294120286634350736906063837462003712}:\\
      \;\;\;\;\frac{1}{t\_3 \cdot t\_3}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_1 \cdot \left(t\_2 \cdot \left(t\_0 \cdot \left|x\right|\right)\right)\right) \cdot t\_0}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 1e-35

        1. Initial program 65.9%

          \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
        2. Taylor expanded in x around 0

          \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
        3. Step-by-step derivation
          1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
            15. lower-*.f6454.7%

              \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
          3. Applied rewrites54.7%

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

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

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

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

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

              \[\leadsto \frac{1}{\left(\left(s \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(c \cdot c\right)} \]
            6. unswap-sqrN/A

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

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

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

              \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
            10. sqr-neg-revN/A

              \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(c\right)\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
            11. unswap-sqrN/A

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

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

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

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

              \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
            16. lower-neg.f6477.9%

              \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(-c\right)}\right)} \]
          5. Applied rewrites77.9%

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

          if 1e-35 < x

          1. Initial program 65.9%

            \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
          2. 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. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot x\right)\right)\right) \cdot c} \]
            3. lift-+.f6489.6%

              \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot x\right)\right)\right) \cdot c} \]
          7. Applied rewrites89.6%

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

        Alternative 4: 88.0% accurate, 0.6× speedup?

        \[\begin{array}{l} t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_2 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left(-t\_0\right)\\ \mathbf{if}\;\left|x\right| \leq \frac{940834429856889}{618970019642690137449562112}:\\ \;\;\;\;\frac{1}{t\_2 \cdot t\_2}\\ \mathbf{elif}\;\left|x\right| \leq 274999999999999995274917990641983180319600859774341068865301343307866076067129259703961489954509259284386354608521075666727825095781944535915128938299392:\\ \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_0 \cdot \left(t\_0 \cdot \left(\left|x\right| \cdot \left|x\right|\right)\right)\right) \cdot \left(t\_1 \cdot t\_1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left(-t\_1\right)\right)}^{2}}\\ \end{array} \]
        (FPCore (x c s)
          :precision binary64
          (let* ((t_0 (fmin (fabs c) (fabs s)))
               (t_1 (fmax (fabs c) (fabs s)))
               (t_2 (* (* t_1 (fabs x)) (- t_0))))
          (if (<= (fabs x) 940834429856889/618970019642690137449562112)
            (/ 1 (* t_2 t_2))
            (if (<=
                 (fabs x)
                 274999999999999995274917990641983180319600859774341068865301343307866076067129259703961489954509259284386354608521075666727825095781944535915128938299392)
              (/
               (cos (+ (fabs x) (fabs x)))
               (* (* t_0 (* t_0 (* (fabs x) (fabs x)))) (* t_1 t_1)))
              (/ 1 (pow (* (* t_0 (fabs x)) (- t_1)) 2))))))
        double code(double x, double c, double s) {
        	double t_0 = fmin(fabs(c), fabs(s));
        	double t_1 = fmax(fabs(c), fabs(s));
        	double t_2 = (t_1 * fabs(x)) * -t_0;
        	double tmp;
        	if (fabs(x) <= 1.52e-12) {
        		tmp = 1.0 / (t_2 * t_2);
        	} else if (fabs(x) <= 2.75e+152) {
        		tmp = cos((fabs(x) + fabs(x))) / ((t_0 * (t_0 * (fabs(x) * fabs(x)))) * (t_1 * t_1));
        	} else {
        		tmp = 1.0 / pow(((t_0 * fabs(x)) * -t_1), 2.0);
        	}
        	return tmp;
        }
        
        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
            real(8) :: t_0
            real(8) :: t_1
            real(8) :: t_2
            real(8) :: tmp
            t_0 = fmin(abs(c), abs(s))
            t_1 = fmax(abs(c), abs(s))
            t_2 = (t_1 * abs(x)) * -t_0
            if (abs(x) <= 1.52d-12) then
                tmp = 1.0d0 / (t_2 * t_2)
            else if (abs(x) <= 2.75d+152) then
                tmp = cos((abs(x) + abs(x))) / ((t_0 * (t_0 * (abs(x) * abs(x)))) * (t_1 * t_1))
            else
                tmp = 1.0d0 / (((t_0 * abs(x)) * -t_1) ** 2.0d0)
            end if
            code = tmp
        end function
        
        public static double code(double x, double c, double s) {
        	double t_0 = fmin(Math.abs(c), Math.abs(s));
        	double t_1 = fmax(Math.abs(c), Math.abs(s));
        	double t_2 = (t_1 * Math.abs(x)) * -t_0;
        	double tmp;
        	if (Math.abs(x) <= 1.52e-12) {
        		tmp = 1.0 / (t_2 * t_2);
        	} else if (Math.abs(x) <= 2.75e+152) {
        		tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((t_0 * (t_0 * (Math.abs(x) * Math.abs(x)))) * (t_1 * t_1));
        	} else {
        		tmp = 1.0 / Math.pow(((t_0 * Math.abs(x)) * -t_1), 2.0);
        	}
        	return tmp;
        }
        
        def code(x, c, s):
        	t_0 = fmin(math.fabs(c), math.fabs(s))
        	t_1 = fmax(math.fabs(c), math.fabs(s))
        	t_2 = (t_1 * math.fabs(x)) * -t_0
        	tmp = 0
        	if math.fabs(x) <= 1.52e-12:
        		tmp = 1.0 / (t_2 * t_2)
        	elif math.fabs(x) <= 2.75e+152:
        		tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((t_0 * (t_0 * (math.fabs(x) * math.fabs(x)))) * (t_1 * t_1))
        	else:
        		tmp = 1.0 / math.pow(((t_0 * math.fabs(x)) * -t_1), 2.0)
        	return tmp
        
        function code(x, c, s)
        	t_0 = fmin(abs(c), abs(s))
        	t_1 = fmax(abs(c), abs(s))
        	t_2 = Float64(Float64(t_1 * abs(x)) * Float64(-t_0))
        	tmp = 0.0
        	if (abs(x) <= 1.52e-12)
        		tmp = Float64(1.0 / Float64(t_2 * t_2));
        	elseif (abs(x) <= 2.75e+152)
        		tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(t_0 * Float64(t_0 * Float64(abs(x) * abs(x)))) * Float64(t_1 * t_1)));
        	else
        		tmp = Float64(1.0 / (Float64(Float64(t_0 * abs(x)) * Float64(-t_1)) ^ 2.0));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, c, s)
        	t_0 = min(abs(c), abs(s));
        	t_1 = max(abs(c), abs(s));
        	t_2 = (t_1 * abs(x)) * -t_0;
        	tmp = 0.0;
        	if (abs(x) <= 1.52e-12)
        		tmp = 1.0 / (t_2 * t_2);
        	elseif (abs(x) <= 2.75e+152)
        		tmp = cos((abs(x) + abs(x))) / ((t_0 * (t_0 * (abs(x) * abs(x)))) * (t_1 * t_1));
        	else
        		tmp = 1.0 / (((t_0 * abs(x)) * -t_1) ^ 2.0);
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * (-t$95$0)), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 940834429856889/618970019642690137449562112], N[(1 / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[x], $MachinePrecision], 274999999999999995274917990641983180319600859774341068865301343307866076067129259703961489954509259284386354608521075666727825095781944535915128938299392], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(t$95$0 * N[(t$95$0 * N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[Power[N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * (-t$95$1)), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
        t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
        t_2 := \left(t\_1 \cdot \left|x\right|\right) \cdot \left(-t\_0\right)\\
        \mathbf{if}\;\left|x\right| \leq \frac{940834429856889}{618970019642690137449562112}:\\
        \;\;\;\;\frac{1}{t\_2 \cdot t\_2}\\
        
        \mathbf{elif}\;\left|x\right| \leq 274999999999999995274917990641983180319600859774341068865301343307866076067129259703961489954509259284386354608521075666727825095781944535915128938299392:\\
        \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_0 \cdot \left(t\_0 \cdot \left(\left|x\right| \cdot \left|x\right|\right)\right)\right) \cdot \left(t\_1 \cdot t\_1\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{1}{{\left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left(-t\_1\right)\right)}^{2}}\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if x < 1.52e-12

          1. Initial program 65.9%

            \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
          2. Taylor expanded in x around 0

            \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
          3. Step-by-step derivation
            1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
              15. lower-*.f6454.7%

                \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
            3. Applied rewrites54.7%

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

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

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

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

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

                \[\leadsto \frac{1}{\left(\left(s \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(c \cdot c\right)} \]
              6. unswap-sqrN/A

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

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

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

                \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
              10. sqr-neg-revN/A

                \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(c\right)\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
              11. unswap-sqrN/A

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

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

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

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

                \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
              16. lower-neg.f6477.9%

                \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(-c\right)}\right)} \]
            5. Applied rewrites77.9%

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

            if 1.52e-12 < x < 2.75e152

            1. Initial program 65.9%

              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            2. Step-by-step derivation
              1. 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)} \]
              2. count-2-revN/A

                \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              3. lower-+.f6465.9%

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left({c}^{2} \cdot x\right) \cdot x\right)} \cdot {s}^{2}} \]
              12. lower-*.f6466.0%

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

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

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

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

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

                \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
              18. lower-*.f6466.0%

                \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
            3. Applied rewrites66.0%

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

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

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

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

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

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

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

                \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \color{blue}{\left(c \cdot \left(x \cdot x\right)\right)}\right) \cdot \left(s \cdot s\right)} \]
              8. lower-*.f6466.6%

                \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(c \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \left(s \cdot s\right)} \]
            5. Applied rewrites66.6%

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

            if 2.75e152 < x

            1. Initial program 65.9%

              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            2. Taylor expanded in x around 0

              \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            3. Step-by-step derivation
              1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                15. lower-*.f6454.7%

                  \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
              3. Applied rewrites54.7%

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

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

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

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

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

                  \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot \left(s \cdot s\right)} \]
                6. pow2N/A

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

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

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

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

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

                  \[\leadsto \frac{1}{{\left(c \cdot x\right)}^{2} \cdot \color{blue}{\left(s \cdot s\right)}} \]
                12. sqr-neg-revN/A

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

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

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

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

                  \[\leadsto \frac{1}{{\color{blue}{\left(\left(c \cdot x\right) \cdot \left(\mathsf{neg}\left(s\right)\right)\right)}}^{2}} \]
                17. lower-neg.f6478.1%

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

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

            Alternative 5: 86.8% accurate, 2.1× speedup?

            \[\begin{array}{l} t_0 := s \cdot \left|x\right|\\ t_1 := t\_0 \cdot \left(-c\right)\\ \mathbf{if}\;\left|x\right| \leq \frac{822752278660603}{822752278660603021077484591278675252491367932816789931674304512}:\\ \;\;\;\;\frac{1}{t\_1 \cdot t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(c \cdot \left(s \cdot c\right)\right) \cdot \left(t\_0 \cdot \left|x\right|\right)}\\ \end{array} \]
            (FPCore (x c s)
              :precision binary64
              (let* ((t_0 (* s (fabs x))) (t_1 (* t_0 (- c))))
              (if (<=
                   (fabs x)
                   822752278660603/822752278660603021077484591278675252491367932816789931674304512)
                (/ 1 (* t_1 t_1))
                (/
                 (cos (+ (fabs x) (fabs x)))
                 (* (* c (* s c)) (* t_0 (fabs x)))))))
            double code(double x, double c, double s) {
            	double t_0 = s * fabs(x);
            	double t_1 = t_0 * -c;
            	double tmp;
            	if (fabs(x) <= 1e-48) {
            		tmp = 1.0 / (t_1 * t_1);
            	} else {
            		tmp = cos((fabs(x) + fabs(x))) / ((c * (s * c)) * (t_0 * fabs(x)));
            	}
            	return tmp;
            }
            
            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
                real(8) :: t_0
                real(8) :: t_1
                real(8) :: tmp
                t_0 = s * abs(x)
                t_1 = t_0 * -c
                if (abs(x) <= 1d-48) then
                    tmp = 1.0d0 / (t_1 * t_1)
                else
                    tmp = cos((abs(x) + abs(x))) / ((c * (s * c)) * (t_0 * abs(x)))
                end if
                code = tmp
            end function
            
            public static double code(double x, double c, double s) {
            	double t_0 = s * Math.abs(x);
            	double t_1 = t_0 * -c;
            	double tmp;
            	if (Math.abs(x) <= 1e-48) {
            		tmp = 1.0 / (t_1 * t_1);
            	} else {
            		tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((c * (s * c)) * (t_0 * Math.abs(x)));
            	}
            	return tmp;
            }
            
            def code(x, c, s):
            	t_0 = s * math.fabs(x)
            	t_1 = t_0 * -c
            	tmp = 0
            	if math.fabs(x) <= 1e-48:
            		tmp = 1.0 / (t_1 * t_1)
            	else:
            		tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((c * (s * c)) * (t_0 * math.fabs(x)))
            	return tmp
            
            function code(x, c, s)
            	t_0 = Float64(s * abs(x))
            	t_1 = Float64(t_0 * Float64(-c))
            	tmp = 0.0
            	if (abs(x) <= 1e-48)
            		tmp = Float64(1.0 / Float64(t_1 * t_1));
            	else
            		tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(c * Float64(s * c)) * Float64(t_0 * abs(x))));
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, c, s)
            	t_0 = s * abs(x);
            	t_1 = t_0 * -c;
            	tmp = 0.0;
            	if (abs(x) <= 1e-48)
            		tmp = 1.0 / (t_1 * t_1);
            	else
            		tmp = cos((abs(x) + abs(x))) / ((c * (s * c)) * (t_0 * abs(x)));
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * (-c)), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 822752278660603/822752278660603021077484591278675252491367932816789931674304512], N[(1 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(c * N[(s * c), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
            
            \begin{array}{l}
            t_0 := s \cdot \left|x\right|\\
            t_1 := t\_0 \cdot \left(-c\right)\\
            \mathbf{if}\;\left|x\right| \leq \frac{822752278660603}{822752278660603021077484591278675252491367932816789931674304512}:\\
            \;\;\;\;\frac{1}{t\_1 \cdot t\_1}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(c \cdot \left(s \cdot c\right)\right) \cdot \left(t\_0 \cdot \left|x\right|\right)}\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < 9.9999999999999997e-49

              1. Initial program 65.9%

                \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              2. Taylor expanded in x around 0

                \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              3. Step-by-step derivation
                1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                  15. lower-*.f6454.7%

                    \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                3. Applied rewrites54.7%

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

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

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

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

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

                    \[\leadsto \frac{1}{\left(\left(s \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(c \cdot c\right)} \]
                  6. unswap-sqrN/A

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

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

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

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
                  10. sqr-neg-revN/A

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(c\right)\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
                  11. unswap-sqrN/A

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

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

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

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

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
                  16. lower-neg.f6477.9%

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(-c\right)}\right)} \]
                5. Applied rewrites77.9%

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

                if 9.9999999999999997e-49 < x

                1. Initial program 65.9%

                  \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                2. Step-by-step derivation
                  1. 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)} \]
                  2. count-2-revN/A

                    \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                  3. lower-+.f6465.9%

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left({c}^{2} \cdot x\right) \cdot x\right)} \cdot {s}^{2}} \]
                  12. lower-*.f6466.0%

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

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

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

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

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

                    \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
                  18. lower-*.f6466.0%

                    \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
                3. Applied rewrites66.0%

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

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

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

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

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

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

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

                    \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \color{blue}{\left(c \cdot \left(x \cdot x\right)\right)}\right) \cdot \left(s \cdot s\right)} \]
                  8. lower-*.f6466.6%

                    \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(c \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \left(s \cdot s\right)} \]
                5. Applied rewrites66.6%

                  \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)} \cdot \left(s \cdot s\right)} \]
                6. Applied rewrites80.9%

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

              Alternative 6: 79.0% accurate, 0.7× speedup?

              \[\begin{array}{l} t_0 := \left(\mathsf{max}\left(\left|c\right|, \left|s\right|\right) \cdot x\right) \cdot \left(-\mathsf{min}\left(\left|c\right|, \left|s\right|\right)\right)\\ \frac{1}{t\_0 \cdot t\_0} \end{array} \]
              (FPCore (x c s)
                :precision binary64
                (let* ((t_0
                      (*
                       (* (fmax (fabs c) (fabs s)) x)
                       (- (fmin (fabs c) (fabs s))))))
                (/ 1 (* t_0 t_0))))
              double code(double x, double c, double s) {
              	double t_0 = (fmax(fabs(c), fabs(s)) * x) * -fmin(fabs(c), fabs(s));
              	return 1.0 / (t_0 * t_0);
              }
              
              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
                  real(8) :: t_0
                  t_0 = (fmax(abs(c), abs(s)) * x) * -fmin(abs(c), abs(s))
                  code = 1.0d0 / (t_0 * t_0)
              end function
              
              public static double code(double x, double c, double s) {
              	double t_0 = (fmax(Math.abs(c), Math.abs(s)) * x) * -fmin(Math.abs(c), Math.abs(s));
              	return 1.0 / (t_0 * t_0);
              }
              
              def code(x, c, s):
              	t_0 = (fmax(math.fabs(c), math.fabs(s)) * x) * -fmin(math.fabs(c), math.fabs(s))
              	return 1.0 / (t_0 * t_0)
              
              function code(x, c, s)
              	t_0 = Float64(Float64(fmax(abs(c), abs(s)) * x) * Float64(-fmin(abs(c), abs(s))))
              	return Float64(1.0 / Float64(t_0 * t_0))
              end
              
              function tmp = code(x, c, s)
              	t_0 = (max(abs(c), abs(s)) * x) * -min(abs(c), abs(s));
              	tmp = 1.0 / (t_0 * t_0);
              end
              
              code[x_, c_, s_] := Block[{t$95$0 = N[(N[(N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision] * (-N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, N[(1 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              t_0 := \left(\mathsf{max}\left(\left|c\right|, \left|s\right|\right) \cdot x\right) \cdot \left(-\mathsf{min}\left(\left|c\right|, \left|s\right|\right)\right)\\
              \frac{1}{t\_0 \cdot t\_0}
              \end{array}
              
              Derivation
              1. Initial program 65.9%

                \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              2. Taylor expanded in x around 0

                \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              3. Step-by-step derivation
                1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                  15. lower-*.f6454.7%

                    \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                3. Applied rewrites54.7%

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

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

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

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

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

                    \[\leadsto \frac{1}{\left(\left(s \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(c \cdot c\right)} \]
                  6. unswap-sqrN/A

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

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

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

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
                  10. sqr-neg-revN/A

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(\mathsf{neg}\left(c\right)\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
                  11. unswap-sqrN/A

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

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

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

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

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}} \]
                  16. lower-neg.f6477.9%

                    \[\leadsto \frac{1}{\left(\left(s \cdot x\right) \cdot \left(-c\right)\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(-c\right)}\right)} \]
                5. Applied rewrites77.9%

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

                Alternative 7: 77.7% accurate, 0.5× speedup?

                \[\begin{array}{l} t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ t_2 := t\_0 \cdot t\_1\\ \mathbf{if}\;{t\_1}^{2} \leq \frac{4586997231980143}{4586997231980143023221641790604173881593129978336562247475177678773845752176969616140037106220251373109248}:\\ \;\;\;\;\frac{1}{t\_2 \cdot \left(x \cdot \left(t\_2 \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(\left(t\_1 \cdot t\_1\right) \cdot x\right) \cdot t\_0\right) \cdot \left(t\_0 \cdot x\right)}\\ \end{array} \]
                (FPCore (x c s)
                  :precision binary64
                  (let* ((t_0 (fmax (fabs c) (fabs s)))
                       (t_1 (fmin (fabs c) (fabs s)))
                       (t_2 (* t_0 t_1)))
                  (if (<=
                       (pow t_1 2)
                       4586997231980143/4586997231980143023221641790604173881593129978336562247475177678773845752176969616140037106220251373109248)
                    (/ 1 (* t_2 (* x (* t_2 x))))
                    (/ 1 (* (* (* (* t_1 t_1) x) t_0) (* t_0 x))))))
                double code(double x, double c, double s) {
                	double t_0 = fmax(fabs(c), fabs(s));
                	double t_1 = fmin(fabs(c), fabs(s));
                	double t_2 = t_0 * t_1;
                	double tmp;
                	if (pow(t_1, 2.0) <= 1e-90) {
                		tmp = 1.0 / (t_2 * (x * (t_2 * x)));
                	} else {
                		tmp = 1.0 / ((((t_1 * t_1) * x) * t_0) * (t_0 * x));
                	}
                	return tmp;
                }
                
                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
                    real(8) :: t_0
                    real(8) :: t_1
                    real(8) :: t_2
                    real(8) :: tmp
                    t_0 = fmax(abs(c), abs(s))
                    t_1 = fmin(abs(c), abs(s))
                    t_2 = t_0 * t_1
                    if ((t_1 ** 2.0d0) <= 1d-90) then
                        tmp = 1.0d0 / (t_2 * (x * (t_2 * x)))
                    else
                        tmp = 1.0d0 / ((((t_1 * t_1) * x) * t_0) * (t_0 * x))
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double c, double s) {
                	double t_0 = fmax(Math.abs(c), Math.abs(s));
                	double t_1 = fmin(Math.abs(c), Math.abs(s));
                	double t_2 = t_0 * t_1;
                	double tmp;
                	if (Math.pow(t_1, 2.0) <= 1e-90) {
                		tmp = 1.0 / (t_2 * (x * (t_2 * x)));
                	} else {
                		tmp = 1.0 / ((((t_1 * t_1) * x) * t_0) * (t_0 * x));
                	}
                	return tmp;
                }
                
                def code(x, c, s):
                	t_0 = fmax(math.fabs(c), math.fabs(s))
                	t_1 = fmin(math.fabs(c), math.fabs(s))
                	t_2 = t_0 * t_1
                	tmp = 0
                	if math.pow(t_1, 2.0) <= 1e-90:
                		tmp = 1.0 / (t_2 * (x * (t_2 * x)))
                	else:
                		tmp = 1.0 / ((((t_1 * t_1) * x) * t_0) * (t_0 * x))
                	return tmp
                
                function code(x, c, s)
                	t_0 = fmax(abs(c), abs(s))
                	t_1 = fmin(abs(c), abs(s))
                	t_2 = Float64(t_0 * t_1)
                	tmp = 0.0
                	if ((t_1 ^ 2.0) <= 1e-90)
                		tmp = Float64(1.0 / Float64(t_2 * Float64(x * Float64(t_2 * x))));
                	else
                		tmp = Float64(1.0 / Float64(Float64(Float64(Float64(t_1 * t_1) * x) * t_0) * Float64(t_0 * x)));
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, c, s)
                	t_0 = max(abs(c), abs(s));
                	t_1 = min(abs(c), abs(s));
                	t_2 = t_0 * t_1;
                	tmp = 0.0;
                	if ((t_1 ^ 2.0) <= 1e-90)
                		tmp = 1.0 / (t_2 * (x * (t_2 * x)));
                	else
                		tmp = 1.0 / ((((t_1 * t_1) * x) * t_0) * (t_0 * x));
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[LessEqual[N[Power[t$95$1, 2], $MachinePrecision], 4586997231980143/4586997231980143023221641790604173881593129978336562247475177678773845752176969616140037106220251373109248], N[(1 / N[(t$95$2 * N[(x * N[(t$95$2 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * x), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                
                \begin{array}{l}
                t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
                t_1 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
                t_2 := t\_0 \cdot t\_1\\
                \mathbf{if}\;{t\_1}^{2} \leq \frac{4586997231980143}{4586997231980143023221641790604173881593129978336562247475177678773845752176969616140037106220251373109248}:\\
                \;\;\;\;\frac{1}{t\_2 \cdot \left(x \cdot \left(t\_2 \cdot x\right)\right)}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{1}{\left(\left(\left(t\_1 \cdot t\_1\right) \cdot x\right) \cdot t\_0\right) \cdot \left(t\_0 \cdot x\right)}\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (pow.f64 c #s(literal 2 binary64)) < 9.9999999999999999e-91

                  1. Initial program 65.9%

                    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                  2. Taylor expanded in x around 0

                    \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                  3. Step-by-step derivation
                    1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                      15. lower-*.f6454.7%

                        \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                    3. Applied rewrites54.7%

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

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

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

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

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

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

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

                        \[\leadsto \frac{1}{\left(s \cdot s\right) \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
                      8. unswap-sqrN/A

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

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

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

                        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot s\right)} \cdot \left(\left(c \cdot x\right) \cdot \left(c \cdot x\right)\right)} \]
                      12. swap-sqrN/A

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right)} \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)} \]
                      23. lower-*.f6475.0%

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

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

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

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

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

                        \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)} \]
                    5. Applied rewrites75.7%

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

                    if 9.9999999999999999e-91 < (pow.f64 c #s(literal 2 binary64))

                    1. Initial program 65.9%

                      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                    2. Taylor expanded in x around 0

                      \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                    3. Step-by-step derivation
                      1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \frac{1}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \color{blue}{\left(s \cdot x\right)}} \]
                        23. lower-*.f6466.4%

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

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

                    Alternative 8: 77.1% accurate, 0.6× speedup?

                    \[\begin{array}{l} t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_2 := t\_1 \cdot t\_0\\ \mathbf{if}\;t\_0 \leq \frac{2758407706096627}{81129638414606681695789005144064}:\\ \;\;\;\;\frac{1}{t\_2 \cdot \left(x \cdot \left(t\_2 \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t\_0 \cdot \left(\left(\left(t\_1 \cdot x\right) \cdot t\_1\right) \cdot \left(t\_0 \cdot x\right)\right)}\\ \end{array} \]
                    (FPCore (x c s)
                      :precision binary64
                      (let* ((t_0 (fmin (fabs c) (fabs s)))
                           (t_1 (fmax (fabs c) (fabs s)))
                           (t_2 (* t_1 t_0)))
                      (if (<= t_0 2758407706096627/81129638414606681695789005144064)
                        (/ 1 (* t_2 (* x (* t_2 x))))
                        (/ 1 (* t_0 (* (* (* t_1 x) t_1) (* t_0 x)))))))
                    double code(double x, double c, double s) {
                    	double t_0 = fmin(fabs(c), fabs(s));
                    	double t_1 = fmax(fabs(c), fabs(s));
                    	double t_2 = t_1 * t_0;
                    	double tmp;
                    	if (t_0 <= 3.4e-17) {
                    		tmp = 1.0 / (t_2 * (x * (t_2 * x)));
                    	} else {
                    		tmp = 1.0 / (t_0 * (((t_1 * x) * t_1) * (t_0 * x)));
                    	}
                    	return tmp;
                    }
                    
                    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
                        real(8) :: t_0
                        real(8) :: t_1
                        real(8) :: t_2
                        real(8) :: tmp
                        t_0 = fmin(abs(c), abs(s))
                        t_1 = fmax(abs(c), abs(s))
                        t_2 = t_1 * t_0
                        if (t_0 <= 3.4d-17) then
                            tmp = 1.0d0 / (t_2 * (x * (t_2 * x)))
                        else
                            tmp = 1.0d0 / (t_0 * (((t_1 * x) * t_1) * (t_0 * x)))
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double c, double s) {
                    	double t_0 = fmin(Math.abs(c), Math.abs(s));
                    	double t_1 = fmax(Math.abs(c), Math.abs(s));
                    	double t_2 = t_1 * t_0;
                    	double tmp;
                    	if (t_0 <= 3.4e-17) {
                    		tmp = 1.0 / (t_2 * (x * (t_2 * x)));
                    	} else {
                    		tmp = 1.0 / (t_0 * (((t_1 * x) * t_1) * (t_0 * x)));
                    	}
                    	return tmp;
                    }
                    
                    def code(x, c, s):
                    	t_0 = fmin(math.fabs(c), math.fabs(s))
                    	t_1 = fmax(math.fabs(c), math.fabs(s))
                    	t_2 = t_1 * t_0
                    	tmp = 0
                    	if t_0 <= 3.4e-17:
                    		tmp = 1.0 / (t_2 * (x * (t_2 * x)))
                    	else:
                    		tmp = 1.0 / (t_0 * (((t_1 * x) * t_1) * (t_0 * x)))
                    	return tmp
                    
                    function code(x, c, s)
                    	t_0 = fmin(abs(c), abs(s))
                    	t_1 = fmax(abs(c), abs(s))
                    	t_2 = Float64(t_1 * t_0)
                    	tmp = 0.0
                    	if (t_0 <= 3.4e-17)
                    		tmp = Float64(1.0 / Float64(t_2 * Float64(x * Float64(t_2 * x))));
                    	else
                    		tmp = Float64(1.0 / Float64(t_0 * Float64(Float64(Float64(t_1 * x) * t_1) * Float64(t_0 * x))));
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, c, s)
                    	t_0 = min(abs(c), abs(s));
                    	t_1 = max(abs(c), abs(s));
                    	t_2 = t_1 * t_0;
                    	tmp = 0.0;
                    	if (t_0 <= 3.4e-17)
                    		tmp = 1.0 / (t_2 * (x * (t_2 * x)));
                    	else
                    		tmp = 1.0 / (t_0 * (((t_1 * x) * t_1) * (t_0 * x)));
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, 2758407706096627/81129638414606681695789005144064], N[(1 / N[(t$95$2 * N[(x * N[(t$95$2 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(t$95$0 * N[(N[(N[(t$95$1 * x), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                    
                    \begin{array}{l}
                    t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
                    t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
                    t_2 := t\_1 \cdot t\_0\\
                    \mathbf{if}\;t\_0 \leq \frac{2758407706096627}{81129638414606681695789005144064}:\\
                    \;\;\;\;\frac{1}{t\_2 \cdot \left(x \cdot \left(t\_2 \cdot x\right)\right)}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\frac{1}{t\_0 \cdot \left(\left(\left(t\_1 \cdot x\right) \cdot t\_1\right) \cdot \left(t\_0 \cdot x\right)\right)}\\
                    
                    
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if c < 3.3999999999999998e-17

                      1. Initial program 65.9%

                        \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                      2. Taylor expanded in x around 0

                        \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                          15. lower-*.f6454.7%

                            \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                        3. Applied rewrites54.7%

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

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

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

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

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

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

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

                            \[\leadsto \frac{1}{\left(s \cdot s\right) \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
                          8. unswap-sqrN/A

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

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

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

                            \[\leadsto \frac{1}{\color{blue}{\left(s \cdot s\right)} \cdot \left(\left(c \cdot x\right) \cdot \left(c \cdot x\right)\right)} \]
                          12. swap-sqrN/A

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right)} \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)} \]
                          23. lower-*.f6475.0%

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

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

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

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

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

                            \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)} \]
                        5. Applied rewrites75.7%

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

                        if 3.3999999999999998e-17 < c

                        1. Initial program 65.9%

                          \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                        3. Step-by-step derivation
                          1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                            15. lower-*.f6454.7%

                              \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                          3. Applied rewrites54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{\left(c \cdot x\right)}} \]
                          5. Applied rewrites71.7%

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

                        Alternative 9: 76.0% accurate, 0.6× speedup?

                        \[\begin{array}{l} t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\ t_1 := t\_0 \cdot x\\ t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\ \mathbf{if}\;t\_0 \leq 460000000000000022101119877342656515916467987006775686626865640412119103751870846467046189291054240972989870508637752971162791533089976828878079167552007296402010877485466082369922318385290320066955959683353273171968:\\ \;\;\;\;\frac{1}{t\_2 \cdot \left(\left(t\_1 \cdot t\_0\right) \cdot \left(t\_2 \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(t\_2 \cdot \left(t\_0 \cdot t\_2\right)\right) \cdot \left(t\_1 \cdot x\right)}\\ \end{array} \]
                        (FPCore (x c s)
                          :precision binary64
                          (let* ((t_0 (fmax (fabs c) (fabs s)))
                               (t_1 (* t_0 x))
                               (t_2 (fmin (fabs c) (fabs s))))
                          (if (<=
                               t_0
                               460000000000000022101119877342656515916467987006775686626865640412119103751870846467046189291054240972989870508637752971162791533089976828878079167552007296402010877485466082369922318385290320066955959683353273171968)
                            (/ 1 (* t_2 (* (* t_1 t_0) (* t_2 x))))
                            (/ 1 (* (* t_2 (* t_0 t_2)) (* t_1 x))))))
                        double code(double x, double c, double s) {
                        	double t_0 = fmax(fabs(c), fabs(s));
                        	double t_1 = t_0 * x;
                        	double t_2 = fmin(fabs(c), fabs(s));
                        	double tmp;
                        	if (t_0 <= 4.6e+215) {
                        		tmp = 1.0 / (t_2 * ((t_1 * t_0) * (t_2 * x)));
                        	} else {
                        		tmp = 1.0 / ((t_2 * (t_0 * t_2)) * (t_1 * x));
                        	}
                        	return tmp;
                        }
                        
                        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
                            real(8) :: t_0
                            real(8) :: t_1
                            real(8) :: t_2
                            real(8) :: tmp
                            t_0 = fmax(abs(c), abs(s))
                            t_1 = t_0 * x
                            t_2 = fmin(abs(c), abs(s))
                            if (t_0 <= 4.6d+215) then
                                tmp = 1.0d0 / (t_2 * ((t_1 * t_0) * (t_2 * x)))
                            else
                                tmp = 1.0d0 / ((t_2 * (t_0 * t_2)) * (t_1 * x))
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double c, double s) {
                        	double t_0 = fmax(Math.abs(c), Math.abs(s));
                        	double t_1 = t_0 * x;
                        	double t_2 = fmin(Math.abs(c), Math.abs(s));
                        	double tmp;
                        	if (t_0 <= 4.6e+215) {
                        		tmp = 1.0 / (t_2 * ((t_1 * t_0) * (t_2 * x)));
                        	} else {
                        		tmp = 1.0 / ((t_2 * (t_0 * t_2)) * (t_1 * x));
                        	}
                        	return tmp;
                        }
                        
                        def code(x, c, s):
                        	t_0 = fmax(math.fabs(c), math.fabs(s))
                        	t_1 = t_0 * x
                        	t_2 = fmin(math.fabs(c), math.fabs(s))
                        	tmp = 0
                        	if t_0 <= 4.6e+215:
                        		tmp = 1.0 / (t_2 * ((t_1 * t_0) * (t_2 * x)))
                        	else:
                        		tmp = 1.0 / ((t_2 * (t_0 * t_2)) * (t_1 * x))
                        	return tmp
                        
                        function code(x, c, s)
                        	t_0 = fmax(abs(c), abs(s))
                        	t_1 = Float64(t_0 * x)
                        	t_2 = fmin(abs(c), abs(s))
                        	tmp = 0.0
                        	if (t_0 <= 4.6e+215)
                        		tmp = Float64(1.0 / Float64(t_2 * Float64(Float64(t_1 * t_0) * Float64(t_2 * x))));
                        	else
                        		tmp = Float64(1.0 / Float64(Float64(t_2 * Float64(t_0 * t_2)) * Float64(t_1 * x)));
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, c, s)
                        	t_0 = max(abs(c), abs(s));
                        	t_1 = t_0 * x;
                        	t_2 = min(abs(c), abs(s));
                        	tmp = 0.0;
                        	if (t_0 <= 4.6e+215)
                        		tmp = 1.0 / (t_2 * ((t_1 * t_0) * (t_2 * x)));
                        	else
                        		tmp = 1.0 / ((t_2 * (t_0 * t_2)) * (t_1 * x));
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * x), $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 460000000000000022101119877342656515916467987006775686626865640412119103751870846467046189291054240972989870508637752971162791533089976828878079167552007296402010877485466082369922318385290320066955959683353273171968], N[(1 / N[(t$95$2 * N[(N[(t$95$1 * t$95$0), $MachinePrecision] * N[(t$95$2 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                        
                        \begin{array}{l}
                        t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
                        t_1 := t\_0 \cdot x\\
                        t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
                        \mathbf{if}\;t\_0 \leq 460000000000000022101119877342656515916467987006775686626865640412119103751870846467046189291054240972989870508637752971162791533089976828878079167552007296402010877485466082369922318385290320066955959683353273171968:\\
                        \;\;\;\;\frac{1}{t\_2 \cdot \left(\left(t\_1 \cdot t\_0\right) \cdot \left(t\_2 \cdot x\right)\right)}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\frac{1}{\left(t\_2 \cdot \left(t\_0 \cdot t\_2\right)\right) \cdot \left(t\_1 \cdot x\right)}\\
                        
                        
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if s < 4.6000000000000002e215

                          1. Initial program 65.9%

                            \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                          2. Taylor expanded in x around 0

                            \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                          3. Step-by-step derivation
                            1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                              15. lower-*.f6454.7%

                                \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                            3. Applied rewrites54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{\left(c \cdot x\right)}} \]
                            5. Applied rewrites71.7%

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

                            if 4.6000000000000002e215 < s

                            1. Initial program 65.9%

                              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                            2. Taylor expanded in x around 0

                              \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                            3. Step-by-step derivation
                              1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                                15. lower-*.f6454.7%

                                  \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                              3. Applied rewrites54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \frac{1}{\left(c \cdot \color{blue}{\left(s \cdot c\right)}\right) \cdot \left(\left(s \cdot x\right) \cdot x\right)} \]
                                20. lower-*.f6469.3%

                                  \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot c\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot x\right)}} \]
                              5. Applied rewrites69.3%

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

                            Alternative 10: 71.9% accurate, 0.8× speedup?

                            \[\frac{1}{\mathsf{min}\left(c, s\right) \cdot \left(\left(\left(\mathsf{max}\left(c, s\right) \cdot x\right) \cdot \mathsf{max}\left(c, s\right)\right) \cdot \left(\mathsf{min}\left(c, s\right) \cdot x\right)\right)} \]
                            (FPCore (x c s)
                              :precision binary64
                              (/
                             1
                             (* (fmin c s) (* (* (* (fmax c s) x) (fmax c s)) (* (fmin c s) x)))))
                            double code(double x, double c, double s) {
                            	return 1.0 / (fmin(c, s) * (((fmax(c, s) * x) * fmax(c, s)) * (fmin(c, s) * 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 = 1.0d0 / (fmin(c, s) * (((fmax(c, s) * x) * fmax(c, s)) * (fmin(c, s) * x)))
                            end function
                            
                            public static double code(double x, double c, double s) {
                            	return 1.0 / (fmin(c, s) * (((fmax(c, s) * x) * fmax(c, s)) * (fmin(c, s) * x)));
                            }
                            
                            def code(x, c, s):
                            	return 1.0 / (fmin(c, s) * (((fmax(c, s) * x) * fmax(c, s)) * (fmin(c, s) * x)))
                            
                            function code(x, c, s)
                            	return Float64(1.0 / Float64(fmin(c, s) * Float64(Float64(Float64(fmax(c, s) * x) * fmax(c, s)) * Float64(fmin(c, s) * x))))
                            end
                            
                            function tmp = code(x, c, s)
                            	tmp = 1.0 / (min(c, s) * (((max(c, s) * x) * max(c, s)) * (min(c, s) * x)));
                            end
                            
                            code[x_, c_, s_] := N[(1 / N[(N[Min[c, s], $MachinePrecision] * N[(N[(N[(N[Max[c, s], $MachinePrecision] * x), $MachinePrecision] * N[Max[c, s], $MachinePrecision]), $MachinePrecision] * N[(N[Min[c, s], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                            
                            \frac{1}{\mathsf{min}\left(c, s\right) \cdot \left(\left(\left(\mathsf{max}\left(c, s\right) \cdot x\right) \cdot \mathsf{max}\left(c, s\right)\right) \cdot \left(\mathsf{min}\left(c, s\right) \cdot x\right)\right)}
                            
                            Derivation
                            1. Initial program 65.9%

                              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                            2. Taylor expanded in x around 0

                              \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                            3. Step-by-step derivation
                              1. Applied rewrites58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \frac{1}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(c \cdot c\right)} \]
                                15. lower-*.f6454.7%

                                  \[\leadsto \frac{1}{\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)\right) \cdot \left(c \cdot c\right)} \]
                              3. Applied rewrites54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{\left(c \cdot x\right)}} \]
                              5. Applied rewrites71.7%

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

                              Reproduce

                              ?
                              herbie shell --seed 2025285 -o generate:evaluate
                              (FPCore (x c s)
                                :name "mixedcos"
                                :precision binary64
                                (/ (cos (* 2 x)) (* (pow c 2) (* (* x (pow s 2)) x))))