mixedcos

Percentage Accurate: 67.0% → 98.8%
Time: 19.9s
Alternatives: 19
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 19 alternatives:

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

Initial Program: 67.0% 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.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(x + x\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{t_0}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (+ x x))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c 2.0) (* x (* x (pow s 2.0)))))
        INFINITY)
     (/ t_0 (pow (* c (* x s)) 2.0))
     (/ t_0 (pow (* x (* c s)) 2.0)))))
double code(double x, double c, double s) {
	double t_0 = cos((x + x));
	double tmp;
	if ((cos((2.0 * x)) / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = t_0 / pow((c * (x * s)), 2.0);
	} else {
		tmp = t_0 / pow((x * (c * s)), 2.0);
	}
	return tmp;
}
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((x + x));
	double tmp;
	if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 / Math.pow((c * (x * s)), 2.0);
	} else {
		tmp = t_0 / Math.pow((x * (c * s)), 2.0);
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((x + x))
	tmp = 0
	if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf:
		tmp = t_0 / math.pow((c * (x * s)), 2.0)
	else:
		tmp = t_0 / math.pow((x * (c * s)), 2.0)
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(x + x))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(t_0 / (Float64(c * Float64(x * s)) ^ 2.0));
	else
		tmp = Float64(t_0 / (Float64(x * Float64(c * s)) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((x + x));
	tmp = 0.0;
	if ((cos((2.0 * x)) / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
		tmp = t_0 / ((c * (x * s)) ^ 2.0);
	else
		tmp = t_0 / ((x * (c * s)) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[Power[N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(x + x\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{t_0}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\

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


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

    1. Initial program 85.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x)))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around inf 0.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. count-20.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(x + x\right)}{{\color{blue}{\left(\sqrt{c \cdot \left(s \cdot x\right)} \cdot \sqrt{c \cdot \left(s \cdot x\right)}\right)}}^{2}} \]
    9. Step-by-step derivation
      1. rem-square-sqrt76.7%

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

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

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

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

Alternative 2: 96.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(x + x\right)\\ \mathbf{if}\;x \leq 13000000000:\\ \;\;\;\;\frac{t_0}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot c\right)}}{s}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (+ x x))))
   (if (<= x 13000000000.0)
     (/ t_0 (pow (* c (* x s)) 2.0))
     (/ (/ t_0 (* (* x (* c s)) (* x c))) s))))
double code(double x, double c, double s) {
	double t_0 = cos((x + x));
	double tmp;
	if (x <= 13000000000.0) {
		tmp = t_0 / pow((c * (x * s)), 2.0);
	} else {
		tmp = (t_0 / ((x * (c * s)) * (x * c))) / s;
	}
	return tmp;
}
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 = cos((x + x))
    if (x <= 13000000000.0d0) then
        tmp = t_0 / ((c * (x * s)) ** 2.0d0)
    else
        tmp = (t_0 / ((x * (c * s)) * (x * c))) / s
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((x + x));
	double tmp;
	if (x <= 13000000000.0) {
		tmp = t_0 / Math.pow((c * (x * s)), 2.0);
	} else {
		tmp = (t_0 / ((x * (c * s)) * (x * c))) / s;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((x + x))
	tmp = 0
	if x <= 13000000000.0:
		tmp = t_0 / math.pow((c * (x * s)), 2.0)
	else:
		tmp = (t_0 / ((x * (c * s)) * (x * c))) / s
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(x + x))
	tmp = 0.0
	if (x <= 13000000000.0)
		tmp = Float64(t_0 / (Float64(c * Float64(x * s)) ^ 2.0));
	else
		tmp = Float64(Float64(t_0 / Float64(Float64(x * Float64(c * s)) * Float64(x * c))) / s);
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((x + x));
	tmp = 0.0;
	if (x <= 13000000000.0)
		tmp = t_0 / ((c * (x * s)) ^ 2.0);
	else
		tmp = (t_0 / ((x * (c * s)) * (x * c))) / s;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 13000000000.0], N[(t$95$0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(x + x\right)\\
\mathbf{if}\;x \leq 13000000000:\\
\;\;\;\;\frac{t_0}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\

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


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

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot \cos \left(x + x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. times-frac69.5%

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

        \[\leadsto \frac{1}{x \cdot x} \cdot \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}} \]
      11. swap-sqr79.7%

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

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

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

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

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

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

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

    if 1.3e10 < x

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(\sqrt{c \cdot \left(s \cdot x\right)} \cdot \sqrt{c \cdot \left(s \cdot x\right)}\right) \cdot \left(c \cdot x\right)}}{s}} \]
    9. Applied rewrite-once40.4%

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(\sqrt{c \cdot \left(s \cdot x\right)} \cdot \sqrt{c \cdot \left(s \cdot x\right)}\right)} \cdot \left(c \cdot x\right)}}{s} \]
    10. Step-by-step derivation
      1. rem-square-sqrt95.4%

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

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

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

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

Alternative 3: 87.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;s \leq 7.5 \cdot 10^{-14}:\\ \;\;\;\;\frac{t_0}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \mathbf{elif}\;s \leq 3.4 \cdot 10^{+201}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(c \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (* 2.0 x))))
   (if (<= s 7.5e-14)
     (/ t_0 (* c (* x (* c (* s (* x s))))))
     (if (<= s 3.4e+201)
       (/ t_0 (* x (* c (* s (* x (* c s))))))
       (/ 1.0 (pow (* c (* x s)) 2.0))))))
double code(double x, double c, double s) {
	double t_0 = cos((2.0 * x));
	double tmp;
	if (s <= 7.5e-14) {
		tmp = t_0 / (c * (x * (c * (s * (x * s)))));
	} else if (s <= 3.4e+201) {
		tmp = t_0 / (x * (c * (s * (x * (c * s)))));
	} else {
		tmp = 1.0 / pow((c * (x * s)), 2.0);
	}
	return tmp;
}
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 = cos((2.0d0 * x))
    if (s <= 7.5d-14) then
        tmp = t_0 / (c * (x * (c * (s * (x * s)))))
    else if (s <= 3.4d+201) then
        tmp = t_0 / (x * (c * (s * (x * (c * s)))))
    else
        tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((2.0 * x));
	double tmp;
	if (s <= 7.5e-14) {
		tmp = t_0 / (c * (x * (c * (s * (x * s)))));
	} else if (s <= 3.4e+201) {
		tmp = t_0 / (x * (c * (s * (x * (c * s)))));
	} else {
		tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((2.0 * x))
	tmp = 0
	if s <= 7.5e-14:
		tmp = t_0 / (c * (x * (c * (s * (x * s)))))
	elif s <= 3.4e+201:
		tmp = t_0 / (x * (c * (s * (x * (c * s)))))
	else:
		tmp = 1.0 / math.pow((c * (x * s)), 2.0)
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(2.0 * x))
	tmp = 0.0
	if (s <= 7.5e-14)
		tmp = Float64(t_0 / Float64(c * Float64(x * Float64(c * Float64(s * Float64(x * s))))));
	elseif (s <= 3.4e+201)
		tmp = Float64(t_0 / Float64(x * Float64(c * Float64(s * Float64(x * Float64(c * s))))));
	else
		tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((2.0 * x));
	tmp = 0.0;
	if (s <= 7.5e-14)
		tmp = t_0 / (c * (x * (c * (s * (x * s)))));
	elseif (s <= 3.4e+201)
		tmp = t_0 / (x * (c * (s * (x * (c * s)))));
	else
		tmp = 1.0 / ((c * (x * s)) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[s, 7.5e-14], N[(t$95$0 / N[(c * N[(x * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[s, 3.4e+201], N[(t$95$0 / N[(x * N[(c * N[(s * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;s \leq 7.5 \cdot 10^{-14}:\\
\;\;\;\;\frac{t_0}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\

\mathbf{elif}\;s \leq 3.4 \cdot 10^{+201}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(c \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if s < 7.4999999999999996e-14

    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. associate-/r*65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.4999999999999996e-14 < s < 3.4e201

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.4e201 < s

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 7.5 \cdot 10^{-14}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \mathbf{elif}\;s \leq 3.4 \cdot 10^{+201}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \end{array} \]

Alternative 4: 87.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 1.1 \cdot 10^{+145}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 1.1e+145)
   (/ (cos (* 2.0 x)) (* c (* x (* c (* s (* x s))))))
   (/ 1.0 (pow (* c (* x s)) 2.0))))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.1e+145) {
		tmp = cos((2.0 * x)) / (c * (x * (c * (s * (x * s)))));
	} else {
		tmp = 1.0 / pow((c * (x * s)), 2.0);
	}
	return tmp;
}
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 (s <= 1.1d+145) then
        tmp = cos((2.0d0 * x)) / (c * (x * (c * (s * (x * s)))))
    else
        tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.1e+145) {
		tmp = Math.cos((2.0 * x)) / (c * (x * (c * (s * (x * s)))));
	} else {
		tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 1.1e+145:
		tmp = math.cos((2.0 * x)) / (c * (x * (c * (s * (x * s)))))
	else:
		tmp = 1.0 / math.pow((c * (x * s)), 2.0)
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 1.1e+145)
		tmp = Float64(cos(Float64(2.0 * x)) / Float64(c * Float64(x * Float64(c * Float64(s * Float64(x * s))))));
	else
		tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 1.1e+145)
		tmp = cos((2.0 * x)) / (c * (x * (c * (s * (x * s)))));
	else
		tmp = 1.0 / ((c * (x * s)) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 1.1e+145], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(c * N[(x * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.1 \cdot 10^{+145}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 1.10000000000000004e145

    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. Step-by-step derivation
      1. associate-/r*70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.10000000000000004e145 < s

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 86.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;x \leq 3 \cdot 10^{-37}:\\ \;\;\;\;\frac{1}{{t_0}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t_0 \cdot \left(x \cdot c\right)}}{s}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s))))
   (if (<= x 3e-37)
     (/ 1.0 (pow t_0 2.0))
     (/ (/ (cos (+ x x)) (* t_0 (* x c))) s))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double tmp;
	if (x <= 3e-37) {
		tmp = 1.0 / pow(t_0, 2.0);
	} else {
		tmp = (cos((x + x)) / (t_0 * (x * c))) / s;
	}
	return tmp;
}
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 = c * (x * s)
    if (x <= 3d-37) then
        tmp = 1.0d0 / (t_0 ** 2.0d0)
    else
        tmp = (cos((x + x)) / (t_0 * (x * c))) / s
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double tmp;
	if (x <= 3e-37) {
		tmp = 1.0 / Math.pow(t_0, 2.0);
	} else {
		tmp = (Math.cos((x + x)) / (t_0 * (x * c))) / s;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = c * (x * s)
	tmp = 0
	if x <= 3e-37:
		tmp = 1.0 / math.pow(t_0, 2.0)
	else:
		tmp = (math.cos((x + x)) / (t_0 * (x * c))) / s
	return tmp
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	tmp = 0.0
	if (x <= 3e-37)
		tmp = Float64(1.0 / (t_0 ^ 2.0));
	else
		tmp = Float64(Float64(cos(Float64(x + x)) / Float64(t_0 * Float64(x * c))) / s);
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = c * (x * s);
	tmp = 0.0;
	if (x <= 3e-37)
		tmp = 1.0 / (t_0 ^ 2.0);
	else
		tmp = (cos((x + x)) / (t_0 * (x * c))) / s;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3e-37], N[(1.0 / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 3 \cdot 10^{-37}:\\
\;\;\;\;\frac{1}{{t_0}^{2}}\\

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


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

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3e-37 < x

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 86.7% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot c\right)}}{s}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 5e-23)
   (/ 1.0 (pow (* c (* x s)) 2.0))
   (/ (/ (cos (+ x x)) (* (* x (* c s)) (* x c))) s)))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 5e-23) {
		tmp = 1.0 / pow((c * (x * s)), 2.0);
	} else {
		tmp = (cos((x + x)) / ((x * (c * s)) * (x * c))) / s;
	}
	return tmp;
}
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 <= 5d-23) then
        tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
    else
        tmp = (cos((x + x)) / ((x * (c * s)) * (x * c))) / s
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 5e-23) {
		tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
	} else {
		tmp = (Math.cos((x + x)) / ((x * (c * s)) * (x * c))) / s;
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 5e-23:
		tmp = 1.0 / math.pow((c * (x * s)), 2.0)
	else:
		tmp = (math.cos((x + x)) / ((x * (c * s)) * (x * c))) / s
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 5e-23)
		tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0));
	else
		tmp = Float64(Float64(cos(Float64(x + x)) / Float64(Float64(x * Float64(c * s)) * Float64(x * c))) / s);
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 5e-23)
		tmp = 1.0 / ((c * (x * s)) ^ 2.0);
	else
		tmp = (cos((x + x)) / ((x * (c * s)) * (x * c))) / s;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 5e-23], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-23}:\\
\;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\

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


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

    1. Initial program 67.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e-23 < x

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      10. *-commutative93.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(\sqrt{c \cdot \left(s \cdot x\right)} \cdot \sqrt{c \cdot \left(s \cdot x\right)}\right) \cdot \left(c \cdot x\right)}}{s}} \]
    9. Applied rewrite-once42.2%

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(\sqrt{c \cdot \left(s \cdot x\right)} \cdot \sqrt{c \cdot \left(s \cdot x\right)}\right)} \cdot \left(c \cdot x\right)}}{s} \]
    10. Step-by-step derivation
      1. rem-square-sqrt95.8%

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

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

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

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

Alternative 7: 54.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 1.75 \cdot 10^{-120}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(s \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 1.75e-120)
   (/ (cos (+ x x)) (* (* x (* c c)) (* s s)))
   (/ 1.0 (pow (* c (* x s)) 2.0))))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.75e-120) {
		tmp = cos((x + x)) / ((x * (c * c)) * (s * s));
	} else {
		tmp = 1.0 / pow((c * (x * s)), 2.0);
	}
	return tmp;
}
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 (s <= 1.75d-120) then
        tmp = cos((x + x)) / ((x * (c * c)) * (s * s))
    else
        tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.75e-120) {
		tmp = Math.cos((x + x)) / ((x * (c * c)) * (s * s));
	} else {
		tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 1.75e-120:
		tmp = math.cos((x + x)) / ((x * (c * c)) * (s * s))
	else:
		tmp = 1.0 / math.pow((c * (x * s)), 2.0)
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 1.75e-120)
		tmp = Float64(cos(Float64(x + x)) / Float64(Float64(x * Float64(c * c)) * Float64(s * s)));
	else
		tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 1.75e-120)
		tmp = cos((x + x)) / ((x * (c * c)) * (s * s));
	else
		tmp = 1.0 / ((c * (x * s)) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 1.75e-120], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(x * N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.75 \cdot 10^{-120}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(s \cdot s\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 1.75e-120

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{e^{--2 \cdot \log s}}} \]
    8. Step-by-step derivation
      1. distribute-lft-neg-in8.7%

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

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot e^{\color{blue}{\log s + \log s}}} \]
      6. exp-sum8.7%

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(e^{\log s} \cdot e^{\log s}\right)}} \]
      7. rem-exp-log8.7%

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(\color{blue}{s} \cdot e^{\log s}\right)} \]
      8. rem-exp-log38.1%

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

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

    if 1.75e-120 < s

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 56.6% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 4.65 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{s \cdot \left(x \cdot c\right)}}{s}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 4.65e-122)
   (/ (/ (cos (+ x x)) (* s (* x c))) s)
   (/ 1.0 (pow (* c (* x s)) 2.0))))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 4.65e-122) {
		tmp = (cos((x + x)) / (s * (x * c))) / s;
	} else {
		tmp = 1.0 / pow((c * (x * s)), 2.0);
	}
	return tmp;
}
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 (s <= 4.65d-122) then
        tmp = (cos((x + x)) / (s * (x * c))) / s
    else
        tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 4.65e-122) {
		tmp = (Math.cos((x + x)) / (s * (x * c))) / s;
	} else {
		tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 4.65e-122:
		tmp = (math.cos((x + x)) / (s * (x * c))) / s
	else:
		tmp = 1.0 / math.pow((c * (x * s)), 2.0)
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 4.65e-122)
		tmp = Float64(Float64(cos(Float64(x + x)) / Float64(s * Float64(x * c))) / s);
	else
		tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 4.65e-122)
		tmp = (cos((x + x)) / (s * (x * c))) / s;
	else
		tmp = 1.0 / ((c * (x * s)) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 4.65e-122], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 4.65 \cdot 10^{-122}:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{s \cdot \left(x \cdot c\right)}}{s}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 4.6499999999999998e-122

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
    8. Applied egg-rr43.0%

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

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

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

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

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

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

    if 4.6499999999999998e-122 < s

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.8% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}} \end{array} \]
(FPCore (x c s) :precision binary64 (/ 1.0 (pow (* c (* x s)) 2.0)))
double code(double x, double c, double s) {
	return 1.0 / pow((c * (x * s)), 2.0);
}
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)) ** 2.0d0)
end function
public static double code(double x, double c, double s) {
	return 1.0 / Math.pow((c * (x * s)), 2.0);
}
def code(x, c, s):
	return 1.0 / math.pow((c * (x * s)), 2.0)
function code(x, c, s)
	return Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0))
end
function tmp = code(x, c, s)
	tmp = 1.0 / ((c * (x * s)) ^ 2.0);
end
code[x_, c_, s_] := N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}
\end{array}
Derivation
  1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.6% accurate, 14.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 8.5 \cdot 10^{-122}:\\ \;\;\;\;\left(\frac{1}{c \cdot \left(x \cdot x\right)} - \frac{2}{c}\right) \cdot \frac{1}{c \cdot \left(s \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 8.5e-122)
   (* (- (/ 1.0 (* c (* x x))) (/ 2.0 c)) (/ 1.0 (* c (* s s))))
   (/ 1.0 (* c (* x (* s (* x (* c s))))))))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 8.5e-122) {
		tmp = ((1.0 / (c * (x * x))) - (2.0 / c)) * (1.0 / (c * (s * s)));
	} else {
		tmp = 1.0 / (c * (x * (s * (x * (c * s)))));
	}
	return tmp;
}
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 (s <= 8.5d-122) then
        tmp = ((1.0d0 / (c * (x * x))) - (2.0d0 / c)) * (1.0d0 / (c * (s * s)))
    else
        tmp = 1.0d0 / (c * (x * (s * (x * (c * s)))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 8.5e-122) {
		tmp = ((1.0 / (c * (x * x))) - (2.0 / c)) * (1.0 / (c * (s * s)));
	} else {
		tmp = 1.0 / (c * (x * (s * (x * (c * s)))));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 8.5e-122:
		tmp = ((1.0 / (c * (x * x))) - (2.0 / c)) * (1.0 / (c * (s * s)))
	else:
		tmp = 1.0 / (c * (x * (s * (x * (c * s)))))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 8.5e-122)
		tmp = Float64(Float64(Float64(1.0 / Float64(c * Float64(x * x))) - Float64(2.0 / c)) * Float64(1.0 / Float64(c * Float64(s * s))));
	else
		tmp = Float64(1.0 / Float64(c * Float64(x * Float64(s * Float64(x * Float64(c * s))))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 8.5e-122)
		tmp = ((1.0 / (c * (x * x))) - (2.0 / c)) * (1.0 / (c * (s * s)));
	else
		tmp = 1.0 / (c * (x * (s * (x * (c * s)))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 8.5e-122], N[(N[(N[(1.0 / N[(c * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(c * N[(x * N[(s * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 8.5 \cdot 10^{-122}:\\
\;\;\;\;\left(\frac{1}{c \cdot \left(x \cdot x\right)} - \frac{2}{c}\right) \cdot \frac{1}{c \cdot \left(s \cdot s\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 8.50000000000000003e-122

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.50000000000000003e-122 < s

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
    8. Taylor expanded in x around 0 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 42.5% accurate, 20.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\ \;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+133}:\\ \;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(s \cdot \left(x \cdot \left(-s\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 3.3e-177)
   (/ 1.0 (* (- c c) (/ s s)))
   (if (<= x 1.2e+133)
     (/ 1.0 (* (* s (* x s)) (* c c)))
     (/ 1.0 (* c (* s (* x (- s))))))))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.3e-177) {
		tmp = 1.0 / ((c - c) * (s / s));
	} else if (x <= 1.2e+133) {
		tmp = 1.0 / ((s * (x * s)) * (c * c));
	} else {
		tmp = 1.0 / (c * (s * (x * -s)));
	}
	return tmp;
}
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 <= 3.3d-177) then
        tmp = 1.0d0 / ((c - c) * (s / s))
    else if (x <= 1.2d+133) then
        tmp = 1.0d0 / ((s * (x * s)) * (c * c))
    else
        tmp = 1.0d0 / (c * (s * (x * -s)))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.3e-177) {
		tmp = 1.0 / ((c - c) * (s / s));
	} else if (x <= 1.2e+133) {
		tmp = 1.0 / ((s * (x * s)) * (c * c));
	} else {
		tmp = 1.0 / (c * (s * (x * -s)));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 3.3e-177:
		tmp = 1.0 / ((c - c) * (s / s))
	elif x <= 1.2e+133:
		tmp = 1.0 / ((s * (x * s)) * (c * c))
	else:
		tmp = 1.0 / (c * (s * (x * -s)))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 3.3e-177)
		tmp = Float64(1.0 / Float64(Float64(c - c) * Float64(s / s)));
	elseif (x <= 1.2e+133)
		tmp = Float64(1.0 / Float64(Float64(s * Float64(x * s)) * Float64(c * c)));
	else
		tmp = Float64(1.0 / Float64(c * Float64(s * Float64(x * Float64(-s)))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 3.3e-177)
		tmp = 1.0 / ((c - c) * (s / s));
	elseif (x <= 1.2e+133)
		tmp = 1.0 / ((s * (x * s)) * (c * c));
	else
		tmp = 1.0 / (c * (s * (x * -s)));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 3.3e-177], N[(1.0 / N[(N[(c - c), $MachinePrecision] * N[(s / s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e+133], N[(1.0 / N[(N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(c * N[(s * N[(x * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\
\;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{+133}:\\
\;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.3e-177

    1. Initial program 67.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. associate-/r*66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.3e-177 < x < 1.1999999999999999e133

    1. Initial program 75.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. associate-/r*75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{e^{--2 \cdot \log c}} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-neg-in26.6%

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

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

        \[\leadsto \frac{1}{e^{\color{blue}{\log c + \log c}} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      4. prod-exp26.6%

        \[\leadsto \frac{1}{\color{blue}{\left(e^{\log c} \cdot e^{\log c}\right)} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      5. rem-exp-log26.6%

        \[\leadsto \frac{1}{\left(\color{blue}{c} \cdot e^{\log c}\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      6. rem-exp-log55.0%

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

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

    if 1.1999999999999999e133 < x

    1. Initial program 70.5%

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

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

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out64.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*70.5%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*61.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg61.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified67.8%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 58.0%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow258.0%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative58.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow258.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow258.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*62.8%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*62.4%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative62.8%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*69.4%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified69.4%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr59.7%

      \[\leadsto \frac{1}{\color{blue}{\left(-c\right)} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\ \;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+133}:\\ \;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(s \cdot \left(x \cdot \left(-s\right)\right)\right)}\\ \end{array} \]

Alternative 12: 42.5% accurate, 20.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := s \cdot \left(x \cdot s\right)\\ \mathbf{if}\;x \leq 3.2 \cdot 10^{-177}:\\ \;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+133}:\\ \;\;\;\;\frac{1}{t_0 \cdot \left(c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0 \cdot \frac{c}{-2}}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* s (* x s))))
   (if (<= x 3.2e-177)
     (/ 1.0 (* (- c c) (/ s s)))
     (if (<= x 1.2e+133) (/ 1.0 (* t_0 (* c c))) (/ 1.0 (* t_0 (/ c -2.0)))))))
double code(double x, double c, double s) {
	double t_0 = s * (x * s);
	double tmp;
	if (x <= 3.2e-177) {
		tmp = 1.0 / ((c - c) * (s / s));
	} else if (x <= 1.2e+133) {
		tmp = 1.0 / (t_0 * (c * c));
	} else {
		tmp = 1.0 / (t_0 * (c / -2.0));
	}
	return tmp;
}
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 * s)
    if (x <= 3.2d-177) then
        tmp = 1.0d0 / ((c - c) * (s / s))
    else if (x <= 1.2d+133) then
        tmp = 1.0d0 / (t_0 * (c * c))
    else
        tmp = 1.0d0 / (t_0 * (c / (-2.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = s * (x * s);
	double tmp;
	if (x <= 3.2e-177) {
		tmp = 1.0 / ((c - c) * (s / s));
	} else if (x <= 1.2e+133) {
		tmp = 1.0 / (t_0 * (c * c));
	} else {
		tmp = 1.0 / (t_0 * (c / -2.0));
	}
	return tmp;
}
def code(x, c, s):
	t_0 = s * (x * s)
	tmp = 0
	if x <= 3.2e-177:
		tmp = 1.0 / ((c - c) * (s / s))
	elif x <= 1.2e+133:
		tmp = 1.0 / (t_0 * (c * c))
	else:
		tmp = 1.0 / (t_0 * (c / -2.0))
	return tmp
function code(x, c, s)
	t_0 = Float64(s * Float64(x * s))
	tmp = 0.0
	if (x <= 3.2e-177)
		tmp = Float64(1.0 / Float64(Float64(c - c) * Float64(s / s)));
	elseif (x <= 1.2e+133)
		tmp = Float64(1.0 / Float64(t_0 * Float64(c * c)));
	else
		tmp = Float64(1.0 / Float64(t_0 * Float64(c / -2.0)));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = s * (x * s);
	tmp = 0.0;
	if (x <= 3.2e-177)
		tmp = 1.0 / ((c - c) * (s / s));
	elseif (x <= 1.2e+133)
		tmp = 1.0 / (t_0 * (c * c));
	else
		tmp = 1.0 / (t_0 * (c / -2.0));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.2e-177], N[(1.0 / N[(N[(c - c), $MachinePrecision] * N[(s / s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e+133], N[(1.0 / N[(t$95$0 * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 * N[(c / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 3.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{+133}:\\
\;\;\;\;\frac{1}{t_0 \cdot \left(c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0 \cdot \frac{c}{-2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.1999999999999998e-177

    1. Initial program 67.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. associate-/r*66.6%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg66.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out66.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out66.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out66.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*67.2%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative67.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*66.7%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*67.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*60.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg60.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*67.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative67.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow267.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg67.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow267.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified67.9%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 56.0%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow256.0%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative56.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow256.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow256.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*59.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*58.8%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative58.8%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*59.5%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*58.8%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative58.8%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative58.8%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*61.2%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified61.2%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr28.6%

      \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\frac{s}{s}}} \]
    8. Applied egg-rr35.0%

      \[\leadsto \frac{1}{\color{blue}{\left(c - c\right)} \cdot \frac{s}{s}} \]

    if 3.1999999999999998e-177 < x < 1.1999999999999999e133

    1. Initial program 75.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. associate-/r*75.1%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg75.1%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out75.1%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out75.1%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out75.1%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*75.2%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*73.4%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow275.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg75.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow275.2%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified75.1%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 64.4%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow264.4%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative64.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow264.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow264.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*64.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*64.3%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative64.3%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*64.4%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*64.3%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative64.3%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative64.3%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*66.1%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified66.1%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr26.6%

      \[\leadsto \frac{1}{\color{blue}{e^{--2 \cdot \log c}} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-neg-in26.6%

        \[\leadsto \frac{1}{e^{\color{blue}{\left(--2\right) \cdot \log c}} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      2. metadata-eval26.6%

        \[\leadsto \frac{1}{e^{\color{blue}{2} \cdot \log c} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      3. count-226.6%

        \[\leadsto \frac{1}{e^{\color{blue}{\log c + \log c}} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      4. prod-exp26.6%

        \[\leadsto \frac{1}{\color{blue}{\left(e^{\log c} \cdot e^{\log c}\right)} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      5. rem-exp-log26.6%

        \[\leadsto \frac{1}{\left(\color{blue}{c} \cdot e^{\log c}\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
      6. rem-exp-log55.0%

        \[\leadsto \frac{1}{\left(c \cdot \color{blue}{c}\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
    9. Simplified55.0%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]

    if 1.1999999999999999e133 < x

    1. Initial program 70.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*64.4%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg64.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out64.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out64.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out64.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*70.5%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*61.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg61.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified67.8%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 58.0%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow258.0%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative58.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow258.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow258.0%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*62.8%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*62.4%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative62.8%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative62.8%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*69.4%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified69.4%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr59.6%

      \[\leadsto \frac{1}{\color{blue}{\frac{c}{-2}} \cdot \left(s \cdot \left(s \cdot x\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.2 \cdot 10^{-177}:\\ \;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+133}:\\ \;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot s\right)\right) \cdot \frac{c}{-2}}\\ \end{array} \]

Alternative 13: 72.0% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \frac{1}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)} \end{array} \]
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* x (* c (* s (* x s)))))))
double code(double x, double c, double s) {
	return 1.0 / (c * (x * (c * (s * (x * s)))));
}
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 * (c * (s * (x * s)))))
end function
public static double code(double x, double c, double s) {
	return 1.0 / (c * (x * (c * (s * (x * s)))));
}
def code(x, c, s):
	return 1.0 / (c * (x * (c * (s * (x * s)))))
function code(x, c, s)
	return Float64(1.0 / Float64(c * Float64(x * Float64(c * Float64(s * Float64(x * s))))))
end
function tmp = code(x, c, s)
	tmp = 1.0 / (c * (x * (c * (s * (x * s)))));
end
code[x_, c_, s_] := N[(1.0 / N[(c * N[(x * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 69.5%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. associate-/r*68.3%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
    2. remove-double-neg68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
    5. distribute-rgt-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
    6. associate-/r*69.5%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
    7. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    8. associate-*r*68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
    9. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    10. associate-*r*63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
    11. sqr-neg63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
    12. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
    13. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    14. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    15. sqr-neg69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    16. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  3. Simplified69.5%

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
  4. Step-by-step derivation
    1. associate-/r*69.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    2. associate-*l*77.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\color{blue}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    3. associate-/r*79.3%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    4. associate-*r*83.4%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot s\right)}} \]
    5. associate-*r*90.4%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot s}} \]
    6. associate-/r*89.6%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)}}{s}} \]
    7. div-inv89.6%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s}} \]
    8. associate-/l/89.7%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot x}}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
    9. count-289.7%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
    10. *-commutative89.7%

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \color{blue}{\left(s \cdot x\right)}} \cdot \frac{1}{s} \]
  5. Applied egg-rr89.7%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot \frac{1}{s}} \]
  6. Step-by-step derivation
    1. associate-*r/89.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot 1}{s}} \]
    2. *-rgt-identity89.7%

      \[\leadsto \frac{\color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)}}}{s} \]
    3. associate-/l/89.4%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}}{s} \]
  7. Simplified89.4%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
  8. Taylor expanded in x around 0 58.1%

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  9. Step-by-step derivation
    1. unpow258.1%

      \[\leadsto \frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
    2. associate-*r*60.9%

      \[\leadsto \frac{1}{{c}^{2} \cdot \color{blue}{\left(\left({s}^{2} \cdot x\right) \cdot x\right)}} \]
    3. unpow260.9%

      \[\leadsto \frac{1}{{c}^{2} \cdot \left(\left(\color{blue}{\left(s \cdot s\right)} \cdot x\right) \cdot x\right)} \]
    4. associate-*r*64.5%

      \[\leadsto \frac{1}{{c}^{2} \cdot \left(\color{blue}{\left(s \cdot \left(s \cdot x\right)\right)} \cdot x\right)} \]
    5. associate-*l*64.1%

      \[\leadsto \frac{1}{\color{blue}{\left({c}^{2} \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x}} \]
    6. unpow264.1%

      \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x} \]
    7. associate-*r*70.2%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)\right)} \cdot x} \]
    8. associate-*l*70.7%

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x\right)}} \]
  10. Simplified70.7%

    \[\leadsto \color{blue}{\frac{1}{c \cdot \left(\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x\right)}} \]
  11. Final simplification70.7%

    \[\leadsto \frac{1}{c \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)} \]

Alternative 14: 75.0% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \frac{1}{c \cdot \left(x \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)} \end{array} \]
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* x (* s (* x (* c s)))))))
double code(double x, double c, double s) {
	return 1.0 / (c * (x * (s * (x * (c * s)))));
}
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 * (x * (c * s)))))
end function
public static double code(double x, double c, double s) {
	return 1.0 / (c * (x * (s * (x * (c * s)))));
}
def code(x, c, s):
	return 1.0 / (c * (x * (s * (x * (c * s)))))
function code(x, c, s)
	return Float64(1.0 / Float64(c * Float64(x * Float64(s * Float64(x * Float64(c * s))))))
end
function tmp = code(x, c, s)
	tmp = 1.0 / (c * (x * (s * (x * (c * s)))));
end
code[x_, c_, s_] := N[(1.0 / N[(c * N[(x * N[(s * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{c \cdot \left(x \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 69.5%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. associate-/r*68.3%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
    2. remove-double-neg68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
    5. distribute-rgt-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
    6. associate-/r*69.5%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
    7. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    8. associate-*r*68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
    9. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    10. associate-*r*63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
    11. sqr-neg63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
    12. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
    13. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    14. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    15. sqr-neg69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    16. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  3. Simplified69.5%

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
  4. Step-by-step derivation
    1. associate-/r*69.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    2. associate-*l*77.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\color{blue}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    3. associate-/r*79.3%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    4. associate-*r*83.4%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot s\right)}} \]
    5. associate-*r*90.4%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot s}} \]
    6. associate-/r*89.6%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)}}{s}} \]
    7. div-inv89.6%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s}} \]
    8. associate-/l/89.7%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot x}}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
    9. count-289.7%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
    10. *-commutative89.7%

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \color{blue}{\left(s \cdot x\right)}} \cdot \frac{1}{s} \]
  5. Applied egg-rr89.7%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot \frac{1}{s}} \]
  6. Step-by-step derivation
    1. associate-*r/89.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot 1}{s}} \]
    2. *-rgt-identity89.7%

      \[\leadsto \frac{\color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)}}}{s} \]
    3. associate-/l/89.4%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}}{s} \]
  7. Simplified89.4%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
  8. Taylor expanded in x around 0 58.1%

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  9. Step-by-step derivation
    1. unpow258.1%

      \[\leadsto \frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
    2. associate-*r*60.9%

      \[\leadsto \frac{1}{{c}^{2} \cdot \color{blue}{\left(\left({s}^{2} \cdot x\right) \cdot x\right)}} \]
    3. unpow260.9%

      \[\leadsto \frac{1}{{c}^{2} \cdot \left(\left(\color{blue}{\left(s \cdot s\right)} \cdot x\right) \cdot x\right)} \]
    4. associate-*r*64.5%

      \[\leadsto \frac{1}{{c}^{2} \cdot \left(\color{blue}{\left(s \cdot \left(s \cdot x\right)\right)} \cdot x\right)} \]
    5. associate-*l*64.1%

      \[\leadsto \frac{1}{\color{blue}{\left({c}^{2} \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x}} \]
    6. unpow264.1%

      \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x} \]
    7. associate-*r*70.2%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)\right)} \cdot x} \]
    8. associate-*l*70.7%

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right) \cdot x\right)}} \]
    9. *-commutative70.7%

      \[\leadsto \frac{1}{c \cdot \left(\color{blue}{\left(\left(s \cdot \left(s \cdot x\right)\right) \cdot c\right)} \cdot x\right)} \]
    10. associate-*l*75.7%

      \[\leadsto \frac{1}{c \cdot \left(\color{blue}{\left(s \cdot \left(\left(s \cdot x\right) \cdot c\right)\right)} \cdot x\right)} \]
    11. *-commutative75.7%

      \[\leadsto \frac{1}{c \cdot \left(\left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right) \cdot x\right)} \]
    12. associate-*r*75.7%

      \[\leadsto \frac{1}{c \cdot \left(\left(s \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right) \cdot x\right)} \]
    13. *-commutative75.7%

      \[\leadsto \frac{1}{c \cdot \left(\left(s \cdot \color{blue}{\left(x \cdot \left(c \cdot s\right)\right)}\right) \cdot x\right)} \]
  10. Simplified75.7%

    \[\leadsto \color{blue}{\frac{1}{c \cdot \left(\left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot x\right)}} \]
  11. Final simplification75.7%

    \[\leadsto \frac{1}{c \cdot \left(x \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)} \]

Alternative 15: 38.1% accurate, 28.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 4.1 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 4.1e+95) (/ 1.0 (* (- c c) (/ s s))) 0.0))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 4.1e+95) {
		tmp = 1.0 / ((c - c) * (s / s));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 (s <= 4.1d+95) then
        tmp = 1.0d0 / ((c - c) * (s / s))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 4.1e+95) {
		tmp = 1.0 / ((c - c) * (s / s));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 4.1e+95:
		tmp = 1.0 / ((c - c) * (s / s))
	else:
		tmp = 0.0
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 4.1e+95)
		tmp = Float64(1.0 / Float64(Float64(c - c) * Float64(s / s)));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 4.1e+95)
		tmp = 1.0 / ((c - c) * (s / s));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 4.1e+95], N[(1.0 / N[(N[(c - c), $MachinePrecision] * N[(s / s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 4.1 \cdot 10^{+95}:\\
\;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 4.09999999999999986e95

    1. Initial program 70.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*69.6%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*70.5%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*70.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*63.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg63.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 57.4%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow257.4%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative57.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow257.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow257.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*60.7%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*60.8%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative60.7%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*63.6%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified63.6%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr35.3%

      \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\frac{s}{s}}} \]
    8. Applied egg-rr34.0%

      \[\leadsto \frac{1}{\color{blue}{\left(c - c\right)} \cdot \frac{s}{s}} \]

    if 4.09999999999999986e95 < s

    1. Initial program 64.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*61.8%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*64.1%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*61.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*63.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg63.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow264.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow264.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified64.1%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*65.5%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      2. associate-*l*77.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\color{blue}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      3. associate-/r*77.6%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      4. associate-*r*82.1%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot s\right)}} \]
      5. associate-*r*88.8%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot s}} \]
      6. associate-/r*88.8%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)}}{s}} \]
      7. div-inv88.7%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s}} \]
      8. associate-/l/88.7%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot x}}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      9. count-288.7%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      10. *-commutative88.7%

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \color{blue}{\left(s \cdot x\right)}} \cdot \frac{1}{s} \]
    5. Applied egg-rr88.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot \frac{1}{s}} \]
    6. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot 1}{s}} \]
      2. *-rgt-identity88.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)}}}{s} \]
      3. associate-/l/88.8%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}}{s} \]
    7. Simplified88.8%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
    8. Applied egg-rr62.7%

      \[\leadsto \color{blue}{c - c} \]
    9. Step-by-step derivation
      1. +-inverses62.7%

        \[\leadsto \color{blue}{0} \]
    10. Simplified62.7%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification38.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 4.1 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{\left(c - c\right) \cdot \frac{s}{s}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 16: 34.5% accurate, 34.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 5.1 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 5.1e+95) (/ 1.0 (* c (* x c))) 0.0))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 5.1e+95) {
		tmp = 1.0 / (c * (x * c));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 (s <= 5.1d+95) then
        tmp = 1.0d0 / (c * (x * c))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 5.1e+95) {
		tmp = 1.0 / (c * (x * c));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 5.1e+95:
		tmp = 1.0 / (c * (x * c))
	else:
		tmp = 0.0
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 5.1e+95)
		tmp = Float64(1.0 / Float64(c * Float64(x * c)));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 5.1e+95)
		tmp = 1.0 / (c * (x * c));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 5.1e+95], N[(1.0 / N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 5.1 \cdot 10^{+95}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 5.10000000000000003e95

    1. Initial program 70.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*69.6%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*70.5%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*70.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*63.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg63.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 57.4%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow257.4%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative57.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow257.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow257.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*60.7%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*60.8%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative60.7%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*63.6%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified63.6%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr35.3%

      \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\frac{s}{s}}} \]
    8. Taylor expanded in c around 0 35.3%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot x}} \]
    9. Step-by-step derivation
      1. unpow235.3%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot x} \]
      2. associate-*l*32.8%

        \[\leadsto \frac{1}{\color{blue}{c \cdot \left(c \cdot x\right)}} \]
    10. Simplified32.8%

      \[\leadsto \color{blue}{\frac{1}{c \cdot \left(c \cdot x\right)}} \]

    if 5.10000000000000003e95 < s

    1. Initial program 64.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*61.8%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*64.1%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*61.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*63.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg63.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow264.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow264.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified64.1%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*65.5%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      2. associate-*l*77.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\color{blue}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      3. associate-/r*77.6%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      4. associate-*r*82.1%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot s\right)}} \]
      5. associate-*r*88.8%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot s}} \]
      6. associate-/r*88.8%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)}}{s}} \]
      7. div-inv88.7%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s}} \]
      8. associate-/l/88.7%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot x}}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      9. count-288.7%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      10. *-commutative88.7%

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \color{blue}{\left(s \cdot x\right)}} \cdot \frac{1}{s} \]
    5. Applied egg-rr88.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot \frac{1}{s}} \]
    6. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot 1}{s}} \]
      2. *-rgt-identity88.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)}}}{s} \]
      3. associate-/l/88.8%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}}{s} \]
    7. Simplified88.8%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
    8. Applied egg-rr62.7%

      \[\leadsto \color{blue}{c - c} \]
    9. Step-by-step derivation
      1. +-inverses62.7%

        \[\leadsto \color{blue}{0} \]
    10. Simplified62.7%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification37.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 5.1 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 17: 36.0% accurate, 34.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 5.4 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{1}{x}}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 5.4e+95) (/ (/ 1.0 x) (* c c)) 0.0))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 5.4e+95) {
		tmp = (1.0 / x) / (c * c);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
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 (s <= 5.4d+95) then
        tmp = (1.0d0 / x) / (c * c)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 5.4e+95) {
		tmp = (1.0 / x) / (c * c);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 5.4e+95:
		tmp = (1.0 / x) / (c * c)
	else:
		tmp = 0.0
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 5.4e+95)
		tmp = Float64(Float64(1.0 / x) / Float64(c * c));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 5.4e+95)
		tmp = (1.0 / x) / (c * c);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 5.4e+95], N[(N[(1.0 / x), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 5.4 \cdot 10^{+95}:\\
\;\;\;\;\frac{\frac{1}{x}}{c \cdot c}\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 5.4e95

    1. Initial program 70.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*69.6%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out69.6%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*70.5%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*70.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*63.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg63.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg70.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow270.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Taylor expanded in x around 0 57.4%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    5. Step-by-step derivation
      1. unpow257.4%

        \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      2. *-commutative57.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
      3. unpow257.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      4. unpow257.4%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
      5. associate-*r*60.7%

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      6. associate-*r*60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      7. *-commutative60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      8. associate-*r*60.8%

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      9. associate-*r*60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      10. *-commutative60.7%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
      11. *-commutative60.7%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
      12. associate-*r*63.6%

        \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
    6. Simplified63.6%

      \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
    7. Applied egg-rr35.3%

      \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\frac{s}{s}}} \]
    8. Taylor expanded in c around 0 35.3%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot x}} \]
    9. Step-by-step derivation
      1. associate-/l/35.3%

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{{c}^{2}}} \]
      2. unpow235.3%

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{c \cdot c}} \]
    10. Simplified35.3%

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{c \cdot c}} \]

    if 5.4e95 < s

    1. Initial program 64.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. associate-/r*61.8%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out61.8%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
      6. associate-/r*64.1%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
      7. *-commutative64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      8. associate-*r*61.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
      9. associate-*r*64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
      10. associate-*r*63.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
      11. sqr-neg63.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      12. associate-*r*64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      13. *-commutative64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      14. unpow264.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      15. sqr-neg64.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      16. unpow264.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    3. Simplified64.1%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*65.5%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      2. associate-*l*77.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\color{blue}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
      3. associate-/r*77.6%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
      4. associate-*r*82.1%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot s\right)}} \]
      5. associate-*r*88.8%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot s}} \]
      6. associate-/r*88.8%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)}}{s}} \]
      7. div-inv88.7%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s}} \]
      8. associate-/l/88.7%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot x}}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      9. count-288.7%

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
      10. *-commutative88.7%

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \color{blue}{\left(s \cdot x\right)}} \cdot \frac{1}{s} \]
    5. Applied egg-rr88.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot \frac{1}{s}} \]
    6. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot 1}{s}} \]
      2. *-rgt-identity88.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)}}}{s} \]
      3. associate-/l/88.8%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}}{s} \]
    7. Simplified88.8%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
    8. Applied egg-rr62.7%

      \[\leadsto \color{blue}{c - c} \]
    9. Step-by-step derivation
      1. +-inverses62.7%

        \[\leadsto \color{blue}{0} \]
    10. Simplified62.7%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 5.4 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{1}{x}}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 18: 2.2% accurate, 313.0× speedup?

\[\begin{array}{l} \\ -0.5 \end{array} \]
(FPCore (x c s) :precision binary64 -0.5)
double code(double x, double c, double s) {
	return -0.5;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = -0.5d0
end function
public static double code(double x, double c, double s) {
	return -0.5;
}
def code(x, c, s):
	return -0.5
function code(x, c, s)
	return -0.5
end
function tmp = code(x, c, s)
	tmp = -0.5;
end
code[x_, c_, s_] := -0.5
\begin{array}{l}

\\
-0.5
\end{array}
Derivation
  1. Initial program 69.5%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. associate-/r*68.3%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
    2. remove-double-neg68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
    5. distribute-rgt-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
    6. associate-/r*69.5%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
    7. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    8. associate-*r*68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
    9. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    10. associate-*r*63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
    11. sqr-neg63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
    12. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
    13. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    14. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    15. sqr-neg69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    16. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  3. Simplified69.5%

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
  4. Taylor expanded in x around 0 58.1%

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  5. Step-by-step derivation
    1. unpow258.1%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
    2. *-commutative58.1%

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left({x}^{2} \cdot {s}^{2}\right)}} \]
    3. unpow258.1%

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
    4. unpow258.1%

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
    5. associate-*r*60.9%

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    6. associate-*r*60.5%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    7. *-commutative60.5%

      \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
    8. associate-*r*61.0%

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    9. associate-*r*60.5%

      \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    10. *-commutative60.5%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
    11. *-commutative60.5%

      \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot s\right) \cdot x\right)}} \]
    12. associate-*r*63.4%

      \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
  6. Simplified63.4%

    \[\leadsto \color{blue}{\frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot \left(s \cdot x\right)\right)}} \]
  7. Applied egg-rr34.5%

    \[\leadsto \frac{1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\frac{s}{s}}} \]
  8. Applied egg-rr3.3%

    \[\leadsto \frac{1}{\color{blue}{\left(-2 - c\right)} \cdot \frac{s}{s}} \]
  9. Taylor expanded in c around 0 2.2%

    \[\leadsto \color{blue}{-0.5} \]
  10. Final simplification2.2%

    \[\leadsto -0.5 \]

Alternative 19: 32.9% accurate, 313.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x c s) :precision binary64 0.0)
double code(double x, double c, double s) {
	return 0.0;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 0.0d0
end function
public static double code(double x, double c, double s) {
	return 0.0;
}
def code(x, c, s):
	return 0.0
function code(x, c, s)
	return 0.0
end
function tmp = code(x, c, s)
	tmp = 0.0;
end
code[x_, c_, s_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 69.5%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. associate-/r*68.3%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
    2. remove-double-neg68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
    5. distribute-rgt-neg-out68.3%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)}} \]
    6. associate-/r*69.5%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right)}} \]
    7. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    8. associate-*r*68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot \left(-x\right)\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)}} \]
    9. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(-x\right) \cdot \left(\left(-x\right) \cdot {s}^{2}\right)\right)}} \]
    10. associate-*r*63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot {s}^{2}\right)}} \]
    11. sqr-neg63.9%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
    12. associate-*r*69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
    13. *-commutative69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    14. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    15. sqr-neg69.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(-c\right) \cdot \left(-c\right)\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    16. unpow269.5%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(-c\right)}^{2}} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  3. Simplified69.5%

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
  4. Step-by-step derivation
    1. associate-/r*69.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    2. associate-*l*77.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{x}}{\color{blue}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
    3. associate-/r*79.3%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    4. associate-*r*83.4%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot s\right)}} \]
    5. associate-*r*90.4%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{\color{blue}{\left(c \cdot \left(x \cdot s\right)\right) \cdot s}} \]
    6. associate-/r*89.6%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)}}{s}} \]
    7. div-inv89.6%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x}}{c}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s}} \]
    8. associate-/l/89.7%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot x}}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
    9. count-289.7%

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c \cdot x}}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{s} \]
    10. *-commutative89.7%

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \color{blue}{\left(s \cdot x\right)}} \cdot \frac{1}{s} \]
  5. Applied egg-rr89.7%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot \frac{1}{s}} \]
  6. Step-by-step derivation
    1. associate-*r/89.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)} \cdot 1}{s}} \]
    2. *-rgt-identity89.7%

      \[\leadsto \frac{\color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot x}}{c \cdot \left(s \cdot x\right)}}}{s} \]
    3. associate-/l/89.4%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}}{s} \]
  7. Simplified89.4%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot x\right)}}{s}} \]
  8. Applied egg-rr35.2%

    \[\leadsto \color{blue}{c - c} \]
  9. Step-by-step derivation
    1. +-inverses35.2%

      \[\leadsto \color{blue}{0} \]
  10. Simplified35.2%

    \[\leadsto \color{blue}{0} \]
  11. Final simplification35.2%

    \[\leadsto 0 \]

Reproduce

?
herbie shell --seed 2023297 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))