
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin x))))
(if (<= eps -0.0029)
(fma (sin eps) t_0 (- (* (cos eps) (cos x)) (cos x)))
(if (<= eps 0.0018)
(+
(*
(cos x)
(+ (* -0.5 (pow eps 2.0)) (* 0.041666666666666664 (pow eps 4.0))))
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps)))
(fma (expm1 (log1p (sin eps))) t_0 (* (cos x) (+ -1.0 (cos eps))))))))
double code(double x, double eps) {
double t_0 = -sin(x);
double tmp;
if (eps <= -0.0029) {
tmp = fma(sin(eps), t_0, ((cos(eps) * cos(x)) - cos(x)));
} else if (eps <= 0.0018) {
tmp = (cos(x) * ((-0.5 * pow(eps, 2.0)) + (0.041666666666666664 * pow(eps, 4.0)))) + (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps));
} else {
tmp = fma(expm1(log1p(sin(eps))), t_0, (cos(x) * (-1.0 + cos(eps))));
}
return tmp;
}
function code(x, eps) t_0 = Float64(-sin(x)) tmp = 0.0 if (eps <= -0.0029) tmp = fma(sin(eps), t_0, Float64(Float64(cos(eps) * cos(x)) - cos(x))); elseif (eps <= 0.0018) tmp = Float64(Float64(cos(x) * Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(0.041666666666666664 * (eps ^ 4.0)))) + Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); else tmp = fma(expm1(log1p(sin(eps))), t_0, Float64(cos(x) * Float64(-1.0 + cos(eps)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Sin[x], $MachinePrecision])}, If[LessEqual[eps, -0.0029], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0018], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Exp[N[Log[1 + N[Sin[eps], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] * t$95$0 + N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin x\\
\mathbf{if}\;\varepsilon \leq -0.0029:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos \varepsilon \cdot \cos x - \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0018:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2} + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) + \sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \varepsilon\right)\right), t_0, \cos x \cdot \left(-1 + \cos \varepsilon\right)\right)\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (fma (sin eps) (- (sin x)) (/ (pow (sin eps) 2.0) (/ (- -1.0 (cos eps)) (cos x)))))
double code(double x, double eps) {
return fma(sin(eps), -sin(x), (pow(sin(eps), 2.0) / ((-1.0 - cos(eps)) / cos(x))));
}
function code(x, eps) return fma(sin(eps), Float64(-sin(x)), Float64((sin(eps) ^ 2.0) / Float64(Float64(-1.0 - cos(eps)) / cos(x)))) end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision]) + N[(N[Power[N[Sin[eps], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(-1.0 - N[Cos[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \varepsilon, -\sin x, \frac{{\sin \varepsilon}^{2}}{\frac{-1 - \cos \varepsilon}{\cos x}}\right)
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin x))))
(if (<= eps -0.00235)
(fma (sin eps) t_0 (- (* (cos eps) (cos x)) (cos x)))
(if (<= eps 0.0018)
(+
(*
(cos x)
(+ (* -0.5 (pow eps 2.0)) (* 0.041666666666666664 (pow eps 4.0))))
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps)))
(fma (sin eps) t_0 (* (cos x) (+ -1.0 (cos eps))))))))
double code(double x, double eps) {
double t_0 = -sin(x);
double tmp;
if (eps <= -0.00235) {
tmp = fma(sin(eps), t_0, ((cos(eps) * cos(x)) - cos(x)));
} else if (eps <= 0.0018) {
tmp = (cos(x) * ((-0.5 * pow(eps, 2.0)) + (0.041666666666666664 * pow(eps, 4.0)))) + (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps));
} else {
tmp = fma(sin(eps), t_0, (cos(x) * (-1.0 + cos(eps))));
}
return tmp;
}
function code(x, eps) t_0 = Float64(-sin(x)) tmp = 0.0 if (eps <= -0.00235) tmp = fma(sin(eps), t_0, Float64(Float64(cos(eps) * cos(x)) - cos(x))); elseif (eps <= 0.0018) tmp = Float64(Float64(cos(x) * Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(0.041666666666666664 * (eps ^ 4.0)))) + Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); else tmp = fma(sin(eps), t_0, Float64(cos(x) * Float64(-1.0 + cos(eps)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Sin[x], $MachinePrecision])}, If[LessEqual[eps, -0.00235], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0018], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin x\\
\mathbf{if}\;\varepsilon \leq -0.00235:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos \varepsilon \cdot \cos x - \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0018:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2} + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) + \sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos x \cdot \left(-1 + \cos \varepsilon\right)\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= eps -0.00215)
(- (* (cos eps) (cos x)) (+ (cos x) (* (sin eps) (sin x))))
(if (<= eps 0.0018)
(+
(*
(cos x)
(+ (* -0.5 (pow eps 2.0)) (* 0.041666666666666664 (pow eps 4.0))))
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps)))
(fma (sin eps) (- (sin x)) (* (cos x) (+ -1.0 (cos eps)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00215) {
tmp = (cos(eps) * cos(x)) - (cos(x) + (sin(eps) * sin(x)));
} else if (eps <= 0.0018) {
tmp = (cos(x) * ((-0.5 * pow(eps, 2.0)) + (0.041666666666666664 * pow(eps, 4.0)))) + (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps));
} else {
tmp = fma(sin(eps), -sin(x), (cos(x) * (-1.0 + cos(eps))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -0.00215) tmp = Float64(Float64(cos(eps) * cos(x)) - Float64(cos(x) + Float64(sin(eps) * sin(x)))); elseif (eps <= 0.0018) tmp = Float64(Float64(cos(x) * Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(0.041666666666666664 * (eps ^ 4.0)))) + Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); else tmp = fma(sin(eps), Float64(-sin(x)), Float64(cos(x) * Float64(-1.0 + cos(eps)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.00215], N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0018], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision]) + N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00215:\\
\;\;\;\;\cos \varepsilon \cdot \cos x - \left(\cos x + \sin \varepsilon \cdot \sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0018:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2} + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) + \sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, -\sin x, \cos x \cdot \left(-1 + \cos \varepsilon\right)\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (cos (+ eps x)) (cos x))))
(if (<= t_0 -0.0001)
t_0
(- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x))))))
double code(double x, double eps) {
double t_0 = cos((eps + x)) - cos(x);
double tmp;
if (t_0 <= -0.0001) {
tmp = t_0;
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = cos((eps + x)) - cos(x)
if (t_0 <= (-0.0001d0)) then
tmp = t_0
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos((eps + x)) - Math.cos(x);
double tmp;
if (t_0 <= -0.0001) {
tmp = t_0;
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): t_0 = math.cos((eps + x)) - math.cos(x) tmp = 0 if t_0 <= -0.0001: tmp = t_0 else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) return tmp
function code(x, eps) t_0 = Float64(cos(Float64(eps + x)) - cos(x)) tmp = 0.0 if (t_0 <= -0.0001) tmp = t_0; else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos((eps + x)) - cos(x); tmp = 0.0; if (t_0 <= -0.0001) tmp = t_0; else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.0001], t$95$0, N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\varepsilon + x\right) - \cos x\\
\mathbf{if}\;t_0 \leq -0.0001:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.00017) (not (<= eps 0.00017)))
(fma (sin eps) (- (sin x)) (* (cos x) (+ -1.0 (cos eps))))
(+
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps))
(* (cos x) (* -0.5 (pow eps 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.00017)) {
tmp = fma(sin(eps), -sin(x), (cos(x) * (-1.0 + cos(eps))));
} else {
tmp = (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps)) + (cos(x) * (-0.5 * pow(eps, 2.0)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.00017) || !(eps <= 0.00017)) tmp = fma(sin(eps), Float64(-sin(x)), Float64(cos(x) * Float64(-1.0 + cos(eps)))); else tmp = Float64(Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps)) + Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00017], N[Not[LessEqual[eps, 0.00017]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision]) + N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00017 \lor \neg \left(\varepsilon \leq 0.00017\right):\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, -\sin x, \cos x \cdot \left(-1 + \cos \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right) + \cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.00017) (not (<= eps 0.00017)))
(- (* (cos x) (+ -1.0 (cos eps))) (* (sin eps) (sin x)))
(+
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps))
(* (cos x) (* -0.5 (pow eps 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.00017)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x));
} else {
tmp = (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps)) + (cos(x) * (-0.5 * pow(eps, 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.00017d0)) .or. (.not. (eps <= 0.00017d0))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(eps) * sin(x))
else
tmp = (sin(x) * ((0.16666666666666666d0 * (eps ** 3.0d0)) - eps)) + (cos(x) * ((-0.5d0) * (eps ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.00017)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(eps) * Math.sin(x));
} else {
tmp = (Math.sin(x) * ((0.16666666666666666 * Math.pow(eps, 3.0)) - eps)) + (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00017) or not (eps <= 0.00017): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(eps) * math.sin(x)) else: tmp = (math.sin(x) * ((0.16666666666666666 * math.pow(eps, 3.0)) - eps)) + (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00017) || !(eps <= 0.00017)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(eps) * sin(x))); else tmp = Float64(Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps)) + Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00017) || ~((eps <= 0.00017))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x)); else tmp = (sin(x) * ((0.16666666666666666 * (eps ^ 3.0)) - eps)) + (cos(x) * (-0.5 * (eps ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00017], N[Not[LessEqual[eps, 0.00017]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00017 \lor \neg \left(\varepsilon \leq 0.00017\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right) + \cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right)\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -3e-5) (not (<= eps 2.9e-5))) (- (* (cos x) (+ -1.0 (cos eps))) (* (sin eps) (sin x))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3e-5) || !(eps <= 2.9e-5)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x));
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3d-5)) .or. (.not. (eps <= 2.9d-5))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(eps) * sin(x))
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3e-5) || !(eps <= 2.9e-5)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(eps) * Math.sin(x));
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3e-5) or not (eps <= 2.9e-5): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(eps) * math.sin(x)) else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3e-5) || !(eps <= 2.9e-5)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(eps) * sin(x))); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3e-5) || ~((eps <= 2.9e-5))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x)); else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3e-5], N[Not[LessEqual[eps, 2.9e-5]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 2.9 \cdot 10^{-5}\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (cos (+ eps x)) (cos x)))) (if (<= t_0 -1e-14) t_0 (* (sin x) (- eps)))))
double code(double x, double eps) {
double t_0 = cos((eps + x)) - cos(x);
double tmp;
if (t_0 <= -1e-14) {
tmp = t_0;
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = cos((eps + x)) - cos(x)
if (t_0 <= (-1d-14)) then
tmp = t_0
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos((eps + x)) - Math.cos(x);
double tmp;
if (t_0 <= -1e-14) {
tmp = t_0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): t_0 = math.cos((eps + x)) - math.cos(x) tmp = 0 if t_0 <= -1e-14: tmp = t_0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) t_0 = Float64(cos(Float64(eps + x)) - cos(x)) tmp = 0.0 if (t_0 <= -1e-14) tmp = t_0; else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos((eps + x)) - cos(x); tmp = 0.0; if (t_0 <= -1e-14) tmp = t_0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-14], t$95$0, N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\varepsilon + x\right) - \cos x\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-14}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (* (sin (* 0.5 (fma 2.0 x eps))) (* -2.0 (sin (* eps 0.5)))))
double code(double x, double eps) {
return sin((0.5 * fma(2.0, x, eps))) * (-2.0 * sin((eps * 0.5)));
}
function code(x, eps) return Float64(sin(Float64(0.5 * fma(2.0, x, eps))) * Float64(-2.0 * sin(Float64(eps * 0.5)))) end
code[x_, eps_] := N[(N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (+ -1.0 (cos eps)) (* (sin eps) x)))
(t_1 (* (sin x) (* -2.0 (sin (* eps 0.5))))))
(if (<= x -0.00275)
t_1
(if (<= x -2.7e-80)
t_0
(if (<= x 2.5e-141)
(*
-2.0
(* (sin (/ (- (+ eps x) x) 2.0)) (sin (/ (+ x (+ eps x)) 2.0))))
(if (<= x 0.000175) t_0 t_1))))))
double code(double x, double eps) {
double t_0 = (-1.0 + cos(eps)) - (sin(eps) * x);
double t_1 = sin(x) * (-2.0 * sin((eps * 0.5)));
double tmp;
if (x <= -0.00275) {
tmp = t_1;
} else if (x <= -2.7e-80) {
tmp = t_0;
} else if (x <= 2.5e-141) {
tmp = -2.0 * (sin((((eps + x) - x) / 2.0)) * sin(((x + (eps + x)) / 2.0)));
} else if (x <= 0.000175) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((-1.0d0) + cos(eps)) - (sin(eps) * x)
t_1 = sin(x) * ((-2.0d0) * sin((eps * 0.5d0)))
if (x <= (-0.00275d0)) then
tmp = t_1
else if (x <= (-2.7d-80)) then
tmp = t_0
else if (x <= 2.5d-141) then
tmp = (-2.0d0) * (sin((((eps + x) - x) / 2.0d0)) * sin(((x + (eps + x)) / 2.0d0)))
else if (x <= 0.000175d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (-1.0 + Math.cos(eps)) - (Math.sin(eps) * x);
double t_1 = Math.sin(x) * (-2.0 * Math.sin((eps * 0.5)));
double tmp;
if (x <= -0.00275) {
tmp = t_1;
} else if (x <= -2.7e-80) {
tmp = t_0;
} else if (x <= 2.5e-141) {
tmp = -2.0 * (Math.sin((((eps + x) - x) / 2.0)) * Math.sin(((x + (eps + x)) / 2.0)));
} else if (x <= 0.000175) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, eps): t_0 = (-1.0 + math.cos(eps)) - (math.sin(eps) * x) t_1 = math.sin(x) * (-2.0 * math.sin((eps * 0.5))) tmp = 0 if x <= -0.00275: tmp = t_1 elif x <= -2.7e-80: tmp = t_0 elif x <= 2.5e-141: tmp = -2.0 * (math.sin((((eps + x) - x) / 2.0)) * math.sin(((x + (eps + x)) / 2.0))) elif x <= 0.000175: tmp = t_0 else: tmp = t_1 return tmp
function code(x, eps) t_0 = Float64(Float64(-1.0 + cos(eps)) - Float64(sin(eps) * x)) t_1 = Float64(sin(x) * Float64(-2.0 * sin(Float64(eps * 0.5)))) tmp = 0.0 if (x <= -0.00275) tmp = t_1; elseif (x <= -2.7e-80) tmp = t_0; elseif (x <= 2.5e-141) tmp = Float64(-2.0 * Float64(sin(Float64(Float64(Float64(eps + x) - x) / 2.0)) * sin(Float64(Float64(x + Float64(eps + x)) / 2.0)))); elseif (x <= 0.000175) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, eps) t_0 = (-1.0 + cos(eps)) - (sin(eps) * x); t_1 = sin(x) * (-2.0 * sin((eps * 0.5))); tmp = 0.0; if (x <= -0.00275) tmp = t_1; elseif (x <= -2.7e-80) tmp = t_0; elseif (x <= 2.5e-141) tmp = -2.0 * (sin((((eps + x) - x) / 2.0)) * sin(((x + (eps + x)) / 2.0))); elseif (x <= 0.000175) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.00275], t$95$1, If[LessEqual[x, -2.7e-80], t$95$0, If[LessEqual[x, 2.5e-141], N[(-2.0 * N[(N[Sin[N[(N[(N[(eps + x), $MachinePrecision] - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000175], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot x\\
t_1 := \sin x \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{if}\;x \leq -0.00275:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-141}:\\
\;\;\;\;-2 \cdot \left(\sin \left(\frac{\left(\varepsilon + x\right) - x}{2}\right) \cdot \sin \left(\frac{x + \left(\varepsilon + x\right)}{2}\right)\right)\\
\mathbf{elif}\;x \leq 0.000175:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (+ -1.0 (cos eps)) (* (sin eps) x)))
(t_1 (sin (* eps 0.5)))
(t_2 (* (sin x) (* -2.0 t_1))))
(if (<= x -0.0062)
t_2
(if (<= x -6.2e-80)
t_0
(if (<= x 2.5e-141)
(* -2.0 (pow t_1 2.0))
(if (<= x 0.0033) t_0 t_2))))))
double code(double x, double eps) {
double t_0 = (-1.0 + cos(eps)) - (sin(eps) * x);
double t_1 = sin((eps * 0.5));
double t_2 = sin(x) * (-2.0 * t_1);
double tmp;
if (x <= -0.0062) {
tmp = t_2;
} else if (x <= -6.2e-80) {
tmp = t_0;
} else if (x <= 2.5e-141) {
tmp = -2.0 * pow(t_1, 2.0);
} else if (x <= 0.0033) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((-1.0d0) + cos(eps)) - (sin(eps) * x)
t_1 = sin((eps * 0.5d0))
t_2 = sin(x) * ((-2.0d0) * t_1)
if (x <= (-0.0062d0)) then
tmp = t_2
else if (x <= (-6.2d-80)) then
tmp = t_0
else if (x <= 2.5d-141) then
tmp = (-2.0d0) * (t_1 ** 2.0d0)
else if (x <= 0.0033d0) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (-1.0 + Math.cos(eps)) - (Math.sin(eps) * x);
double t_1 = Math.sin((eps * 0.5));
double t_2 = Math.sin(x) * (-2.0 * t_1);
double tmp;
if (x <= -0.0062) {
tmp = t_2;
} else if (x <= -6.2e-80) {
tmp = t_0;
} else if (x <= 2.5e-141) {
tmp = -2.0 * Math.pow(t_1, 2.0);
} else if (x <= 0.0033) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, eps): t_0 = (-1.0 + math.cos(eps)) - (math.sin(eps) * x) t_1 = math.sin((eps * 0.5)) t_2 = math.sin(x) * (-2.0 * t_1) tmp = 0 if x <= -0.0062: tmp = t_2 elif x <= -6.2e-80: tmp = t_0 elif x <= 2.5e-141: tmp = -2.0 * math.pow(t_1, 2.0) elif x <= 0.0033: tmp = t_0 else: tmp = t_2 return tmp
function code(x, eps) t_0 = Float64(Float64(-1.0 + cos(eps)) - Float64(sin(eps) * x)) t_1 = sin(Float64(eps * 0.5)) t_2 = Float64(sin(x) * Float64(-2.0 * t_1)) tmp = 0.0 if (x <= -0.0062) tmp = t_2; elseif (x <= -6.2e-80) tmp = t_0; elseif (x <= 2.5e-141) tmp = Float64(-2.0 * (t_1 ^ 2.0)); elseif (x <= 0.0033) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x, eps) t_0 = (-1.0 + cos(eps)) - (sin(eps) * x); t_1 = sin((eps * 0.5)); t_2 = sin(x) * (-2.0 * t_1); tmp = 0.0; if (x <= -0.0062) tmp = t_2; elseif (x <= -6.2e-80) tmp = t_0; elseif (x <= 2.5e-141) tmp = -2.0 * (t_1 ^ 2.0); elseif (x <= 0.0033) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.0062], t$95$2, If[LessEqual[x, -6.2e-80], t$95$0, If[LessEqual[x, 2.5e-141], N[(-2.0 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0033], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot x\\
t_1 := \sin \left(\varepsilon \cdot 0.5\right)\\
t_2 := \sin x \cdot \left(-2 \cdot t_1\right)\\
\mathbf{if}\;x \leq -0.0062:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-141}:\\
\;\;\;\;-2 \cdot {t_1}^{2}\\
\mathbf{elif}\;x \leq 0.0033:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -3.4e-26) (not (<= x 1.75e-5)))
(* (sin x) (* -2.0 t_0))
(* -2.0 (pow t_0 2.0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((x <= -3.4e-26) || !(x <= 1.75e-5)) {
tmp = sin(x) * (-2.0 * t_0);
} else {
tmp = -2.0 * pow(t_0, 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin((eps * 0.5d0))
if ((x <= (-3.4d-26)) .or. (.not. (x <= 1.75d-5))) then
tmp = sin(x) * ((-2.0d0) * t_0)
else
tmp = (-2.0d0) * (t_0 ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps * 0.5));
double tmp;
if ((x <= -3.4e-26) || !(x <= 1.75e-5)) {
tmp = Math.sin(x) * (-2.0 * t_0);
} else {
tmp = -2.0 * Math.pow(t_0, 2.0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (x <= -3.4e-26) or not (x <= 1.75e-5): tmp = math.sin(x) * (-2.0 * t_0) else: tmp = -2.0 * math.pow(t_0, 2.0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if ((x <= -3.4e-26) || !(x <= 1.75e-5)) tmp = Float64(sin(x) * Float64(-2.0 * t_0)); else tmp = Float64(-2.0 * (t_0 ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); tmp = 0.0; if ((x <= -3.4e-26) || ~((x <= 1.75e-5))) tmp = sin(x) * (-2.0 * t_0); else tmp = -2.0 * (t_0 ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x, -3.4e-26], N[Not[LessEqual[x, 1.75e-5]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{-26} \lor \neg \left(x \leq 1.75 \cdot 10^{-5}\right):\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= eps -0.00045)
(- (cos eps) (cos x))
(if (<= eps 1.3e-27)
(* (sin x) (- eps))
(* -2.0 (pow (sin (* eps 0.5)) 2.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00045) {
tmp = cos(eps) - cos(x);
} else if (eps <= 1.3e-27) {
tmp = sin(x) * -eps;
} else {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.00045d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 1.3d-27) then
tmp = sin(x) * -eps
else
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.00045) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 1.3e-27) {
tmp = Math.sin(x) * -eps;
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.00045: tmp = math.cos(eps) - math.cos(x) elif eps <= 1.3e-27: tmp = math.sin(x) * -eps else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.00045) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 1.3e-27) tmp = Float64(sin(x) * Float64(-eps)); else tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.00045) tmp = cos(eps) - cos(x); elseif (eps <= 1.3e-27) tmp = sin(x) * -eps; else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.00045], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.3e-27], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00045:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 1.3 \cdot 10^{-27}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= eps -0.00045) (- (cos eps) (cos x)) (if (<= eps 1.7e-7) (* (sin x) (- eps)) (+ -1.0 (cos eps)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00045) {
tmp = cos(eps) - cos(x);
} else if (eps <= 1.7e-7) {
tmp = sin(x) * -eps;
} else {
tmp = -1.0 + cos(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.00045d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 1.7d-7) then
tmp = sin(x) * -eps
else
tmp = (-1.0d0) + cos(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.00045) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 1.7e-7) {
tmp = Math.sin(x) * -eps;
} else {
tmp = -1.0 + Math.cos(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.00045: tmp = math.cos(eps) - math.cos(x) elif eps <= 1.7e-7: tmp = math.sin(x) * -eps else: tmp = -1.0 + math.cos(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.00045) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 1.7e-7) tmp = Float64(sin(x) * Float64(-eps)); else tmp = Float64(-1.0 + cos(eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.00045) tmp = cos(eps) - cos(x); elseif (eps <= 1.7e-7) tmp = sin(x) * -eps; else tmp = -1.0 + cos(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.00045], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.7e-7], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00045:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \cos \varepsilon\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))) (t_1 (* -0.5 (pow eps 2.0))))
(if (<= eps -4.6e-17)
t_0
(if (<= eps -2.1e-121)
t_1
(if (<= eps 7.2e-155) (* eps (- x)) (if (<= eps 0.00017) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double t_1 = -0.5 * pow(eps, 2.0);
double tmp;
if (eps <= -4.6e-17) {
tmp = t_0;
} else if (eps <= -2.1e-121) {
tmp = t_1;
} else if (eps <= 7.2e-155) {
tmp = eps * -x;
} else if (eps <= 0.00017) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-1.0d0) + cos(eps)
t_1 = (-0.5d0) * (eps ** 2.0d0)
if (eps <= (-4.6d-17)) then
tmp = t_0
else if (eps <= (-2.1d-121)) then
tmp = t_1
else if (eps <= 7.2d-155) then
tmp = eps * -x
else if (eps <= 0.00017d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = -1.0 + Math.cos(eps);
double t_1 = -0.5 * Math.pow(eps, 2.0);
double tmp;
if (eps <= -4.6e-17) {
tmp = t_0;
} else if (eps <= -2.1e-121) {
tmp = t_1;
} else if (eps <= 7.2e-155) {
tmp = eps * -x;
} else if (eps <= 0.00017) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) t_1 = -0.5 * math.pow(eps, 2.0) tmp = 0 if eps <= -4.6e-17: tmp = t_0 elif eps <= -2.1e-121: tmp = t_1 elif eps <= 7.2e-155: tmp = eps * -x elif eps <= 0.00017: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) t_1 = Float64(-0.5 * (eps ^ 2.0)) tmp = 0.0 if (eps <= -4.6e-17) tmp = t_0; elseif (eps <= -2.1e-121) tmp = t_1; elseif (eps <= 7.2e-155) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.00017) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = -1.0 + cos(eps); t_1 = -0.5 * (eps ^ 2.0); tmp = 0.0; if (eps <= -4.6e-17) tmp = t_0; elseif (eps <= -2.1e-121) tmp = t_1; elseif (eps <= 7.2e-155) tmp = eps * -x; elseif (eps <= 0.00017) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.6e-17], t$95$0, If[LessEqual[eps, -2.1e-121], t$95$1, If[LessEqual[eps, 7.2e-155], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00017], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
t_1 := -0.5 \cdot {\varepsilon}^{2}\\
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -2.1 \cdot 10^{-121}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 7.2 \cdot 10^{-155}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00017:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00045) (not (<= eps 1.7e-7))) (+ -1.0 (cos eps)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00045) || !(eps <= 1.7e-7)) {
tmp = -1.0 + cos(eps);
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.00045d0)) .or. (.not. (eps <= 1.7d-7))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00045) || !(eps <= 1.7e-7)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00045) or not (eps <= 1.7e-7): tmp = -1.0 + math.cos(eps) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00045) || !(eps <= 1.7e-7)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00045) || ~((eps <= 1.7e-7))) tmp = -1.0 + cos(eps); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00045], N[Not[LessEqual[eps, 1.7e-7]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00045 \lor \neg \left(\varepsilon \leq 1.7 \cdot 10^{-7}\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -1e-8) (not (<= eps 1.95e-87))) (+ -1.0 (cos eps)) (* eps (- x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1e-8) || !(eps <= 1.95e-87)) {
tmp = -1.0 + cos(eps);
} else {
tmp = eps * -x;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1d-8)) .or. (.not. (eps <= 1.95d-87))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = eps * -x
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1e-8) || !(eps <= 1.95e-87)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = eps * -x;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1e-8) or not (eps <= 1.95e-87): tmp = -1.0 + math.cos(eps) else: tmp = eps * -x return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1e-8) || !(eps <= 1.95e-87)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(eps * Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1e-8) || ~((eps <= 1.95e-87))) tmp = -1.0 + cos(eps); else tmp = eps * -x; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1e-8], N[Not[LessEqual[eps, 1.95e-87]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(eps * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 1.95 \cdot 10^{-87}\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (* eps (- x)))
double code(double x, double eps) {
return eps * -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * -x
end function
public static double code(double x, double eps) {
return eps * -x;
}
def code(x, eps): return eps * -x
function code(x, eps) return Float64(eps * Float64(-x)) end
function tmp = code(x, eps) tmp = eps * -x; end
code[x_, eps_] := N[(eps * (-x)), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(-x\right)
\end{array}
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
herbie shell --seed 2023343
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))