mixedcos

Percentage Accurate: 65.6% → 98.6%
Time: 22.7s
Alternatives: 11
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 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 65.6% 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: 98.6% accurate, 1.5× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{+98}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{\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} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 2.4e+98)
   (/ (cos (* x 2.0)) (pow (* c (* x s)) 2.0))
   (/ (cos (* x -2.0)) (* s (* (* x c) (* s (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 2.4e+98) {
		tmp = cos((x * 2.0)) / pow((c * (x * s)), 2.0);
	} else {
		tmp = cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 2.4d+98) then
        tmp = cos((x * 2.0d0)) / ((c * (x * s)) ** 2.0d0)
    else
        tmp = cos((x * (-2.0d0))) / (s * ((x * c) * (s * (x * c))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 2.4e+98) {
		tmp = Math.cos((x * 2.0)) / Math.pow((c * (x * s)), 2.0);
	} else {
		tmp = Math.cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 2.4e+98:
		tmp = math.cos((x * 2.0)) / math.pow((c * (x * s)), 2.0)
	else:
		tmp = math.cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 2.4e+98)
		tmp = Float64(cos(Float64(x * 2.0)) / (Float64(c * Float64(x * s)) ^ 2.0));
	else
		tmp = Float64(cos(Float64(x * -2.0)) / Float64(s * Float64(Float64(x * c) * Float64(s * Float64(x * c)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 2.4e+98)
		tmp = cos((x * 2.0)) / ((c * (x * s)) ^ 2.0);
	else
		tmp = cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 2.4e+98], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{+98}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.3999999999999999e98

    1. Initial program 74.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. add-sqr-sqrt74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3999999999999999e98 < x

    1. Initial program 54.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. *-commutative54.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      16. associate-*l*92.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)}} \]
      17. unpow292.5%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    7. Step-by-step derivation
      1. unpow296.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. *-commutative96.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*90.2%

        \[\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}} \]
    8. Applied egg-rr90.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{+98}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{\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} \]

Alternative 2: 95.7% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.8 \cdot 10^{-98}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \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} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 1.8e-98)
   (/ 1.0 (* c (* (* x s) (* c (* x s)))))
   (/ (cos (* x -2.0)) (* (* c s) (* x (* s (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 1.8e-98) {
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	} else {
		tmp = cos((x * -2.0)) / ((c * s) * (x * (s * (x * c))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 1.8d-98) then
        tmp = 1.0d0 / (c * ((x * s) * (c * (x * s))))
    else
        tmp = cos((x * (-2.0d0))) / ((c * s) * (x * (s * (x * c))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 1.8e-98) {
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	} else {
		tmp = Math.cos((x * -2.0)) / ((c * s) * (x * (s * (x * c))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 1.8e-98:
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))))
	else:
		tmp = math.cos((x * -2.0)) / ((c * s) * (x * (s * (x * c))))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 1.8e-98)
		tmp = Float64(1.0 / Float64(c * Float64(Float64(x * s) * Float64(c * Float64(x * s)))));
	else
		tmp = Float64(cos(Float64(x * -2.0)) / Float64(Float64(c * s) * Float64(x * Float64(s * Float64(x * c)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 1.8e-98)
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	else
		tmp = cos((x * -2.0)) / ((c * s) * (x * (s * (x * c))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 1.8e-98], N[(1.0 / N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(c * s), $MachinePrecision] * N[(x * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{-98}:\\
\;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\

\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.8000000000000001e-98

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      15. associate-*l*84.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)}} \]
      16. unpow284.2%

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

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

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

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

        \[\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*82.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*81.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)}} \]
    6. Applied egg-rr81.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)}} \]
    7. Taylor expanded in s around 0 80.4%

      \[\leadsto \frac{1}{\left(s \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
    8. Step-by-step derivation
      1. /-rgt-identity80.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\frac{\color{blue}{-1}}{-c \cdot \left(s \cdot x\right)}}} \]
      8. distribute-lft-neg-in84.2%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{s \cdot x}}}} \]
    9. Applied egg-rr80.4%

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{1} \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}} \]
      3. /-rgt-identity80.4%

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

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

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

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

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

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

    if 1.8000000000000001e-98 < x

    1. Initial program 67.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. *-commutative67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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)}} \]
      17. unpow295.7%

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

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

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

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

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

        \[\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.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)}} \]
    8. Applied egg-rr83.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.8 \cdot 10^{-98}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \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} \]

Alternative 3: 97.4% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{-6}:\\ \;\;\;\;{\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} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 1.1e-6)
   (pow (* c (* x s)) -2.0)
   (/ (cos (* x -2.0)) (* (* x c) (* s (* s (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 1.1e-6) {
		tmp = pow((c * (x * s)), -2.0);
	} else {
		tmp = cos((x * -2.0)) / ((x * c) * (s * (s * (x * c))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 1.1d-6) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else
        tmp = cos((x * (-2.0d0))) / ((x * c) * (s * (s * (x * c))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 1.1e-6) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else {
		tmp = Math.cos((x * -2.0)) / ((x * c) * (s * (s * (x * c))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 1.1e-6:
		tmp = math.pow((c * (x * s)), -2.0)
	else:
		tmp = math.cos((x * -2.0)) / ((x * c) * (s * (s * (x * c))))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 1.1e-6)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * -2.0)) / Float64(Float64(x * c) * Float64(s * Float64(s * Float64(x * c)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 1.1e-6)
		tmp = (c * (x * s)) ^ -2.0;
	else
		tmp = cos((x * -2.0)) / ((x * c) * (s * (s * (x * c))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 1.1e-6], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(s * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{-6}:\\
\;\;\;\;{\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.1000000000000001e-6

    1. Initial program 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\right)\right)} \]
      2. expm1-udef75.7%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}}\right)} - 1 \]
      4. metadata-eval75.7%

        \[\leadsto e^{\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}}\right)} - 1 \]
    6. Applied egg-rr75.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{-2}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def84.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{-2}\right)\right)} \]
      2. expm1-log1p86.0%

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

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

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

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

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

    if 1.1000000000000001e-6 < x

    1. Initial program 62.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. *-commutative62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      16. associate-*l*94.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)}} \]
      17. unpow294.3%

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

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

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

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

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

        \[\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)}} \]
    8. Applied egg-rr89.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{-6}:\\ \;\;\;\;{\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} \]

Alternative 4: 98.0% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.05 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \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} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 1.05e-21)
   (/ 1.0 (* c (* (* x s) (* c (* x s)))))
   (/ (cos (* x -2.0)) (* s (* (* x c) (* s (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 1.05e-21) {
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	} else {
		tmp = cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 1.05d-21) then
        tmp = 1.0d0 / (c * ((x * s) * (c * (x * s))))
    else
        tmp = cos((x * (-2.0d0))) / (s * ((x * c) * (s * (x * c))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 1.05e-21) {
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	} else {
		tmp = Math.cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 1.05e-21:
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))))
	else:
		tmp = math.cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 1.05e-21)
		tmp = Float64(1.0 / Float64(c * Float64(Float64(x * s) * Float64(c * Float64(x * s)))));
	else
		tmp = Float64(cos(Float64(x * -2.0)) / Float64(s * Float64(Float64(x * c) * Float64(s * Float64(x * c)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 1.05e-21)
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	else
		tmp = cos((x * -2.0)) / (s * ((x * c) * (s * (x * c))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 1.05e-21], N[(1.0 / N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{-21}:\\
\;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\

\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.05000000000000006e-21

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      15. associate-*l*85.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)}} \]
      16. unpow285.6%

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

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

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

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

        \[\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*84.4%

        \[\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*83.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\color{blue}{\frac{-1}{-c \cdot \left(s \cdot x\right)}}}} \]
      7. metadata-eval85.6%

        \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\frac{\color{blue}{-1}}{-c \cdot \left(s \cdot x\right)}}} \]
      8. distribute-lft-neg-in85.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{s \cdot x}}}} \]
    9. Applied egg-rr82.1%

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{1} \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}} \]
      3. /-rgt-identity82.1%

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

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

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

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

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

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

    if 1.05000000000000006e-21 < x

    1. Initial program 63.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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)}} \]
      17. unpow294.4%

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

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

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

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

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

        \[\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*92.7%

        \[\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}} \]
    8. Applied egg-rr92.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.05 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \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} \]

Alternative 5: 99.0% accurate, 2.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}\\


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

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      15. associate-*l*85.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)}} \]
      16. unpow285.6%

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

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

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

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

        \[\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*84.4%

        \[\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*83.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\color{blue}{\frac{-1}{-c \cdot \left(s \cdot x\right)}}}} \]
      7. metadata-eval85.6%

        \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\frac{\color{blue}{-1}}{-c \cdot \left(s \cdot x\right)}}} \]
      8. distribute-lft-neg-in85.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{s \cdot x}}}} \]
    9. Applied egg-rr82.1%

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{1} \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}} \]
      3. /-rgt-identity82.1%

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

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

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

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

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

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

    if 2.05e-22 < x

    1. Initial program 63.2%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Applied egg-rr80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.05 \cdot 10^{-22}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(x \cdot c\right)}}{s \cdot \left(x \cdot c\right)}\\ \end{array} \]

Alternative 6: 99.1% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 5.1 \cdot 10^{-92}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{s}}{x \cdot c}}{s \cdot \left(x \cdot c\right)}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 5.1e-92)
   (/ 1.0 (* c (* (* x s) (* c (* x s)))))
   (/ (/ (/ (cos (* x 2.0)) s) (* x c)) (* s (* x c)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 5.1e-92) {
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	} else {
		tmp = ((cos((x * 2.0)) / s) / (x * c)) / (s * (x * c));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 5.1d-92) then
        tmp = 1.0d0 / (c * ((x * s) * (c * (x * s))))
    else
        tmp = ((cos((x * 2.0d0)) / s) / (x * c)) / (s * (x * c))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 5.1e-92) {
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	} else {
		tmp = ((Math.cos((x * 2.0)) / s) / (x * c)) / (s * (x * c));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 5.1e-92:
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))))
	else:
		tmp = ((math.cos((x * 2.0)) / s) / (x * c)) / (s * (x * c))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 5.1e-92)
		tmp = Float64(1.0 / Float64(c * Float64(Float64(x * s) * Float64(c * Float64(x * s)))));
	else
		tmp = Float64(Float64(Float64(cos(Float64(x * 2.0)) / s) / Float64(x * c)) / Float64(s * Float64(x * c)));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 5.1e-92)
		tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
	else
		tmp = ((cos((x * 2.0)) / s) / (x * c)) / (s * (x * c));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 5.1e-92], N[(1.0 / N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision] / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.1 \cdot 10^{-92}:\\
\;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\

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


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

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      15. associate-*l*84.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)}} \]
      16. unpow284.3%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    5. Step-by-step derivation
      1. unpow284.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*83.0%

        \[\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*81.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)}} \]
    6. Applied egg-rr81.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)}} \]
    7. Taylor expanded in s around 0 80.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)} \]
    8. Step-by-step derivation
      1. /-rgt-identity80.5%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\frac{\color{blue}{-1}}{-c \cdot \left(s \cdot x\right)}}} \]
      8. distribute-lft-neg-in84.3%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{s \cdot x}}}} \]
    9. Applied egg-rr80.5%

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c}{1} \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}} \]
      3. /-rgt-identity80.5%

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

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

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

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

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

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

    if 5.09999999999999972e-92 < x

    1. Initial program 66.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Applied egg-rr82.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(\sqrt{\left(x \cdot x\right) \cdot \color{blue}{4}}\right)}{\frac{{\left(c \cdot x\right)}^{2}}{{s}^{-2}}} \]
      11. metadata-eval42.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.1 \cdot 10^{-92}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{s}}{x \cdot c}}{s \cdot \left(x \cdot c\right)}\\ \end{array} \]

Alternative 7: 79.8% accurate, 2.8× speedup?

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

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


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

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\right)\right)} \]
      2. expm1-udef74.8%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}}\right)} - 1 \]
      4. metadata-eval74.8%

        \[\leadsto e^{\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}}\right)} - 1 \]
    6. Applied egg-rr74.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{-2}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def83.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{-2}\right)\right)} \]
      2. expm1-log1p85.0%

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

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

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

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

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

    if 2.25e15 < x

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \color{blue}{\left(c \cdot \left(x \cdot s\right)\right)}\right)} \]
      15. associate-*l*49.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)}} \]
      16. unpow249.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{s \cdot \left(c \cdot x\right)} \cdot \frac{1}{\color{blue}{\sqrt{s \cdot \left(c \cdot x\right)} \cdot \sqrt{s \cdot \left(c \cdot x\right)}}} \]
      11. add-sqr-sqrt49.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left({\color{blue}{\left(\left(c \cdot x\right) \cdot s\right)}}^{\left(-1\right)}\right)}^{2} \]
      7. unpow-prod-down49.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{1}{x \cdot c} \cdot \frac{1}{\color{blue}{\sqrt{s} \cdot \sqrt{s}}}\right)}^{2} \]
      20. add-sqr-sqrt49.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{s}}{c \cdot x} \cdot \frac{\color{blue}{-1}}{-c \cdot \left(s \cdot x\right)} \]
      8. distribute-lft-neg-in49.2%

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}} \cdot \frac{\frac{-1}{s \cdot x}}{-c} \]
      14. times-frac48.9%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{-1}{s \cdot x}}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(-c\right)}} \]
      15. *-un-lft-identity48.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.25 \cdot 10^{+15}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}\\ \end{array} \]

Alternative 8: 79.7% accurate, 3.0× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ {\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (pow (* c (* x s)) -2.0))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return pow((c * (x * s)), -2.0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (c * (x * s)) ** (-2.0d0)
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return Math.pow((c * (x * s)), -2.0);
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return math.pow((c * (x * s)), -2.0)
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(c * Float64(x * s)) ^ -2.0
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (c * (x * s)) ^ -2.0;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{\left(-2\right)}}\right)} - 1 \]
    4. metadata-eval69.5%

      \[\leadsto e^{\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{\color{blue}{-2}}\right)} - 1 \]
  6. Applied egg-rr69.5%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{-2}\right)} - 1} \]
  7. Step-by-step derivation
    1. expm1-def77.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(s \cdot \left(c \cdot x\right)\right)}^{-2}\right)\right)} \]
    2. expm1-log1p77.9%

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

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

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

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

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

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

Alternative 9: 79.7% accurate, 20.9× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{\frac{\frac{-1}{c}}{x \cdot s}}{-1}}{c \cdot \left(x \cdot s\right)} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (/ (/ (/ (/ -1.0 c) (* x s)) -1.0) (* c (* x s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return (((-1.0 / c) / (x * s)) / -1.0) / (c * (x * s));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = ((((-1.0d0) / c) / (x * s)) / (-1.0d0)) / (c * (x * s))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return (((-1.0 / c) / (x * s)) / -1.0) / (c * (x * s));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (((-1.0 / c) / (x * s)) / -1.0) / (c * (x * s))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(Float64(-1.0 / c) / Float64(x * s)) / -1.0) / Float64(c * Float64(x * s)))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (((-1.0 / c) / (x * s)) / -1.0) / (c * (x * s));
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(N[(N[(-1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{\frac{-1}{c}}{x \cdot s}}{-1}}{c \cdot \left(x \cdot s\right)}
\end{array}
Derivation
  1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{s \cdot \left(c \cdot x\right)} \cdot \frac{1}{\color{blue}{\sqrt{s \cdot \left(c \cdot x\right)} \cdot \sqrt{s \cdot \left(c \cdot x\right)}}} \]
    11. add-sqr-sqrt77.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s \cdot x}}{c} \cdot \frac{\frac{1}{s \cdot x}}{c}} \]
    2. frac-2neg77.5%

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{s}}{x}}}{c} \cdot \frac{-\frac{1}{s \cdot x}}{-c} \]
    4. associate-/l/76.8%

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

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

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

      \[\leadsto \frac{\color{blue}{-\frac{1}{s \cdot x}}}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(-c\right)} \]
    8. distribute-neg-frac73.3%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{-1}{x \cdot s}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(-c\right)}} \]
  11. Step-by-step derivation
    1. *-commutative73.7%

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

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{-1}}{x \cdot s}}{-c}}{x \cdot \left(s \cdot c\right)} \]
    6. distribute-neg-frac76.2%

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

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

      \[\leadsto \frac{\frac{-\color{blue}{\frac{1}{x \cdot s}}}{-c}}{x \cdot \left(s \cdot c\right)} \]
    9. distribute-neg-frac76.2%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{c \cdot \left(s \cdot x\right)}} \]
  13. Step-by-step derivation
    1. add-sqr-sqrt40.3%

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\frac{-1}{s \cdot x}} \cdot \sqrt{\frac{-1}{s \cdot x}}}}{-c}}{c \cdot \left(s \cdot x\right)} \]
    2. neg-mul-140.3%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{\frac{\frac{-1}{s}}{x}} \cdot \frac{\sqrt{\frac{\frac{-1}{s}}{x}}}{c}}{-1}}}{c \cdot \left(s \cdot x\right)} \]
  16. Simplified77.7%

    \[\leadsto \frac{\color{blue}{\frac{\frac{\frac{-1}{c}}{s \cdot x}}{-1}}}{c \cdot \left(s \cdot x\right)} \]
  17. Final simplification77.7%

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

Alternative 10: 79.7% accurate, 22.4× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{\frac{-1}{x \cdot s}}{-c}}{c \cdot \left(x \cdot s\right)} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (/ (/ (/ -1.0 (* x s)) (- c)) (* c (* x s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return ((-1.0 / (x * s)) / -c) / (c * (x * s));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (((-1.0d0) / (x * s)) / -c) / (c * (x * s))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return ((-1.0 / (x * s)) / -c) / (c * (x * s));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return ((-1.0 / (x * s)) / -c) / (c * (x * s))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(-1.0 / Float64(x * s)) / Float64(-c)) / Float64(c * Float64(x * s)))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = ((-1.0 / (x * s)) / -c) / (c * (x * s));
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(N[(-1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision] / (-c)), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{-1}{x \cdot s}}{-c}}{c \cdot \left(x \cdot s\right)}
\end{array}
Derivation
  1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{s \cdot \left(c \cdot x\right)} \cdot \frac{1}{\color{blue}{\sqrt{s \cdot \left(c \cdot x\right)} \cdot \sqrt{s \cdot \left(c \cdot x\right)}}} \]
    11. add-sqr-sqrt77.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{s \cdot x}}{c} \cdot \frac{\frac{1}{s \cdot x}}{c}} \]
    2. frac-2neg77.5%

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{s}}{x}}}{c} \cdot \frac{-\frac{1}{s \cdot x}}{-c} \]
    4. associate-/l/76.8%

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

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

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

      \[\leadsto \frac{\color{blue}{-\frac{1}{s \cdot x}}}{\left(s \cdot \left(c \cdot x\right)\right) \cdot \left(-c\right)} \]
    8. distribute-neg-frac73.3%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{-1}{x \cdot s}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(-c\right)}} \]
  11. Step-by-step derivation
    1. *-commutative73.7%

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

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{-1}}{x \cdot s}}{-c}}{x \cdot \left(s \cdot c\right)} \]
    6. distribute-neg-frac76.2%

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

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

      \[\leadsto \frac{\frac{-\color{blue}{\frac{1}{x \cdot s}}}{-c}}{x \cdot \left(s \cdot c\right)} \]
    9. distribute-neg-frac76.2%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{c \cdot \left(s \cdot x\right)}} \]
  13. Final simplification77.6%

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

Alternative 11: 78.9% accurate, 24.1× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* (* x s) (* c (* x s))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / (c * ((x * s) * (c * (x * s))));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / (c * ((x * s) * (c * (x * s))))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / (c * ((x * s) * (c * (x * s))));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / (c * ((x * s) * (c * (x * s))))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(c * Float64(Float64(x * s) * Float64(c * Float64(x * s)))))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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*76.4%

      \[\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*75.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{c \cdot \left(s \cdot x\right)}{\frac{\color{blue}{-1}}{-c \cdot \left(s \cdot x\right)}}} \]
    8. distribute-lft-neg-in77.7%

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{c}{\frac{\frac{\frac{-1}{s \cdot x}}{-c}}{s \cdot x}}}} \]
  9. Applied egg-rr74.7%

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

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

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

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

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

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

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

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

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

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

Reproduce

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