(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 (* c (* x s)))
(t_2 (* x (* c s)))
(t_3 (/ 1.0 t_2)))
(if (<= x -1.95e-62)
(* t_0 (* t_3 t_3))
(if (<= x -5.4e-253)
(/ (cos (* x 2.0)) (pow t_1 2.0))
(if (<= x 5.8e-218)
(* t_0 (pow (* s (* x c)) -2.0))
(if (<= x 1.85e+217)
(* t_0 (pow t_2 -2.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 = c * (x * s);
double t_2 = x * (c * s);
double t_3 = 1.0 / t_2;
double tmp;
if (x <= -1.95e-62) {
tmp = t_0 * (t_3 * t_3);
} else if (x <= -5.4e-253) {
tmp = cos((x * 2.0)) / pow(t_1, 2.0);
} else if (x <= 5.8e-218) {
tmp = t_0 * pow((s * (x * c)), -2.0);
} else if (x <= 1.85e+217) {
tmp = t_0 * pow(t_2, -2.0);
} else {
tmp = t_0 * pow(t_1, -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
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos((x + x))
t_1 = c * (x * s)
t_2 = x * (c * s)
t_3 = 1.0d0 / t_2
if (x <= (-1.95d-62)) then
tmp = t_0 * (t_3 * t_3)
else if (x <= (-5.4d-253)) then
tmp = cos((x * 2.0d0)) / (t_1 ** 2.0d0)
else if (x <= 5.8d-218) then
tmp = t_0 * ((s * (x * c)) ** (-2.0d0))
else if (x <= 1.85d+217) then
tmp = t_0 * (t_2 ** (-2.0d0))
else
tmp = t_0 * (t_1 ** (-2.0d0))
end if
code = tmp
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));
}
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x + x));
double t_1 = c * (x * s);
double t_2 = x * (c * s);
double t_3 = 1.0 / t_2;
double tmp;
if (x <= -1.95e-62) {
tmp = t_0 * (t_3 * t_3);
} else if (x <= -5.4e-253) {
tmp = Math.cos((x * 2.0)) / Math.pow(t_1, 2.0);
} else if (x <= 5.8e-218) {
tmp = t_0 * Math.pow((s * (x * c)), -2.0);
} else if (x <= 1.85e+217) {
tmp = t_0 * Math.pow(t_2, -2.0);
} else {
tmp = t_0 * Math.pow(t_1, -2.0);
}
return tmp;
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
def code(x, c, s): t_0 = math.cos((x + x)) t_1 = c * (x * s) t_2 = x * (c * s) t_3 = 1.0 / t_2 tmp = 0 if x <= -1.95e-62: tmp = t_0 * (t_3 * t_3) elif x <= -5.4e-253: tmp = math.cos((x * 2.0)) / math.pow(t_1, 2.0) elif x <= 5.8e-218: tmp = t_0 * math.pow((s * (x * c)), -2.0) elif x <= 1.85e+217: tmp = t_0 * math.pow(t_2, -2.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(c * Float64(x * s)) t_2 = Float64(x * Float64(c * s)) t_3 = Float64(1.0 / t_2) tmp = 0.0 if (x <= -1.95e-62) tmp = Float64(t_0 * Float64(t_3 * t_3)); elseif (x <= -5.4e-253) tmp = Float64(cos(Float64(x * 2.0)) / (t_1 ^ 2.0)); elseif (x <= 5.8e-218) tmp = Float64(t_0 * (Float64(s * Float64(x * c)) ^ -2.0)); elseif (x <= 1.85e+217) tmp = Float64(t_0 * (t_2 ^ -2.0)); else tmp = Float64(t_0 * (t_1 ^ -2.0)); end return tmp end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
function tmp_2 = code(x, c, s) t_0 = cos((x + x)); t_1 = c * (x * s); t_2 = x * (c * s); t_3 = 1.0 / t_2; tmp = 0.0; if (x <= -1.95e-62) tmp = t_0 * (t_3 * t_3); elseif (x <= -5.4e-253) tmp = cos((x * 2.0)) / (t_1 ^ 2.0); elseif (x <= 5.8e-218) tmp = t_0 * ((s * (x * c)) ^ -2.0); elseif (x <= 1.85e+217) tmp = t_0 * (t_2 ^ -2.0); else tmp = t_0 * (t_1 ^ -2.0); end tmp_2 = 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[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / t$95$2), $MachinePrecision]}, If[LessEqual[x, -1.95e-62], N[(t$95$0 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.4e-253], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e-218], N[(t$95$0 * N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.85e+217], N[(t$95$0 * N[Power[t$95$2, -2.0], $MachinePrecision]), $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 := c \cdot \left(x \cdot s\right)\\
t_2 := x \cdot \left(c \cdot s\right)\\
t_3 := \frac{1}{t_2}\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{-62}:\\
\;\;\;\;t_0 \cdot \left(t_3 \cdot t_3\right)\\
\mathbf{elif}\;x \leq -5.4 \cdot 10^{-253}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{t_1}^{2}}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-218}:\\
\;\;\;\;t_0 \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+217}:\\
\;\;\;\;t_0 \cdot {t_2}^{-2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot {t_1}^{-2}\\
\end{array}



Bits error versus x



Bits error versus c



Bits error versus s
Results
if x < -1.9500000000000002e-62Initial program 24.1
Simplified2.0
Applied egg-rr2.3
Applied egg-rr1.6
if -1.9500000000000002e-62 < x < -5.39999999999999998e-253Initial program 35.8
Simplified2.8
Applied egg-rr4.3
if -5.39999999999999998e-253 < x < 5.8000000000000004e-218Initial program 49.9
Simplified18.0
Applied egg-rr4.5
Taylor expanded in c around 0 5.3
if 5.8000000000000004e-218 < x < 1.85000000000000005e217Initial program 26.2
Simplified1.3
Applied egg-rr2.5
Applied egg-rr0.9
if 1.85000000000000005e217 < x Initial program 27.9
Simplified5.6
Applied egg-rr2.6
Applied egg-rr5.3
Taylor expanded in x around 0 2.6
Final simplification2.0
herbie shell --seed 2022162
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))