\[\cos \left(x + \varepsilon\right) - \cos x
\]
↓
\[\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
\left(t_0 \cdot \left(t_0 \cdot \cos x + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin x\right)\right) \cdot -2
\end{array}
\]
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
↓
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* 0.5 eps))))
(* (* t_0 (+ (* t_0 (cos x)) (* (cos (* 0.5 eps)) (sin x)))) -2.0)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
↓
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return (t_0 * ((t_0 * cos(x)) + (cos((0.5 * eps)) * sin(x)))) * -2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
↓
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = sin((0.5d0 * eps))
code = (t_0 * ((t_0 * cos(x)) + (cos((0.5d0 * eps)) * sin(x)))) * (-2.0d0)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
↓
public static double code(double x, double eps) {
double t_0 = Math.sin((0.5 * eps));
return (t_0 * ((t_0 * Math.cos(x)) + (Math.cos((0.5 * eps)) * Math.sin(x)))) * -2.0;
}
def code(x, eps):
return math.cos((x + eps)) - math.cos(x)
↓
def code(x, eps):
t_0 = math.sin((0.5 * eps))
return (t_0 * ((t_0 * math.cos(x)) + (math.cos((0.5 * eps)) * math.sin(x)))) * -2.0
function code(x, eps)
return Float64(cos(Float64(x + eps)) - cos(x))
end
↓
function code(x, eps)
t_0 = sin(Float64(0.5 * eps))
return Float64(Float64(t_0 * Float64(Float64(t_0 * cos(x)) + Float64(cos(Float64(0.5 * eps)) * sin(x)))) * -2.0)
end
function tmp = code(x, eps)
tmp = cos((x + eps)) - cos(x);
end
↓
function tmp = code(x, eps)
t_0 = sin((0.5 * eps));
tmp = (t_0 * ((t_0 * cos(x)) + (cos((0.5 * eps)) * sin(x)))) * -2.0;
end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
↓
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, N[(N[(t$95$0 * N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]]
\cos \left(x + \varepsilon\right) - \cos x
↓
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
\left(t_0 \cdot \left(t_0 \cdot \cos x + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin x\right)\right) \cdot -2
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.8 |
|---|
| Cost | 32840 |
|---|
\[\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{if}\;\varepsilon \leq -0.0019391995777601862:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 0.002847402336945821:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.8 |
|---|
| Cost | 32840 |
|---|
\[\begin{array}{l}
t_0 := \left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{if}\;\varepsilon \leq -0.0019391995777601862:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 0.002847402336945821:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 14.9 |
|---|
| Cost | 13640 |
|---|
\[\begin{array}{l}
t_0 := \cos \varepsilon - \cos x\\
\mathbf{if}\;\varepsilon \leq -0.9303548950018607:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.1268120518731243 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot \left(\cos x \cdot -0.5\right) - \sin x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 15.1 |
|---|
| Cost | 13632 |
|---|
\[-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + x \cdot 2\right)\right)\right)
\]
| Alternative 5 |
|---|
| Error | 18.8 |
|---|
| Cost | 13512 |
|---|
\[\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
t_1 := -2 \cdot \left(t_0 \cdot \sin x\right)\\
\mathbf{if}\;x \leq -4.2274067724269265 \cdot 10^{-28}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.6799745731378967 \cdot 10^{-23}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 21.6 |
|---|
| Cost | 13448 |
|---|
\[\begin{array}{l}
t_0 := -2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\mathbf{if}\;\varepsilon \leq -1.1063543140823851 \cdot 10^{-53}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3.904703325838417 \cdot 10^{-111}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 20.7 |
|---|
| Cost | 13388 |
|---|
\[\begin{array}{l}
t_0 := \cos \varepsilon - \cos x\\
\mathbf{if}\;\varepsilon \leq -0.001140205663377386:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3.904703325838417 \cdot 10^{-111}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.1268120518731243 \cdot 10^{-6}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2} - \varepsilon \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 21.1 |
|---|
| Cost | 7308 |
|---|
\[\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -0.001140205663377386:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3.904703325838417 \cdot 10^{-111}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.1268120518731243 \cdot 10^{-6}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2} - \varepsilon \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 21.1 |
|---|
| Cost | 7180 |
|---|
\[\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -0.001140205663377386:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3.904703325838417 \cdot 10^{-111}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.1268120518731243 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon \cdot \mathsf{fma}\left(-0.5, \varepsilon, -x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 21.6 |
|---|
| Cost | 6988 |
|---|
\[\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -0.001140205663377386:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3.904703325838417 \cdot 10^{-111}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.1268120518731243 \cdot 10^{-6}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 33.3 |
|---|
| Cost | 6856 |
|---|
\[\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -0.001140205663377386:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.1268120518731243 \cdot 10^{-6}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 56.1 |
|---|
| Cost | 320 |
|---|
\[0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)
\]
| Alternative 13 |
|---|
| Error | 50.3 |
|---|
| Cost | 320 |
|---|
\[-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)
\]