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



Bits error versus x



Bits error versus c



Bits error versus s
Results
if s < 7.7964485768190474e-90Initial program 34.4
Simplified3.7
Applied egg-rr3.5
Applied egg-rr3.6
if 7.7964485768190474e-90 < s < 4.3187385146686588e217Initial program 24.4
Simplified1.9
Applied egg-rr2.0
Taylor expanded in x around inf 1.3
if 4.3187385146686588e217 < s Initial program 25.0
Simplified2.2
Applied egg-rr2.0
Final simplification2.3
herbie shell --seed 2022153
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))