mixedcos

Percentage Accurate: 67.7% → 99.6%
Time: 19.5s
Alternatives: 13
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 99.6% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{\cos \left(x\_m \cdot -2\right)}{t\_0}\\


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

    1. Initial program 64.3%

      \[\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. associate-/r*64.3%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out64.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg64.3%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out64.3%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in64.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval64.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*52.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative52.6%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow252.6%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr84.2%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
      11. unpow284.2%

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*83.7%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified83.7%

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity83.7%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      2. pow-flip84.0%

        \[\leadsto 1 \cdot \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      3. metadata-eval84.0%

        \[\leadsto 1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}} \]
    9. Applied egg-rr84.0%

      \[\leadsto \color{blue}{1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
    10. Step-by-step derivation
      1. *-lft-identity84.0%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      2. associate-*r*84.3%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{-2} \]
      3. *-commutative84.3%

        \[\leadsto {\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{-2} \]
      4. associate-*r*84.5%

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
    11. Simplified84.5%

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

    if 6.9999999999999998e-9 < x

    1. Initial program 68.6%

      \[\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. associate-/r*68.6%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg68.6%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out68.6%

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out68.6%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in68.6%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval68.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*63.1%

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
      5. swap-sqr77.6%

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
      10. unpow277.7%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      11. swap-sqr95.2%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
      12. unpow295.2%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity91.6%

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

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

        \[\leadsto \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)} \cdot \frac{\cos \left(x \cdot -2\right)}{s \cdot \left(c \cdot x\right)}} \]
    9. Applied egg-rr92.2%

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)} \cdot \frac{\cos \left(x \cdot -2\right)}{s \cdot \left(c \cdot x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-9}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(x \cdot c\right)} \cdot \frac{\cos \left(x \cdot -2\right)}{s \cdot \left(x \cdot c\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 96.0% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot -2\right)}{\left(c\_m \cdot s\_m\right) \cdot \left(x\_m \cdot \left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)\right)}\\


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

    1. Initial program 64.4%

      \[\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. associate-/r*64.3%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out64.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg64.3%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out64.3%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in64.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval64.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*52.1%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative52.1%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow252.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
      8. unpow271.0%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
      9. unpow271.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr83.4%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*82.9%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified82.9%

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity82.9%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      2. pow-flip83.3%

        \[\leadsto 1 \cdot \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      3. metadata-eval83.3%

        \[\leadsto 1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}} \]
    9. Applied egg-rr83.3%

      \[\leadsto \color{blue}{1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
    10. Step-by-step derivation
      1. *-lft-identity83.3%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      2. associate-*r*83.6%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{-2} \]
      3. *-commutative83.6%

        \[\leadsto {\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{-2} \]
      4. associate-*r*83.8%

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
    11. Simplified83.8%

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

    if 9.2000000000000005e-60 < x

    1. Initial program 68.1%

      \[\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. associate-/r*68.1%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg68.1%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out68.1%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg68.1%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out68.1%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in68.1%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval68.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*63.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      11. swap-sqr95.6%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
      12. unpow295.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. unpow261.4%

        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*60.9%

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

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

      \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 9.2 \cdot 10^{-60}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot -2\right)}{\left(c \cdot s\right) \cdot \left(x \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.7% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot -2\right)}{\left(x\_m \cdot c\_m\right) \cdot \left(s\_m \cdot \left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)\right)}\\


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

    1. Initial program 64.1%

      \[\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. associate-/r*64.1%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg64.1%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out64.1%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg64.1%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out64.1%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in64.1%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval64.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*52.3%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative52.3%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow252.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr84.1%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*83.6%

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

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

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity83.6%

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

        \[\leadsto 1 \cdot \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      3. metadata-eval83.9%

        \[\leadsto 1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}} \]
    9. Applied egg-rr83.9%

      \[\leadsto \color{blue}{1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
    10. Step-by-step derivation
      1. *-lft-identity83.9%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      2. associate-*r*84.3%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{-2} \]
      3. *-commutative84.3%

        \[\leadsto {\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{-2} \]
      4. associate-*r*84.4%

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
    11. Simplified84.4%

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

    if 2.4000000000000001e-26 < x

    1. Initial program 69.0%

      \[\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. associate-/r*69.0%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg69.0%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out69.0%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg69.0%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out69.0%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in69.0%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval69.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*63.6%

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
      5. swap-sqr77.9%

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      11. swap-sqr95.3%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
      12. unpow295.3%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. unpow291.7%

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

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

      \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(\left(s \cdot \left(c \cdot x\right)\right) \cdot s\right) \cdot \left(c \cdot x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-26}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot -2\right)}{\left(x \cdot c\right) \cdot \left(s \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.7% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x\_m \cdot -2\right)}{s\_m \cdot \left(\left(x\_m \cdot c\_m\right) \cdot \left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)\right)}\\


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

    1. Initial program 64.1%

      \[\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. associate-/r*64.1%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg64.1%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out64.1%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg64.1%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out64.1%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in64.1%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval64.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*52.3%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative52.3%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow252.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr84.1%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*83.6%

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

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

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity83.6%

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

        \[\leadsto 1 \cdot \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      3. metadata-eval83.9%

        \[\leadsto 1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}} \]
    9. Applied egg-rr83.9%

      \[\leadsto \color{blue}{1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
    10. Step-by-step derivation
      1. *-lft-identity83.9%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      2. associate-*r*84.3%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{-2} \]
      3. *-commutative84.3%

        \[\leadsto {\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{-2} \]
      4. associate-*r*84.4%

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
    11. Simplified84.4%

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

    if 1.1000000000000001e-25 < x

    1. Initial program 69.0%

      \[\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. associate-/r*69.0%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg69.0%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out69.0%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg69.0%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out69.0%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in69.0%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval69.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*63.6%

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
      5. swap-sqr77.9%

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      11. swap-sqr95.3%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
      12. unpow295.3%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. unpow291.7%

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot x\right) \cdot s\right)}} \]
      3. associate-*r*89.3%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(c \cdot x\right)\right) \cdot s}} \]
    9. Applied egg-rr89.3%

      \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(c \cdot x\right)\right) \cdot s}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{-25}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot -2\right)}{s \cdot \left(\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 79.6% accurate, 2.7× speedup?

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

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


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

    1. Initial program 66.7%

      \[\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. associate-/r*66.7%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg66.7%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out66.7%

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out66.7%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in66.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*53.2%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative53.2%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow253.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
      8. unpow269.9%

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr82.6%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*82.1%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified82.1%

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity82.1%

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

        \[\leadsto 1 \cdot \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      3. metadata-eval82.5%

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

      \[\leadsto \color{blue}{1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
    10. Step-by-step derivation
      1. *-lft-identity82.5%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      2. associate-*r*82.7%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{-2} \]
      3. *-commutative82.7%

        \[\leadsto {\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{-2} \]
      4. associate-*r*82.9%

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
    11. Simplified82.9%

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

    if 8.20000000000000011e30 < x

    1. Initial program 62.3%

      \[\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. associate-/r*62.3%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg62.3%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out62.3%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval62.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*46.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative46.6%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow246.6%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr57.3%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*56.7%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified56.7%

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

        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.1%

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
    10. Taylor expanded in s around 0 56.0%

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

      \[\leadsto \color{blue}{-1 \cdot {\left(\frac{\frac{1}{s}}{x \cdot c}\right)}^{2}} \]
    12. Step-by-step derivation
      1. neg-mul-164.5%

        \[\leadsto \color{blue}{-{\left(\frac{\frac{1}{s}}{x \cdot c}\right)}^{2}} \]
      2. associate-/l/64.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.2 \cdot 10^{+30}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;-{\left(\frac{1}{s \cdot \left(x \cdot c\right)}\right)}^{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 79.5% accurate, 2.8× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-1}{s\_m}}{x\_m \cdot c\_m}}{x\_m \cdot \left(c\_m \cdot s\_m\right)}\\


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

    1. Initial program 66.7%

      \[\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. associate-/r*66.7%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg66.7%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out66.7%

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out66.7%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in66.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*53.2%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative53.2%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow253.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
      8. unpow269.9%

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr82.6%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*82.1%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified82.1%

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity82.1%

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

        \[\leadsto 1 \cdot \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      3. metadata-eval82.5%

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

      \[\leadsto \color{blue}{1 \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
    10. Step-by-step derivation
      1. *-lft-identity82.5%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      2. associate-*r*82.7%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{-2} \]
      3. *-commutative82.7%

        \[\leadsto {\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{-2} \]
      4. associate-*r*82.9%

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
    11. Simplified82.9%

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

    if 8.20000000000000011e30 < x

    1. Initial program 62.3%

      \[\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. associate-/r*62.3%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg62.3%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out62.3%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval62.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*46.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative46.6%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow246.6%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr57.3%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*56.7%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified56.7%

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

        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.1%

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. associate-*r*56.1%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.7%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      4. associate-*r*56.8%

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

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

        \[\leadsto \frac{1}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
      7. pow-flip57.4%

        \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{\left(-2\right)}} \]
      8. associate-*r*56.9%

        \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{\left(-2\right)} \]
      9. *-commutative56.9%

        \[\leadsto {\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{\left(-2\right)} \]
      10. metadata-eval56.9%

        \[\leadsto {\left(\left(s \cdot c\right) \cdot x\right)}^{\color{blue}{-2}} \]
      11. pow-prod-down53.6%

        \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
      12. *-commutative53.6%

        \[\leadsto \color{blue}{{x}^{-2} \cdot {\left(s \cdot c\right)}^{-2}} \]
      13. sqr-pow53.6%

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{-2}{2}\right)} \cdot {x}^{\left(\frac{-2}{2}\right)}\right)} \cdot {\left(s \cdot c\right)}^{-2} \]
      14. associate-*l*56.3%

        \[\leadsto \color{blue}{{x}^{\left(\frac{-2}{2}\right)} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right)} \]
      15. metadata-eval56.3%

        \[\leadsto {x}^{\color{blue}{-1}} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      16. unpow-156.3%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      17. metadata-eval56.3%

        \[\leadsto \frac{1}{x} \cdot \left({x}^{\color{blue}{-1}} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      18. unpow-156.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.2 \cdot 10^{+30}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{s}}{x \cdot c}}{x \cdot \left(c \cdot s\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 79.7% accurate, 15.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\ \\ \begin{array}{l} \mathbf{if}\;c\_m \leq 2 \cdot 10^{-43}:\\ \;\;\;\;\frac{\frac{\frac{\frac{1}{s\_m}}{c\_m}}{x\_m}}{x\_m \cdot \left(c\_m \cdot s\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s\_m \cdot \left(x\_m \cdot c\_m\right)} \cdot \frac{1}{c\_m \cdot \left(x\_m \cdot s\_m\right)}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
 :precision binary64
 (if (<= c_m 2e-43)
   (/ (/ (/ (/ 1.0 s_m) c_m) x_m) (* x_m (* c_m s_m)))
   (* (/ 1.0 (* s_m (* x_m c_m))) (/ 1.0 (* c_m (* x_m s_m))))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
	double tmp;
	if (c_m <= 2e-43) {
		tmp = (((1.0 / s_m) / c_m) / x_m) / (x_m * (c_m * s_m));
	} else {
		tmp = (1.0 / (s_m * (x_m * c_m))) * (1.0 / (c_m * (x_m * s_m)));
	}
	return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: tmp
    if (c_m <= 2d-43) then
        tmp = (((1.0d0 / s_m) / c_m) / x_m) / (x_m * (c_m * s_m))
    else
        tmp = (1.0d0 / (s_m * (x_m * c_m))) * (1.0d0 / (c_m * (x_m * s_m)))
    end if
    code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
	double tmp;
	if (c_m <= 2e-43) {
		tmp = (((1.0 / s_m) / c_m) / x_m) / (x_m * (c_m * s_m));
	} else {
		tmp = (1.0 / (s_m * (x_m * c_m))) * (1.0 / (c_m * (x_m * s_m)));
	}
	return tmp;
}
x_m = math.fabs(x)
c_m = math.fabs(c)
s_m = math.fabs(s)
[x_m, c_m, s_m] = sort([x_m, c_m, s_m])
def code(x_m, c_m, s_m):
	tmp = 0
	if c_m <= 2e-43:
		tmp = (((1.0 / s_m) / c_m) / x_m) / (x_m * (c_m * s_m))
	else:
		tmp = (1.0 / (s_m * (x_m * c_m))) * (1.0 / (c_m * (x_m * s_m)))
	return tmp
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
x_m, c_m, s_m = sort([x_m, c_m, s_m])
function code(x_m, c_m, s_m)
	tmp = 0.0
	if (c_m <= 2e-43)
		tmp = Float64(Float64(Float64(Float64(1.0 / s_m) / c_m) / x_m) / Float64(x_m * Float64(c_m * s_m)));
	else
		tmp = Float64(Float64(1.0 / Float64(s_m * Float64(x_m * c_m))) * Float64(1.0 / Float64(c_m * Float64(x_m * s_m))));
	end
	return tmp
end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
	tmp = 0.0;
	if (c_m <= 2e-43)
		tmp = (((1.0 / s_m) / c_m) / x_m) / (x_m * (c_m * s_m));
	else
		tmp = (1.0 / (s_m * (x_m * c_m))) * (1.0 / (c_m * (x_m * s_m)));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := If[LessEqual[c$95$m, 2e-43], N[(N[(N[(N[(1.0 / s$95$m), $MachinePrecision] / c$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] / N[(x$95$m * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;c\_m \leq 2 \cdot 10^{-43}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{s\_m}}{c\_m}}{x\_m}}{x\_m \cdot \left(c\_m \cdot s\_m\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 2.00000000000000015e-43

    1. Initial program 66.1%

      \[\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. associate-/r*66.0%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg66.0%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out66.0%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg66.0%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out66.0%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in66.0%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval66.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*49.2%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative49.2%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow249.2%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr74.6%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*72.7%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified72.7%

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. pow-flip73.0%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
      2. associate-*r*74.5%

        \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{\left(-2\right)} \]
      3. metadata-eval74.5%

        \[\leadsto {\left(\left(s \cdot c\right) \cdot x\right)}^{\color{blue}{-2}} \]
      4. unpow-prod-down64.0%

        \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
    9. Applied egg-rr64.0%

      \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
    10. Step-by-step derivation
      1. pow-prod-down74.5%

        \[\leadsto \color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{-2}} \]
      2. associate-*r*73.0%

        \[\leadsto {\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{-2} \]
      3. metadata-eval73.0%

        \[\leadsto {\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{\left(-1 + -1\right)}} \]
      4. pow-prod-up72.9%

        \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-1} \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-1}} \]
      5. inv-pow72.9%

        \[\leadsto \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)}} \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-1} \]
      6. inv-pow72.9%

        \[\leadsto \frac{1}{s \cdot \left(c \cdot x\right)} \cdot \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)}} \]
      7. un-div-inv72.9%

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x}}}{s \cdot \left(c \cdot x\right)} \]
      10. associate-*r*74.5%

        \[\leadsto \frac{\frac{\frac{\frac{1}{s}}{c}}{x}}{\color{blue}{\left(s \cdot c\right) \cdot x}} \]
      11. *-commutative74.5%

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

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

    if 2.00000000000000015e-43 < c

    1. Initial program 64.5%

      \[\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. associate-/r*64.5%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out64.5%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg64.5%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out64.5%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in64.5%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval64.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*59.9%

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
      5. swap-sqr81.9%

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      11. swap-sqr93.5%

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
      12. unpow293.5%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. *-un-lft-identity89.6%

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

        \[\leadsto \frac{1 \cdot \cos \left(x \cdot -2\right)}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      3. times-frac90.6%

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

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)} \cdot \frac{\cos \left(x \cdot -2\right)}{s \cdot \left(c \cdot x\right)}} \]
    10. Taylor expanded in x around 0 80.2%

      \[\leadsto \frac{1}{s \cdot \left(c \cdot x\right)} \cdot \color{blue}{\frac{1}{c \cdot \left(s \cdot x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq 2 \cdot 10^{-43}:\\ \;\;\;\;\frac{\frac{\frac{\frac{1}{s}}{c}}{x}}{x \cdot \left(c \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(x \cdot c\right)} \cdot \frac{1}{c \cdot \left(x \cdot s\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 78.2% accurate, 15.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-1}{s\_m}}{x\_m \cdot c\_m}}{x\_m \cdot \left(c\_m \cdot s\_m\right)}\\


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

    1. Initial program 66.7%

      \[\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. associate-/r*66.7%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg66.7%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out66.7%

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out66.7%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in66.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*53.2%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative53.2%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow253.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
      8. unpow269.9%

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr82.6%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*82.1%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified82.1%

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

        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*80.3%

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. associate-/r*79.3%

        \[\leadsto \color{blue}{\frac{\frac{1}{s \cdot c}}{x \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. inv-pow79.3%

        \[\leadsto \frac{\color{blue}{{\left(s \cdot c\right)}^{-1}}}{x \cdot \left(s \cdot \left(c \cdot x\right)\right)} \]
      3. metadata-eval79.3%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{\left(s \cdot c\right) \cdot x}}}{s \cdot \left(c \cdot x\right)} \]
      8. associate-*r*82.4%

        \[\leadsto \frac{\frac{1}{\color{blue}{s \cdot \left(c \cdot x\right)}}}{s \cdot \left(c \cdot x\right)} \]
      9. un-div-inv82.4%

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

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

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

        \[\leadsto \frac{\frac{\frac{1}{s}}{c}}{x} \cdot \color{blue}{\frac{\frac{1}{s}}{c \cdot x}} \]
      13. associate-/r*83.0%

        \[\leadsto \frac{\frac{\frac{1}{s}}{c}}{x} \cdot \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x}} \]
    11. Applied egg-rr83.0%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 8.20000000000000011e30 < x

    1. Initial program 62.3%

      \[\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. associate-/r*62.3%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg62.3%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out62.3%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval62.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*46.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative46.6%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow246.6%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr57.3%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*56.7%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified56.7%

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

        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.1%

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. associate-*r*56.1%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.7%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      4. associate-*r*56.8%

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

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

        \[\leadsto \frac{1}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
      7. pow-flip57.4%

        \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{\left(-2\right)}} \]
      8. associate-*r*56.9%

        \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{\left(-2\right)} \]
      9. *-commutative56.9%

        \[\leadsto {\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{\left(-2\right)} \]
      10. metadata-eval56.9%

        \[\leadsto {\left(\left(s \cdot c\right) \cdot x\right)}^{\color{blue}{-2}} \]
      11. pow-prod-down53.6%

        \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
      12. *-commutative53.6%

        \[\leadsto \color{blue}{{x}^{-2} \cdot {\left(s \cdot c\right)}^{-2}} \]
      13. sqr-pow53.6%

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{-2}{2}\right)} \cdot {x}^{\left(\frac{-2}{2}\right)}\right)} \cdot {\left(s \cdot c\right)}^{-2} \]
      14. associate-*l*56.3%

        \[\leadsto \color{blue}{{x}^{\left(\frac{-2}{2}\right)} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right)} \]
      15. metadata-eval56.3%

        \[\leadsto {x}^{\color{blue}{-1}} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      16. unpow-156.3%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      17. metadata-eval56.3%

        \[\leadsto \frac{1}{x} \cdot \left({x}^{\color{blue}{-1}} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      18. unpow-156.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.2 \cdot 10^{+30}:\\ \;\;\;\;\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{s}}{x \cdot c}}{x \cdot \left(c \cdot s\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 77.6% accurate, 17.4× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-1}{s\_m}}{x\_m \cdot c\_m}}{t\_0}\\


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

    1. Initial program 66.7%

      \[\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. associate-/r*66.7%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      3. sqr-neg66.7%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out66.7%

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out66.7%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in66.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*53.2%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative53.2%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow253.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
      8. unpow269.9%

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr82.6%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*82.1%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified82.1%

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Taylor expanded in s around 0 82.6%

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

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)}} \]
      2. associate-*r*80.7%

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)} \]
      4. associate-*r*80.0%

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

        \[\leadsto \frac{1}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}} \]
      6. associate-*r*79.1%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot x\right)\right) \cdot c}} \]
      7. associate-*r*79.7%

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

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

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(s \cdot c\right)\right) \cdot \color{blue}{\left(x \cdot s\right)}\right) \cdot c} \]
    10. Applied egg-rr79.7%

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

    if 8.20000000000000011e30 < x

    1. Initial program 62.3%

      \[\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. associate-/r*62.3%

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      7. distribute-rgt-neg-out62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot \left(-x\right)\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      8. sqr-neg62.3%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      10. distribute-rgt-neg-out62.3%

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      12. distribute-rgt-neg-in62.3%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
      13. metadata-eval62.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*46.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
      2. *-commutative46.6%

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
      3. unpow246.6%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr57.3%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
      12. associate-*r*56.7%

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

        \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
    7. Simplified56.7%

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

        \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.1%

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. associate-*r*56.1%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
      2. associate-*r*56.7%

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

        \[\leadsto \frac{1}{\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      4. associate-*r*56.8%

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

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

        \[\leadsto \frac{1}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
      7. pow-flip57.4%

        \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{\left(-2\right)}} \]
      8. associate-*r*56.9%

        \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{\left(-2\right)} \]
      9. *-commutative56.9%

        \[\leadsto {\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{\left(-2\right)} \]
      10. metadata-eval56.9%

        \[\leadsto {\left(\left(s \cdot c\right) \cdot x\right)}^{\color{blue}{-2}} \]
      11. pow-prod-down53.6%

        \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
      12. *-commutative53.6%

        \[\leadsto \color{blue}{{x}^{-2} \cdot {\left(s \cdot c\right)}^{-2}} \]
      13. sqr-pow53.6%

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{-2}{2}\right)} \cdot {x}^{\left(\frac{-2}{2}\right)}\right)} \cdot {\left(s \cdot c\right)}^{-2} \]
      14. associate-*l*56.3%

        \[\leadsto \color{blue}{{x}^{\left(\frac{-2}{2}\right)} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right)} \]
      15. metadata-eval56.3%

        \[\leadsto {x}^{\color{blue}{-1}} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      16. unpow-156.3%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot \left({x}^{\left(\frac{-2}{2}\right)} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      17. metadata-eval56.3%

        \[\leadsto \frac{1}{x} \cdot \left({x}^{\color{blue}{-1}} \cdot {\left(s \cdot c\right)}^{-2}\right) \]
      18. unpow-156.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{x \cdot c}}{\left(s \cdot c\right) \cdot \left(-x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification75.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.2 \cdot 10^{+30}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{s}}{x \cdot c}}{x \cdot \left(c \cdot s\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 76.2% accurate, 24.1× speedup?

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

    \[\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. associate-/r*65.6%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    3. sqr-neg65.6%

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    7. distribute-rgt-neg-out65.6%

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

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    10. distribute-rgt-neg-out65.6%

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    12. distribute-rgt-neg-in65.6%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    13. metadata-eval65.6%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  6. Step-by-step derivation
    1. associate-/r*51.5%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative51.5%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow251.5%

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
    10. swap-sqr76.2%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
    11. unpow276.2%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
    12. associate-*r*75.8%

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

      \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
  7. Simplified75.8%

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
    2. associate-*r*74.2%

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

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

    \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
  10. Taylor expanded in s around 0 74.5%

    \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
  11. Final simplification74.5%

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

Alternative 11: 76.3% accurate, 24.1× speedup?

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

    \[\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. associate-/r*65.6%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    3. sqr-neg65.6%

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    7. distribute-rgt-neg-out65.6%

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

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    10. distribute-rgt-neg-out65.6%

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    12. distribute-rgt-neg-in65.6%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    13. metadata-eval65.6%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  6. Step-by-step derivation
    1. associate-/r*51.5%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative51.5%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow251.5%

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
    10. swap-sqr76.2%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
    11. unpow276.2%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
    12. associate-*r*75.8%

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

      \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
  7. Simplified75.8%

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
    2. associate-*r*74.2%

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

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

    \[\leadsto \frac{1}{\color{blue}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}} \]
  10. Taylor expanded in s around 0 74.5%

    \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
  11. Step-by-step derivation
    1. *-commutative74.5%

      \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}\right)} \]
    2. associate-*r*73.4%

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

      \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot x\right)}\right)\right)} \]
    4. /-rgt-identity73.4%

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

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

      \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \frac{\color{blue}{\left(x \cdot c\right)} \cdot s}{1}\right)} \]
    7. associate-*l*75.3%

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

      \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \frac{x \cdot \color{blue}{\left(s \cdot c\right)}}{1}\right)} \]
  12. Applied egg-rr75.3%

    \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \color{blue}{\frac{x \cdot \left(s \cdot c\right)}{1}}\right)} \]
  13. Step-by-step derivation
    1. /-rgt-identity75.3%

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

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

    \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(c \cdot s\right)\right)}\right)} \]
  15. Final simplification75.3%

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

Alternative 12: 78.3% accurate, 24.1× speedup?

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

    \[\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. associate-/r*65.6%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    3. sqr-neg65.6%

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    7. distribute-rgt-neg-out65.6%

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

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    10. distribute-rgt-neg-out65.6%

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    12. distribute-rgt-neg-in65.6%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    13. metadata-eval65.6%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  6. Step-by-step derivation
    1. associate-/r*51.5%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative51.5%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow251.5%

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
    10. swap-sqr76.2%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
    11. unpow276.2%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
    12. associate-*r*75.8%

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

      \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
  7. Simplified75.8%

    \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
  8. Taylor expanded in s around 0 76.2%

    \[\leadsto \frac{1}{{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{2}} \]
  9. Step-by-step derivation
    1. associate-*r*76.3%

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

      \[\leadsto \frac{1}{{\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right)}^{2}} \]
    3. associate-*r*75.8%

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}} \]
    5. *-commutative75.8%

      \[\leadsto \frac{1}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot x\right) \cdot s\right)}} \]
    6. *-commutative75.8%

      \[\leadsto \frac{1}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(\color{blue}{\left(x \cdot c\right)} \cdot s\right)} \]
    7. associate-*l*74.2%

      \[\leadsto \frac{1}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \color{blue}{\left(x \cdot \left(c \cdot s\right)\right)}} \]
    8. *-commutative74.2%

      \[\leadsto \frac{1}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot c\right)}\right)} \]
    9. associate-*r*76.3%

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

      \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
  10. Applied egg-rr76.3%

    \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
  11. Final simplification76.3%

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

Alternative 13: 78.4% accurate, 24.1× speedup?

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

    \[\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. associate-/r*65.6%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\color{blue}{c \cdot c}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    3. sqr-neg65.6%

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\cos \left(-2 \cdot x\right)}}{\left(-c\right) \cdot \left(-c\right)}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    7. distribute-rgt-neg-out65.6%

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

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot \left(-x\right)\right)}{\color{blue}{{c}^{2}}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    10. distribute-rgt-neg-out65.6%

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    12. distribute-rgt-neg-in65.6%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x \cdot \left(-2\right)\right)}}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x} \]
    13. metadata-eval65.6%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  6. Step-by-step derivation
    1. associate-/r*51.5%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative51.5%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow251.5%

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

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

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

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

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

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

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
    10. swap-sqr76.2%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}} \]
    11. unpow276.2%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
    12. associate-*r*75.8%

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

      \[\leadsto \frac{1}{{\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{2}} \]
  7. Simplified75.8%

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

      \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}} \]
    2. associate-*r*76.3%

      \[\leadsto {\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}}^{\left(-2\right)} \]
    3. metadata-eval76.3%

      \[\leadsto {\left(\left(s \cdot c\right) \cdot x\right)}^{\color{blue}{-2}} \]
    4. unpow-prod-down65.1%

      \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
  9. Applied egg-rr65.1%

    \[\leadsto \color{blue}{{\left(s \cdot c\right)}^{-2} \cdot {x}^{-2}} \]
  10. Step-by-step derivation
    1. pow-prod-down76.3%

      \[\leadsto \color{blue}{{\left(\left(s \cdot c\right) \cdot x\right)}^{-2}} \]
    2. associate-*r*76.1%

      \[\leadsto {\color{blue}{\left(s \cdot \left(c \cdot x\right)\right)}}^{-2} \]
    3. metadata-eval76.1%

      \[\leadsto {\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{\left(-1 + -1\right)}} \]
    4. pow-prod-up76.0%

      \[\leadsto \color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{-1} \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-1}} \]
    5. inv-pow76.0%

      \[\leadsto \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)}} \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-1} \]
    6. inv-pow76.0%

      \[\leadsto \frac{1}{s \cdot \left(c \cdot x\right)} \cdot \color{blue}{\frac{1}{s \cdot \left(c \cdot x\right)}} \]
    7. un-div-inv76.1%

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

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x}}}{s \cdot \left(c \cdot x\right)} \]
    10. associate-*r*76.3%

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

      \[\leadsto \frac{\frac{\frac{\frac{1}{s}}{c}}{x}}{\color{blue}{x \cdot \left(s \cdot c\right)}} \]
  11. Applied egg-rr76.3%

    \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{1}{s}}{c}}{x}}{x \cdot \left(s \cdot c\right)}} \]
  12. Final simplification76.3%

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

Reproduce

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