\frac{\cos \left(2 \cdot x\right)}{{cos}^{2} \cdot \left(\left(x \cdot {sin}^{2}\right) \cdot x\right)}\begin{array}{l}
\mathbf{if}\;cos \le -9.4308741933923411 \cdot 10^{-213}:\\
\;\;\;\;\cos \left(2 \cdot x\right) \cdot \frac{\frac{1}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}\\
\mathbf{elif}\;cos \le 4.1817646661223308 \cdot 10^{-149}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{{\left(\left|{\left({cos}^{1} \cdot {sin}^{1}\right)}^{1} \cdot x\right|\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}}{\left|{cos}^{\left(\frac{2}{2}\right)} \cdot \left(x \cdot {sin}^{\left(\frac{2}{2}\right)}\right)\right|}\\
\end{array}double code(double x, double cos, double sin) {
return (cos((2.0 * x)) / (pow(cos, 2.0) * ((x * pow(sin, 2.0)) * x)));
}
double code(double x, double cos, double sin) {
double temp;
if ((cos <= -9.430874193392341e-213)) {
temp = (cos((2.0 * x)) * ((1.0 / fabs((pow(cos, (2.0 / 2.0)) * (x * pow(sin, (2.0 / 2.0)))))) / fabs((pow(cos, (2.0 / 2.0)) * (x * pow(sin, (2.0 / 2.0)))))));
} else {
double temp_1;
if ((cos <= 4.181764666122331e-149)) {
temp_1 = (cos((2.0 * x)) / pow(fabs((pow((pow(cos, 1.0) * pow(sin, 1.0)), 1.0) * x)), 2.0));
} else {
temp_1 = ((cos((2.0 * x)) / fabs((pow(cos, (2.0 / 2.0)) * (x * pow(sin, (2.0 / 2.0)))))) / fabs((pow(cos, (2.0 / 2.0)) * (x * pow(sin, (2.0 / 2.0))))));
}
temp = temp_1;
}
return temp;
}



Bits error versus x



Bits error versus cos



Bits error versus sin
Results
if cos < -9.430874193392341e-213Initial program 24.8
rmApplied sqr-pow24.8
Applied associate-*r*18.0
rmApplied add-sqr-sqrt18.0
Simplified18.0
Simplified1.6
rmApplied associate-/r*1.3
rmApplied *-un-lft-identity1.3
Applied div-inv1.3
Applied times-frac1.3
Simplified1.3
if -9.430874193392341e-213 < cos < 4.181764666122331e-149Initial program 61.5
rmApplied sqr-pow61.5
Applied associate-*r*61.1
rmApplied add-sqr-sqrt61.1
Simplified61.1
Simplified9.5
Taylor expanded around 0 6.0
Simplified6.0
if 4.181764666122331e-149 < cos Initial program 22.6
rmApplied sqr-pow22.6
Applied associate-*r*15.2
rmApplied add-sqr-sqrt15.2
Simplified15.2
Simplified1.9
rmApplied associate-/r*1.7
Final simplification2.0
herbie shell --seed 2020057 +o rules:numerics
(FPCore (x cos sin)
:name "cos(2*x)/(cos^2(x)*sin^2(x))"
:precision binary64
(/ (cos (* 2 x)) (* (pow cos 2) (* (* x (pow sin 2)) x))))