2cos (problem 3.3.5)

Percentage Accurate: 38.2% → 99.3%
Time: 16.4s
Alternatives: 16
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \cos \left(x + \varepsilon\right) - \cos x \end{array} \]
(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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 16 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 38.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos \left(x + \varepsilon\right) - \cos x \end{array} \]
(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}

Alternative 1: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.0038 \lor \neg \left(\varepsilon \leq 0.0045\right):\\ \;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\ \mathbf{else}:\\ \;\;\;\;\left(\sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right) + \cos x \cdot \left(\varepsilon \cdot 0.5 + -0.020833333333333332 \cdot {\varepsilon}^{3}\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -0.0038) (not (<= eps 0.0045)))
   (- (- (* (cos x) (cos eps)) (* (sin x) (sin eps))) (cos x))
   (*
    (+
     (* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0))
     (* (cos x) (+ (* eps 0.5) (* -0.020833333333333332 (pow eps 3.0)))))
    (* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.0038) || !(eps <= 0.0045)) {
		tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
	} else {
		tmp = ((sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0)) + (cos(x) * ((eps * 0.5) + (-0.020833333333333332 * pow(eps, 3.0))))) * (-2.0 * sin((eps * 0.5)));
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: tmp
    if ((eps <= (-0.0038d0)) .or. (.not. (eps <= 0.0045d0))) then
        tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x)
    else
        tmp = ((sin(x) * (((-0.125d0) * (eps ** 2.0d0)) + 1.0d0)) + (cos(x) * ((eps * 0.5d0) + ((-0.020833333333333332d0) * (eps ** 3.0d0))))) * ((-2.0d0) * sin((eps * 0.5d0)))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.0038) || !(eps <= 0.0045)) {
		tmp = ((Math.cos(x) * Math.cos(eps)) - (Math.sin(x) * Math.sin(eps))) - Math.cos(x);
	} else {
		tmp = ((Math.sin(x) * ((-0.125 * Math.pow(eps, 2.0)) + 1.0)) + (Math.cos(x) * ((eps * 0.5) + (-0.020833333333333332 * Math.pow(eps, 3.0))))) * (-2.0 * Math.sin((eps * 0.5)));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -0.0038) or not (eps <= 0.0045):
		tmp = ((math.cos(x) * math.cos(eps)) - (math.sin(x) * math.sin(eps))) - math.cos(x)
	else:
		tmp = ((math.sin(x) * ((-0.125 * math.pow(eps, 2.0)) + 1.0)) + (math.cos(x) * ((eps * 0.5) + (-0.020833333333333332 * math.pow(eps, 3.0))))) * (-2.0 * math.sin((eps * 0.5)))
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -0.0038) || !(eps <= 0.0045))
		tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - Float64(sin(x) * sin(eps))) - cos(x));
	else
		tmp = Float64(Float64(Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0)) + Float64(cos(x) * Float64(Float64(eps * 0.5) + Float64(-0.020833333333333332 * (eps ^ 3.0))))) * Float64(-2.0 * sin(Float64(eps * 0.5))));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -0.0038) || ~((eps <= 0.0045)))
		tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
	else
		tmp = ((sin(x) * ((-0.125 * (eps ^ 2.0)) + 1.0)) + (cos(x) * ((eps * 0.5) + (-0.020833333333333332 * (eps ^ 3.0))))) * (-2.0 * sin((eps * 0.5)));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0038], N[Not[LessEqual[eps, 0.0045]], $MachinePrecision]], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(N[(eps * 0.5), $MachinePrecision] + N[(-0.020833333333333332 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0038 \lor \neg \left(\varepsilon \leq 0.0045\right):\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\

\mathbf{else}:\\
\;\;\;\;\left(\sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right) + \cos x \cdot \left(\varepsilon \cdot 0.5 + -0.020833333333333332 \cdot {\varepsilon}^{3}\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.0032 \lor \neg \left(\varepsilon \leq 0.0033\right):\\ \;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot \left({\varepsilon}^{2} \cdot -0.5 + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) + \sin x \cdot \left({\varepsilon}^{3} \cdot 0.16666666666666666 - \varepsilon\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -0.0032) (not (<= eps 0.0033)))
   (- (- (* (cos x) (cos eps)) (* (sin x) (sin eps))) (cos x))
   (+
    (*
     (cos x)
     (+ (* (pow eps 2.0) -0.5) (* 0.041666666666666664 (pow eps 4.0))))
    (* (sin x) (- (* (pow eps 3.0) 0.16666666666666666) eps)))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.0032) || !(eps <= 0.0033)) {
		tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
	} else {
		tmp = (cos(x) * ((pow(eps, 2.0) * -0.5) + (0.041666666666666664 * pow(eps, 4.0)))) + (sin(x) * ((pow(eps, 3.0) * 0.16666666666666666) - 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.0032d0)) .or. (.not. (eps <= 0.0033d0))) then
        tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x)
    else
        tmp = (cos(x) * (((eps ** 2.0d0) * (-0.5d0)) + (0.041666666666666664d0 * (eps ** 4.0d0)))) + (sin(x) * (((eps ** 3.0d0) * 0.16666666666666666d0) - eps))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.0032) || !(eps <= 0.0033)) {
		tmp = ((Math.cos(x) * Math.cos(eps)) - (Math.sin(x) * Math.sin(eps))) - Math.cos(x);
	} else {
		tmp = (Math.cos(x) * ((Math.pow(eps, 2.0) * -0.5) + (0.041666666666666664 * Math.pow(eps, 4.0)))) + (Math.sin(x) * ((Math.pow(eps, 3.0) * 0.16666666666666666) - eps));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -0.0032) or not (eps <= 0.0033):
		tmp = ((math.cos(x) * math.cos(eps)) - (math.sin(x) * math.sin(eps))) - math.cos(x)
	else:
		tmp = (math.cos(x) * ((math.pow(eps, 2.0) * -0.5) + (0.041666666666666664 * math.pow(eps, 4.0)))) + (math.sin(x) * ((math.pow(eps, 3.0) * 0.16666666666666666) - eps))
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -0.0032) || !(eps <= 0.0033))
		tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - Float64(sin(x) * sin(eps))) - cos(x));
	else
		tmp = Float64(Float64(cos(x) * Float64(Float64((eps ^ 2.0) * -0.5) + Float64(0.041666666666666664 * (eps ^ 4.0)))) + Float64(sin(x) * Float64(Float64((eps ^ 3.0) * 0.16666666666666666) - eps)));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -0.0032) || ~((eps <= 0.0033)))
		tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
	else
		tmp = (cos(x) * (((eps ^ 2.0) * -0.5) + (0.041666666666666664 * (eps ^ 4.0)))) + (sin(x) * (((eps ^ 3.0) * 0.16666666666666666) - eps));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0032], N[Not[LessEqual[eps, 0.0033]], $MachinePrecision]], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(N[Power[eps, 2.0], $MachinePrecision] * -0.5), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(N[Power[eps, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0032 \lor \neg \left(\varepsilon \leq 0.0033\right):\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\

\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left({\varepsilon}^{2} \cdot -0.5 + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) + \sin x \cdot \left({\varepsilon}^{3} \cdot 0.16666666666666666 - \varepsilon\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 75.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -4 \cdot 10^{-5}:\\ \;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\cos x \cdot \left({\varepsilon}^{2} \cdot -0.5\right) - \varepsilon \cdot \sin x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= (- (cos (+ eps x)) (cos x)) -4e-5)
   (* -2.0 (pow (sin (* eps 0.5)) 2.0))
   (- (* (cos x) (* (pow eps 2.0) -0.5)) (* eps (sin x)))))
double code(double x, double eps) {
	double tmp;
	if ((cos((eps + x)) - cos(x)) <= -4e-5) {
		tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
	} else {
		tmp = (cos(x) * (pow(eps, 2.0) * -0.5)) - (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 ((cos((eps + x)) - cos(x)) <= (-4d-5)) then
        tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
    else
        tmp = (cos(x) * ((eps ** 2.0d0) * (-0.5d0))) - (eps * sin(x))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((Math.cos((eps + x)) - Math.cos(x)) <= -4e-5) {
		tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
	} else {
		tmp = (Math.cos(x) * (Math.pow(eps, 2.0) * -0.5)) - (eps * Math.sin(x));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (math.cos((eps + x)) - math.cos(x)) <= -4e-5:
		tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0)
	else:
		tmp = (math.cos(x) * (math.pow(eps, 2.0) * -0.5)) - (eps * math.sin(x))
	return tmp
function code(x, eps)
	tmp = 0.0
	if (Float64(cos(Float64(eps + x)) - cos(x)) <= -4e-5)
		tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0));
	else
		tmp = Float64(Float64(cos(x) * Float64((eps ^ 2.0) * -0.5)) - Float64(eps * sin(x)));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((cos((eps + x)) - cos(x)) <= -4e-5)
		tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0);
	else
		tmp = (cos(x) * ((eps ^ 2.0) * -0.5)) - (eps * sin(x));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -4e-5], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Power[eps, 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -4 \cdot 10^{-5}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left({\varepsilon}^{2} \cdot -0.5\right) - \varepsilon \cdot \sin x\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.00017 \lor \neg \left(\varepsilon \leq 0.00021\right):\\ \;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(\sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right) + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -0.00017) (not (<= eps 0.00021)))
   (- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps))))
   (*
    (* -2.0 (sin (* eps 0.5)))
    (+ (* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0)) (* (cos x) (* eps 0.5))))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.00017) || !(eps <= 0.00021)) {
		tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
	} else {
		tmp = (-2.0 * sin((eps * 0.5))) * ((sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0)) + (cos(x) * (eps * 0.5)));
	}
	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.00021d0))) then
        tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
    else
        tmp = ((-2.0d0) * sin((eps * 0.5d0))) * ((sin(x) * (((-0.125d0) * (eps ** 2.0d0)) + 1.0d0)) + (cos(x) * (eps * 0.5d0)))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.00017) || !(eps <= 0.00021)) {
		tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
	} else {
		tmp = (-2.0 * Math.sin((eps * 0.5))) * ((Math.sin(x) * ((-0.125 * Math.pow(eps, 2.0)) + 1.0)) + (Math.cos(x) * (eps * 0.5)));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -0.00017) or not (eps <= 0.00021):
		tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps)))
	else:
		tmp = (-2.0 * math.sin((eps * 0.5))) * ((math.sin(x) * ((-0.125 * math.pow(eps, 2.0)) + 1.0)) + (math.cos(x) * (eps * 0.5)))
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -0.00017) || !(eps <= 0.00021))
		tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps))));
	else
		tmp = Float64(Float64(-2.0 * sin(Float64(eps * 0.5))) * Float64(Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0)) + Float64(cos(x) * Float64(eps * 0.5))));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -0.00017) || ~((eps <= 0.00021)))
		tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
	else
		tmp = (-2.0 * sin((eps * 0.5))) * ((sin(x) * ((-0.125 * (eps ^ 2.0)) + 1.0)) + (cos(x) * (eps * 0.5)));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00017], N[Not[LessEqual[eps, 0.00021]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00017 \lor \neg \left(\varepsilon \leq 0.00021\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\

\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(\sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right) + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.00019 \lor \neg \left(\varepsilon \leq 0.00018\right):\\ \;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(\sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right) + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -0.00019) (not (<= eps 0.00018)))
   (- (- (* (cos x) (cos eps)) (* (sin x) (sin eps))) (cos x))
   (*
    (* -2.0 (sin (* eps 0.5)))
    (+ (* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0)) (* (cos x) (* eps 0.5))))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.00019) || !(eps <= 0.00018)) {
		tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
	} else {
		tmp = (-2.0 * sin((eps * 0.5))) * ((sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0)) + (cos(x) * (eps * 0.5)));
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: tmp
    if ((eps <= (-0.00019d0)) .or. (.not. (eps <= 0.00018d0))) then
        tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x)
    else
        tmp = ((-2.0d0) * sin((eps * 0.5d0))) * ((sin(x) * (((-0.125d0) * (eps ** 2.0d0)) + 1.0d0)) + (cos(x) * (eps * 0.5d0)))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.00019) || !(eps <= 0.00018)) {
		tmp = ((Math.cos(x) * Math.cos(eps)) - (Math.sin(x) * Math.sin(eps))) - Math.cos(x);
	} else {
		tmp = (-2.0 * Math.sin((eps * 0.5))) * ((Math.sin(x) * ((-0.125 * Math.pow(eps, 2.0)) + 1.0)) + (Math.cos(x) * (eps * 0.5)));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -0.00019) or not (eps <= 0.00018):
		tmp = ((math.cos(x) * math.cos(eps)) - (math.sin(x) * math.sin(eps))) - math.cos(x)
	else:
		tmp = (-2.0 * math.sin((eps * 0.5))) * ((math.sin(x) * ((-0.125 * math.pow(eps, 2.0)) + 1.0)) + (math.cos(x) * (eps * 0.5)))
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -0.00019) || !(eps <= 0.00018))
		tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - Float64(sin(x) * sin(eps))) - cos(x));
	else
		tmp = Float64(Float64(-2.0 * sin(Float64(eps * 0.5))) * Float64(Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0)) + Float64(cos(x) * Float64(eps * 0.5))));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -0.00019) || ~((eps <= 0.00018)))
		tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
	else
		tmp = (-2.0 * sin((eps * 0.5))) * ((sin(x) * ((-0.125 * (eps ^ 2.0)) + 1.0)) + (cos(x) * (eps * 0.5)));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00019], N[Not[LessEqual[eps, 0.00018]], $MachinePrecision]], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00019 \lor \neg \left(\varepsilon \leq 0.00018\right):\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\

\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(\sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right) + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 66.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\varepsilon + x\right) - \cos x\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (cos (+ eps x)) (cos x))))
   (if (<= t_0 -2e-7) t_0 (* eps (- (sin x))))))
double code(double x, double eps) {
	double t_0 = cos((eps + x)) - cos(x);
	double tmp;
	if (t_0 <= -2e-7) {
		tmp = t_0;
	} else {
		tmp = 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 <= (-2d-7)) then
        tmp = t_0
    else
        tmp = 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 <= -2e-7) {
		tmp = t_0;
	} else {
		tmp = eps * -Math.sin(x);
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.cos((eps + x)) - math.cos(x)
	tmp = 0
	if t_0 <= -2e-7:
		tmp = t_0
	else:
		tmp = 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 <= -2e-7)
		tmp = t_0;
	else
		tmp = Float64(eps * Float64(-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 <= -2e-7)
		tmp = t_0;
	else
		tmp = 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, -2e-7], t$95$0, N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\varepsilon + x\right) - \cos x\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{-7}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 77.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \end{array} \]
(FPCore (x eps)
 :precision binary64
 (* (* -2.0 (sin (* eps 0.5))) (sin (* 0.5 (fma 2.0 x eps)))))
double code(double x, double eps) {
	return (-2.0 * sin((eps * 0.5))) * sin((0.5 * fma(2.0, x, eps)));
}
function code(x, eps)
	return Float64(Float64(-2.0 * sin(Float64(eps * 0.5))) * sin(Float64(0.5 * fma(2.0, x, eps))))
end
code[x_, eps_] := N[(N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 70.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin x \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{-94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-150}:\\ \;\;\;\;\left(-2 \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon - x\right)\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-14}:\\ \;\;\;\;\left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* (sin x) (* -2.0 (sin (* eps 0.5))))))
   (if (<= x -3.3e-94)
     t_0
     (if (<= x 1.5e-150)
       (* (* -2.0 (sin (* 0.5 (+ x (- eps x))))) (sin (* 0.5 (+ eps (+ x x)))))
       (if (<= x 1.2e-14) (- (+ (cos eps) -1.0) (* x (sin eps))) t_0)))))
double code(double x, double eps) {
	double t_0 = sin(x) * (-2.0 * sin((eps * 0.5)));
	double tmp;
	if (x <= -3.3e-94) {
		tmp = t_0;
	} else if (x <= 1.5e-150) {
		tmp = (-2.0 * sin((0.5 * (x + (eps - x))))) * sin((0.5 * (eps + (x + x))));
	} else if (x <= 1.2e-14) {
		tmp = (cos(eps) + -1.0) - (x * sin(eps));
	} 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) :: tmp
    t_0 = sin(x) * ((-2.0d0) * sin((eps * 0.5d0)))
    if (x <= (-3.3d-94)) then
        tmp = t_0
    else if (x <= 1.5d-150) then
        tmp = ((-2.0d0) * sin((0.5d0 * (x + (eps - x))))) * sin((0.5d0 * (eps + (x + x))))
    else if (x <= 1.2d-14) then
        tmp = (cos(eps) + (-1.0d0)) - (x * sin(eps))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.sin(x) * (-2.0 * Math.sin((eps * 0.5)));
	double tmp;
	if (x <= -3.3e-94) {
		tmp = t_0;
	} else if (x <= 1.5e-150) {
		tmp = (-2.0 * Math.sin((0.5 * (x + (eps - x))))) * Math.sin((0.5 * (eps + (x + x))));
	} else if (x <= 1.2e-14) {
		tmp = (Math.cos(eps) + -1.0) - (x * Math.sin(eps));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.sin(x) * (-2.0 * math.sin((eps * 0.5)))
	tmp = 0
	if x <= -3.3e-94:
		tmp = t_0
	elif x <= 1.5e-150:
		tmp = (-2.0 * math.sin((0.5 * (x + (eps - x))))) * math.sin((0.5 * (eps + (x + x))))
	elif x <= 1.2e-14:
		tmp = (math.cos(eps) + -1.0) - (x * math.sin(eps))
	else:
		tmp = t_0
	return tmp
function code(x, eps)
	t_0 = Float64(sin(x) * Float64(-2.0 * sin(Float64(eps * 0.5))))
	tmp = 0.0
	if (x <= -3.3e-94)
		tmp = t_0;
	elseif (x <= 1.5e-150)
		tmp = Float64(Float64(-2.0 * sin(Float64(0.5 * Float64(x + Float64(eps - x))))) * sin(Float64(0.5 * Float64(eps + Float64(x + x)))));
	elseif (x <= 1.2e-14)
		tmp = Float64(Float64(cos(eps) + -1.0) - Float64(x * sin(eps)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = sin(x) * (-2.0 * sin((eps * 0.5)));
	tmp = 0.0;
	if (x <= -3.3e-94)
		tmp = t_0;
	elseif (x <= 1.5e-150)
		tmp = (-2.0 * sin((0.5 * (x + (eps - x))))) * sin((0.5 * (eps + (x + x))));
	elseif (x <= 1.2e-14)
		tmp = (cos(eps) + -1.0) - (x * sin(eps));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.3e-94], t$95$0, If[LessEqual[x, 1.5e-150], N[(N[(-2.0 * N[Sin[N[(0.5 * N[(x + N[(eps - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e-14], N[(N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin x \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{if}\;x \leq -3.3 \cdot 10^{-94}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-150}:\\
\;\;\;\;\left(-2 \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon - x\right)\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-14}:\\
\;\;\;\;\left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 70.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\ t_1 := \sin x \cdot \left(-2 \cdot t_0\right)\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-150}:\\ \;\;\;\;-2 \cdot {t_0}^{2}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-14}:\\ \;\;\;\;\left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (sin (* eps 0.5))) (t_1 (* (sin x) (* -2.0 t_0))))
   (if (<= x -3.3e-94)
     t_1
     (if (<= x 1.5e-150)
       (* -2.0 (pow t_0 2.0))
       (if (<= x 1.2e-14) (- (+ (cos eps) -1.0) (* x (sin eps))) t_1)))))
double code(double x, double eps) {
	double t_0 = sin((eps * 0.5));
	double t_1 = sin(x) * (-2.0 * t_0);
	double tmp;
	if (x <= -3.3e-94) {
		tmp = t_1;
	} else if (x <= 1.5e-150) {
		tmp = -2.0 * pow(t_0, 2.0);
	} else if (x <= 1.2e-14) {
		tmp = (cos(eps) + -1.0) - (x * sin(eps));
	} 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 = sin((eps * 0.5d0))
    t_1 = sin(x) * ((-2.0d0) * t_0)
    if (x <= (-3.3d-94)) then
        tmp = t_1
    else if (x <= 1.5d-150) then
        tmp = (-2.0d0) * (t_0 ** 2.0d0)
    else if (x <= 1.2d-14) then
        tmp = (cos(eps) + (-1.0d0)) - (x * sin(eps))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.sin((eps * 0.5));
	double t_1 = Math.sin(x) * (-2.0 * t_0);
	double tmp;
	if (x <= -3.3e-94) {
		tmp = t_1;
	} else if (x <= 1.5e-150) {
		tmp = -2.0 * Math.pow(t_0, 2.0);
	} else if (x <= 1.2e-14) {
		tmp = (Math.cos(eps) + -1.0) - (x * Math.sin(eps));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.sin((eps * 0.5))
	t_1 = math.sin(x) * (-2.0 * t_0)
	tmp = 0
	if x <= -3.3e-94:
		tmp = t_1
	elif x <= 1.5e-150:
		tmp = -2.0 * math.pow(t_0, 2.0)
	elif x <= 1.2e-14:
		tmp = (math.cos(eps) + -1.0) - (x * math.sin(eps))
	else:
		tmp = t_1
	return tmp
function code(x, eps)
	t_0 = sin(Float64(eps * 0.5))
	t_1 = Float64(sin(x) * Float64(-2.0 * t_0))
	tmp = 0.0
	if (x <= -3.3e-94)
		tmp = t_1;
	elseif (x <= 1.5e-150)
		tmp = Float64(-2.0 * (t_0 ^ 2.0));
	elseif (x <= 1.2e-14)
		tmp = Float64(Float64(cos(eps) + -1.0) - Float64(x * sin(eps)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = sin((eps * 0.5));
	t_1 = sin(x) * (-2.0 * t_0);
	tmp = 0.0;
	if (x <= -3.3e-94)
		tmp = t_1;
	elseif (x <= 1.5e-150)
		tmp = -2.0 * (t_0 ^ 2.0);
	elseif (x <= 1.2e-14)
		tmp = (cos(eps) + -1.0) - (x * sin(eps));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.3e-94], t$95$1, If[LessEqual[x, 1.5e-150], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e-14], N[(N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
t_1 := \sin x \cdot \left(-2 \cdot t_0\right)\\
\mathbf{if}\;x \leq -3.3 \cdot 10^{-94}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-150}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-14}:\\
\;\;\;\;\left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 70.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\ t_1 := -2 \cdot t_0\\ t_2 := \sin x \cdot t_1\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{-94}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-150}:\\ \;\;\;\;t_1 \cdot t_0\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-14}:\\ \;\;\;\;\left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (sin (* eps 0.5))) (t_1 (* -2.0 t_0)) (t_2 (* (sin x) t_1)))
   (if (<= x -3.3e-94)
     t_2
     (if (<= x 1.5e-150)
       (* t_1 t_0)
       (if (<= x 1.2e-14) (- (+ (cos eps) -1.0) (* x (sin eps))) t_2)))))
double code(double x, double eps) {
	double t_0 = sin((eps * 0.5));
	double t_1 = -2.0 * t_0;
	double t_2 = sin(x) * t_1;
	double tmp;
	if (x <= -3.3e-94) {
		tmp = t_2;
	} else if (x <= 1.5e-150) {
		tmp = t_1 * t_0;
	} else if (x <= 1.2e-14) {
		tmp = (cos(eps) + -1.0) - (x * sin(eps));
	} 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 = sin((eps * 0.5d0))
    t_1 = (-2.0d0) * t_0
    t_2 = sin(x) * t_1
    if (x <= (-3.3d-94)) then
        tmp = t_2
    else if (x <= 1.5d-150) then
        tmp = t_1 * t_0
    else if (x <= 1.2d-14) then
        tmp = (cos(eps) + (-1.0d0)) - (x * sin(eps))
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.sin((eps * 0.5));
	double t_1 = -2.0 * t_0;
	double t_2 = Math.sin(x) * t_1;
	double tmp;
	if (x <= -3.3e-94) {
		tmp = t_2;
	} else if (x <= 1.5e-150) {
		tmp = t_1 * t_0;
	} else if (x <= 1.2e-14) {
		tmp = (Math.cos(eps) + -1.0) - (x * Math.sin(eps));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.sin((eps * 0.5))
	t_1 = -2.0 * t_0
	t_2 = math.sin(x) * t_1
	tmp = 0
	if x <= -3.3e-94:
		tmp = t_2
	elif x <= 1.5e-150:
		tmp = t_1 * t_0
	elif x <= 1.2e-14:
		tmp = (math.cos(eps) + -1.0) - (x * math.sin(eps))
	else:
		tmp = t_2
	return tmp
function code(x, eps)
	t_0 = sin(Float64(eps * 0.5))
	t_1 = Float64(-2.0 * t_0)
	t_2 = Float64(sin(x) * t_1)
	tmp = 0.0
	if (x <= -3.3e-94)
		tmp = t_2;
	elseif (x <= 1.5e-150)
		tmp = Float64(t_1 * t_0);
	elseif (x <= 1.2e-14)
		tmp = Float64(Float64(cos(eps) + -1.0) - Float64(x * sin(eps)));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = sin((eps * 0.5));
	t_1 = -2.0 * t_0;
	t_2 = sin(x) * t_1;
	tmp = 0.0;
	if (x <= -3.3e-94)
		tmp = t_2;
	elseif (x <= 1.5e-150)
		tmp = t_1 * t_0;
	elseif (x <= 1.2e-14)
		tmp = (cos(eps) + -1.0) - (x * sin(eps));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-2.0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[x], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[x, -3.3e-94], t$95$2, If[LessEqual[x, 1.5e-150], N[(t$95$1 * t$95$0), $MachinePrecision], If[LessEqual[x, 1.2e-14], N[(N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
t_1 := -2 \cdot t_0\\
t_2 := \sin x \cdot t_1\\
\mathbf{if}\;x \leq -3.3 \cdot 10^{-94}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-150}:\\
\;\;\;\;t_1 \cdot t_0\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-14}:\\
\;\;\;\;\left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 69.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{-94} \lor \neg \left(x \leq 6.5 \cdot 10^{-40}\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
 (let* ((t_0 (sin (* eps 0.5))))
   (if (or (<= x -3.3e-94) (not (<= x 6.5e-40)))
     (* (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.3e-94) || !(x <= 6.5e-40)) {
		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.3d-94)) .or. (.not. (x <= 6.5d-40))) 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.3e-94) || !(x <= 6.5e-40)) {
		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.3e-94) or not (x <= 6.5e-40):
		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.3e-94) || !(x <= 6.5e-40))
		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.3e-94) || ~((x <= 6.5e-40)))
		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.3e-94], N[Not[LessEqual[x, 6.5e-40]], $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.3 \cdot 10^{-94} \lor \neg \left(x \leq 6.5 \cdot 10^{-40}\right):\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 12: 67.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.3 \cdot 10^{-94} \lor \neg \left(x \leq 2.4 \cdot 10^{-40}\right):\\ \;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= x -3.3e-94) (not (<= x 2.4e-40)))
   (* eps (- (sin x)))
   (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
	double tmp;
	if ((x <= -3.3e-94) || !(x <= 2.4e-40)) {
		tmp = eps * -sin(x);
	} 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 ((x <= (-3.3d-94)) .or. (.not. (x <= 2.4d-40))) then
        tmp = eps * -sin(x)
    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 ((x <= -3.3e-94) || !(x <= 2.4e-40)) {
		tmp = eps * -Math.sin(x);
	} else {
		tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (x <= -3.3e-94) or not (x <= 2.4e-40):
		tmp = eps * -math.sin(x)
	else:
		tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((x <= -3.3e-94) || !(x <= 2.4e-40))
		tmp = Float64(eps * Float64(-sin(x)));
	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 ((x <= -3.3e-94) || ~((x <= 2.4e-40)))
		tmp = eps * -sin(x);
	else
		tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[x, -3.3e-94], N[Not[LessEqual[x, 2.4e-40]], $MachinePrecision]], N[(eps * (-N[Sin[x], $MachinePrecision])), $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}\;x \leq -3.3 \cdot 10^{-94} \lor \neg \left(x \leq 2.4 \cdot 10^{-40}\right):\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 13: 68.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.78 \lor \neg \left(\varepsilon \leq 0.000235\right):\\ \;\;\;\;\cos \varepsilon - \cos x\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -0.78) (not (<= eps 0.000235)))
   (- (cos eps) (cos x))
   (* eps (- (sin x)))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.78) || !(eps <= 0.000235)) {
		tmp = cos(eps) - cos(x);
	} else {
		tmp = 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 <= (-0.78d0)) .or. (.not. (eps <= 0.000235d0))) then
        tmp = cos(eps) - cos(x)
    else
        tmp = eps * -sin(x)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.78) || !(eps <= 0.000235)) {
		tmp = Math.cos(eps) - Math.cos(x);
	} else {
		tmp = eps * -Math.sin(x);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -0.78) or not (eps <= 0.000235):
		tmp = math.cos(eps) - math.cos(x)
	else:
		tmp = eps * -math.sin(x)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -0.78) || !(eps <= 0.000235))
		tmp = Float64(cos(eps) - cos(x));
	else
		tmp = Float64(eps * Float64(-sin(x)));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -0.78) || ~((eps <= 0.000235)))
		tmp = cos(eps) - cos(x);
	else
		tmp = eps * -sin(x);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -0.78], N[Not[LessEqual[eps, 0.000235]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.78 \lor \neg \left(\varepsilon \leq 0.000235\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\

\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 14: 67.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.78 \lor \neg \left(\varepsilon \leq 0.000235\right):\\ \;\;\;\;\cos \varepsilon + -1\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -0.78) (not (<= eps 0.000235)))
   (+ (cos eps) -1.0)
   (* eps (- (sin x)))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.78) || !(eps <= 0.000235)) {
		tmp = cos(eps) + -1.0;
	} else {
		tmp = 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 <= (-0.78d0)) .or. (.not. (eps <= 0.000235d0))) then
        tmp = cos(eps) + (-1.0d0)
    else
        tmp = eps * -sin(x)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -0.78) || !(eps <= 0.000235)) {
		tmp = Math.cos(eps) + -1.0;
	} else {
		tmp = eps * -Math.sin(x);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -0.78) or not (eps <= 0.000235):
		tmp = math.cos(eps) + -1.0
	else:
		tmp = eps * -math.sin(x)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -0.78) || !(eps <= 0.000235))
		tmp = Float64(cos(eps) + -1.0);
	else
		tmp = Float64(eps * Float64(-sin(x)));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -0.78) || ~((eps <= 0.000235)))
		tmp = cos(eps) + -1.0;
	else
		tmp = eps * -sin(x);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -0.78], N[Not[LessEqual[eps, 0.000235]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.78 \lor \neg \left(\varepsilon \leq 0.000235\right):\\
\;\;\;\;\cos \varepsilon + -1\\

\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 15: 46.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -7.8 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 4.3 \cdot 10^{-7}\right):\\ \;\;\;\;\cos \varepsilon + -1\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= eps -7.8e-7) (not (<= eps 4.3e-7)))
   (+ (cos eps) -1.0)
   (* -0.5 (* eps eps))))
double code(double x, double eps) {
	double tmp;
	if ((eps <= -7.8e-7) || !(eps <= 4.3e-7)) {
		tmp = cos(eps) + -1.0;
	} else {
		tmp = -0.5 * (eps * eps);
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: tmp
    if ((eps <= (-7.8d-7)) .or. (.not. (eps <= 4.3d-7))) then
        tmp = cos(eps) + (-1.0d0)
    else
        tmp = (-0.5d0) * (eps * eps)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((eps <= -7.8e-7) || !(eps <= 4.3e-7)) {
		tmp = Math.cos(eps) + -1.0;
	} else {
		tmp = -0.5 * (eps * eps);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (eps <= -7.8e-7) or not (eps <= 4.3e-7):
		tmp = math.cos(eps) + -1.0
	else:
		tmp = -0.5 * (eps * eps)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((eps <= -7.8e-7) || !(eps <= 4.3e-7))
		tmp = Float64(cos(eps) + -1.0);
	else
		tmp = Float64(-0.5 * Float64(eps * eps));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((eps <= -7.8e-7) || ~((eps <= 4.3e-7)))
		tmp = cos(eps) + -1.0;
	else
		tmp = -0.5 * (eps * eps);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[eps, -7.8e-7], N[Not[LessEqual[eps, 4.3e-7]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7.8 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 4.3 \cdot 10^{-7}\right):\\
\;\;\;\;\cos \varepsilon + -1\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 16: 21.5% accurate, 41.0× speedup?

\[\begin{array}{l} \\ -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right) \end{array} \]
(FPCore (x eps) :precision binary64 (* -0.5 (* eps eps)))
double code(double x, double eps) {
	return -0.5 * (eps * eps);
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = (-0.5d0) * (eps * eps)
end function
public static double code(double x, double eps) {
	return -0.5 * (eps * eps);
}
def code(x, eps):
	return -0.5 * (eps * eps)
function code(x, eps)
	return Float64(-0.5 * Float64(eps * eps))
end
function tmp = code(x, eps)
	tmp = -0.5 * (eps * eps);
end
code[x_, eps_] := N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Reproduce

?
herbie shell --seed 2023347 
(FPCore (x eps)
  :name "2cos (problem 3.3.5)"
  :precision binary64
  (- (cos (+ x eps)) (cos x)))