2cos (problem 3.3.5)

Percentage Accurate: 38.1% → 99.4%
Time: 17.4s
Alternatives: 13
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 13 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.1% 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.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
-2 \cdot \left(t_0 \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), t_0 \cdot \cos x\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 37.1%

    \[\cos \left(x + \varepsilon\right) - \cos x \]
  2. Step-by-step derivation
    1. diff-cos43.0%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + \varepsilon\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right)} \]
    2. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(\left(\left(x + \varepsilon\right) - x\right) \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    3. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    4. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \color{blue}{\left(\left(\left(x + \varepsilon\right) + x\right) \cdot \frac{1}{2}\right)}\right) \]
    5. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\color{blue}{\left(x + \left(x + \varepsilon\right)\right)} \cdot \frac{1}{2}\right)\right) \]
    6. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot \color{blue}{0.5}\right)\right) \]
  3. Applied egg-rr43.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right)} \]
  4. Step-by-step derivation
    1. *-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(0.5 \cdot \left(\left(x + \varepsilon\right) - x\right)\right)} \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    2. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\color{blue}{\left(\varepsilon + x\right)} - x\right)\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    3. associate--l+77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x - x\right)\right)}\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    4. *-commutative77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right)}\right) \]
    5. associate-+r+78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\left(x + x\right) + \varepsilon\right)}\right)\right) \]
    6. +-commutative78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x + x\right)\right)}\right)\right) \]
  5. Simplified78.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-in78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \varepsilon + 0.5 \cdot \left(x + x\right)\right)}\right) \]
    2. sin-sum99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  7. Applied egg-rr99.4%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    2. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\color{blue}{\sin \left(0.5 \cdot \left(x + x\right)\right) \cdot \cos \left(0.5 \cdot \varepsilon\right)} + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    3. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    4. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    5. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    6. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \color{blue}{\left(\varepsilon \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    7. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right)\right)\right) \]
    8. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)}\right)\right) \]
    9. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right)\right)\right) \]
    10. fma-def99.5%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(x + x\right) \cdot 0.5\right), \cos \left(0.5 \cdot \varepsilon\right), \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\left(x + x\right) \cdot 0.5\right)\right)}\right) \]
  9. Simplified99.5%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
  10. Taylor expanded in eps around inf 99.4%

    \[\leadsto -2 \cdot \color{blue}{\left(\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right) \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \]
  11. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\color{blue}{\left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
    2. fma-def99.5%

      \[\leadsto -2 \cdot \left(\color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
    3. *-commutative99.5%

      \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)\right)} \]
  12. Simplified99.5%

    \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)\right)} \]
  13. Final simplification99.5%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos x\right)\right) \]

Alternative 2: 99.5% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
-2 \cdot \left(t_0 \cdot \mathsf{fma}\left(\cos x, t_0, \sin x \cdot \cos \left(\varepsilon \cdot -0.5\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 37.1%

    \[\cos \left(x + \varepsilon\right) - \cos x \]
  2. Step-by-step derivation
    1. diff-cos43.0%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + \varepsilon\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right)} \]
    2. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(\left(\left(x + \varepsilon\right) - x\right) \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    3. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    4. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \color{blue}{\left(\left(\left(x + \varepsilon\right) + x\right) \cdot \frac{1}{2}\right)}\right) \]
    5. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\color{blue}{\left(x + \left(x + \varepsilon\right)\right)} \cdot \frac{1}{2}\right)\right) \]
    6. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot \color{blue}{0.5}\right)\right) \]
  3. Applied egg-rr43.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right)} \]
  4. Step-by-step derivation
    1. *-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(0.5 \cdot \left(\left(x + \varepsilon\right) - x\right)\right)} \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    2. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\color{blue}{\left(\varepsilon + x\right)} - x\right)\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    3. associate--l+77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x - x\right)\right)}\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    4. *-commutative77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right)}\right) \]
    5. associate-+r+78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\left(x + x\right) + \varepsilon\right)}\right)\right) \]
    6. +-commutative78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x + x\right)\right)}\right)\right) \]
  5. Simplified78.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-in78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \varepsilon + 0.5 \cdot \left(x + x\right)\right)}\right) \]
    2. sin-sum99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  7. Applied egg-rr99.4%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    2. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\color{blue}{\sin \left(0.5 \cdot \left(x + x\right)\right) \cdot \cos \left(0.5 \cdot \varepsilon\right)} + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    3. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    4. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    5. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    6. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \color{blue}{\left(\varepsilon \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    7. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right)\right)\right) \]
    8. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)}\right)\right) \]
    9. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right)\right)\right) \]
    10. fma-def99.5%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(x + x\right) \cdot 0.5\right), \cos \left(0.5 \cdot \varepsilon\right), \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\left(x + x\right) \cdot 0.5\right)\right)}\right) \]
  9. Simplified99.5%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
  10. Taylor expanded in eps around inf 99.4%

    \[\leadsto -2 \cdot \color{blue}{\left(\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right) \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \]
  11. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\color{blue}{\left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
    2. fma-def99.5%

      \[\leadsto -2 \cdot \left(\color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
    3. *-commutative99.5%

      \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)\right)} \]
    4. fma-def99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \color{blue}{\left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
    5. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \color{blue}{\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
    6. fma-def99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \color{blue}{\mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
    7. metadata-eval99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(\color{blue}{\left(-0.5 \cdot -1\right)} \cdot \varepsilon\right)\right)\right) \]
    8. associate-*r*99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \color{blue}{\left(-0.5 \cdot \left(-1 \cdot \varepsilon\right)\right)}\right)\right) \]
    9. mul-1-neg99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(-0.5 \cdot \color{blue}{\left(-\varepsilon\right)}\right)\right)\right) \]
    10. distribute-rgt-neg-out99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \color{blue}{\left(--0.5 \cdot \varepsilon\right)}\right)\right) \]
    11. metadata-eval99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(-\color{blue}{\left(-0.5\right)} \cdot \varepsilon\right)\right)\right) \]
    12. distribute-lft-neg-in99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(-\color{blue}{\left(-0.5 \cdot \varepsilon\right)}\right)\right)\right) \]
    13. cos-neg99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \color{blue}{\cos \left(-0.5 \cdot \varepsilon\right)}\right)\right) \]
    14. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(-\color{blue}{\varepsilon \cdot 0.5}\right)\right)\right) \]
    15. distribute-rgt-neg-in99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \color{blue}{\left(\varepsilon \cdot \left(-0.5\right)\right)}\right)\right) \]
    16. metadata-eval99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(\varepsilon \cdot \color{blue}{-0.5}\right)\right)\right) \]
  12. Simplified99.4%

    \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(\varepsilon \cdot -0.5\right)\right)\right)} \]
  13. Final simplification99.4%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\cos x, \sin \left(0.5 \cdot \varepsilon\right), \sin x \cdot \cos \left(\varepsilon \cdot -0.5\right)\right)\right) \]

Alternative 3: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\ -2 \cdot \left(t_0 \cdot \left(t_0 \cdot \cos x + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (sin (* 0.5 eps))))
   (* -2.0 (* t_0 (+ (* t_0 (cos x)) (* (sin x) (cos (* 0.5 eps))))))))
double code(double x, double eps) {
	double t_0 = sin((0.5 * eps));
	return -2.0 * (t_0 * ((t_0 * cos(x)) + (sin(x) * cos((0.5 * eps)))));
}
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 = (-2.0d0) * (t_0 * ((t_0 * cos(x)) + (sin(x) * cos((0.5d0 * eps)))))
end function
public static double code(double x, double eps) {
	double t_0 = Math.sin((0.5 * eps));
	return -2.0 * (t_0 * ((t_0 * Math.cos(x)) + (Math.sin(x) * Math.cos((0.5 * eps)))));
}
def code(x, eps):
	t_0 = math.sin((0.5 * eps))
	return -2.0 * (t_0 * ((t_0 * math.cos(x)) + (math.sin(x) * math.cos((0.5 * eps)))))
function code(x, eps)
	t_0 = sin(Float64(0.5 * eps))
	return Float64(-2.0 * Float64(t_0 * Float64(Float64(t_0 * cos(x)) + Float64(sin(x) * cos(Float64(0.5 * eps))))))
end
function tmp = code(x, eps)
	t_0 = sin((0.5 * eps));
	tmp = -2.0 * (t_0 * ((t_0 * cos(x)) + (sin(x) * cos((0.5 * eps)))));
end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
-2 \cdot \left(t_0 \cdot \left(t_0 \cdot \cos x + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 37.1%

    \[\cos \left(x + \varepsilon\right) - \cos x \]
  2. Step-by-step derivation
    1. diff-cos43.0%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + \varepsilon\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right)} \]
    2. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(\left(\left(x + \varepsilon\right) - x\right) \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    3. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    4. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \color{blue}{\left(\left(\left(x + \varepsilon\right) + x\right) \cdot \frac{1}{2}\right)}\right) \]
    5. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\color{blue}{\left(x + \left(x + \varepsilon\right)\right)} \cdot \frac{1}{2}\right)\right) \]
    6. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot \color{blue}{0.5}\right)\right) \]
  3. Applied egg-rr43.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right)} \]
  4. Step-by-step derivation
    1. *-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(0.5 \cdot \left(\left(x + \varepsilon\right) - x\right)\right)} \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    2. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\color{blue}{\left(\varepsilon + x\right)} - x\right)\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    3. associate--l+77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x - x\right)\right)}\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    4. *-commutative77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right)}\right) \]
    5. associate-+r+78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\left(x + x\right) + \varepsilon\right)}\right)\right) \]
    6. +-commutative78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x + x\right)\right)}\right)\right) \]
  5. Simplified78.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-in78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \varepsilon + 0.5 \cdot \left(x + x\right)\right)}\right) \]
    2. sin-sum99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  7. Applied egg-rr99.4%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    2. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\color{blue}{\sin \left(0.5 \cdot \left(x + x\right)\right) \cdot \cos \left(0.5 \cdot \varepsilon\right)} + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    3. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    4. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    5. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    6. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \color{blue}{\left(\varepsilon \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    7. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right)\right)\right) \]
    8. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)}\right)\right) \]
    9. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right)\right)\right) \]
    10. fma-def99.5%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(x + x\right) \cdot 0.5\right), \cos \left(0.5 \cdot \varepsilon\right), \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\left(x + x\right) \cdot 0.5\right)\right)}\right) \]
  9. Simplified99.5%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
  10. Taylor expanded in eps around inf 99.4%

    \[\leadsto -2 \cdot \color{blue}{\left(\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right) \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \]
  11. Final simplification99.4%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos x + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)\right) \]

Alternative 4: 99.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-8} \lor \neg \left(x \leq 1.25 \cdot 10^{-39}\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.4999999999999999e-8 or 1.25e-39 < x

    1. Initial program 9.4%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Step-by-step derivation
      1. cos-sum48.7%

        \[\leadsto \color{blue}{\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right)} - \cos x \]
      2. cancel-sign-sub-inv48.7%

        \[\leadsto \color{blue}{\left(\cos x \cdot \cos \varepsilon + \left(-\sin x\right) \cdot \sin \varepsilon\right)} - \cos x \]
      3. fma-def48.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\sin x\right) \cdot \sin \varepsilon\right)} - \cos x \]
    3. Applied egg-rr48.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\sin x\right) \cdot \sin \varepsilon\right)} - \cos x \]
    4. Taylor expanded in x around inf 48.7%

      \[\leadsto \color{blue}{\left(-1 \cdot \left(\sin x \cdot \sin \varepsilon\right) + \cos \varepsilon \cdot \cos x\right) - \cos x} \]
    5. Step-by-step derivation
      1. neg-mul-148.7%

        \[\leadsto \left(\color{blue}{\left(-\sin x \cdot \sin \varepsilon\right)} + \cos \varepsilon \cdot \cos x\right) - \cos x \]
      2. distribute-lft-neg-in48.7%

        \[\leadsto \left(\color{blue}{\left(-\sin x\right) \cdot \sin \varepsilon} + \cos \varepsilon \cdot \cos x\right) - \cos x \]
      3. associate--l+99.0%

        \[\leadsto \color{blue}{\left(-\sin x\right) \cdot \sin \varepsilon + \left(\cos \varepsilon \cdot \cos x - \cos x\right)} \]
      4. *-commutative99.0%

        \[\leadsto \left(-\sin x\right) \cdot \sin \varepsilon + \left(\color{blue}{\cos x \cdot \cos \varepsilon} - \cos x\right) \]
      5. +-commutative99.0%

        \[\leadsto \color{blue}{\left(\cos x \cdot \cos \varepsilon - \cos x\right) + \left(-\sin x\right) \cdot \sin \varepsilon} \]
      6. distribute-lft-neg-in99.0%

        \[\leadsto \left(\cos x \cdot \cos \varepsilon - \cos x\right) + \color{blue}{\left(-\sin x \cdot \sin \varepsilon\right)} \]
      7. unsub-neg99.0%

        \[\leadsto \color{blue}{\left(\cos x \cdot \cos \varepsilon - \cos x\right) - \sin x \cdot \sin \varepsilon} \]
      8. *-rgt-identity99.0%

        \[\leadsto \left(\cos x \cdot \cos \varepsilon - \color{blue}{\cos x \cdot 1}\right) - \sin x \cdot \sin \varepsilon \]
      9. distribute-lft-out--99.0%

        \[\leadsto \color{blue}{\cos x \cdot \left(\cos \varepsilon - 1\right)} - \sin x \cdot \sin \varepsilon \]
      10. sub-neg99.0%

        \[\leadsto \cos x \cdot \color{blue}{\left(\cos \varepsilon + \left(-1\right)\right)} - \sin x \cdot \sin \varepsilon \]
      11. metadata-eval99.0%

        \[\leadsto \cos x \cdot \left(\cos \varepsilon + \color{blue}{-1}\right) - \sin x \cdot \sin \varepsilon \]
      12. +-commutative99.0%

        \[\leadsto \cos x \cdot \color{blue}{\left(-1 + \cos \varepsilon\right)} - \sin x \cdot \sin \varepsilon \]
    6. Simplified99.0%

      \[\leadsto \color{blue}{\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon} \]

    if -2.4999999999999999e-8 < x < 1.25e-39

    1. Initial program 73.9%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Step-by-step derivation
      1. diff-cos89.2%

        \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + \varepsilon\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right)} \]
      2. div-inv89.2%

        \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(\left(\left(x + \varepsilon\right) - x\right) \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
      3. metadata-eval89.2%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
      4. div-inv89.2%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \color{blue}{\left(\left(\left(x + \varepsilon\right) + x\right) \cdot \frac{1}{2}\right)}\right) \]
      5. +-commutative89.2%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\color{blue}{\left(x + \left(x + \varepsilon\right)\right)} \cdot \frac{1}{2}\right)\right) \]
      6. metadata-eval89.2%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot \color{blue}{0.5}\right)\right) \]
    3. Applied egg-rr89.2%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutative89.2%

        \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(0.5 \cdot \left(\left(x + \varepsilon\right) - x\right)\right)} \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
      2. +-commutative89.2%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\color{blue}{\left(\varepsilon + x\right)} - x\right)\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
      3. associate--l+99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x - x\right)\right)}\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
      4. *-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right)}\right) \]
      5. associate-+r+99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\left(x + x\right) + \varepsilon\right)}\right)\right) \]
      6. +-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x + x\right)\right)}\right)\right) \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \varepsilon + 0.5 \cdot \left(x + x\right)\right)}\right) \]
      2. sin-sum99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    7. Applied egg-rr99.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    8. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
      2. *-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\color{blue}{\sin \left(0.5 \cdot \left(x + x\right)\right) \cdot \cos \left(0.5 \cdot \varepsilon\right)} + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      3. count-299.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      4. *-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      5. count-299.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      6. *-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \color{blue}{\left(\varepsilon \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      7. count-299.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right)\right)\right) \]
      8. *-commutative99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)}\right)\right) \]
      9. count-299.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right)\right)\right) \]
      10. fma-def99.7%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(x + x\right) \cdot 0.5\right), \cos \left(0.5 \cdot \varepsilon\right), \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\left(x + x\right) \cdot 0.5\right)\right)}\right) \]
    9. Simplified99.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
    10. Taylor expanded in eps around inf 99.7%

      \[\leadsto -2 \cdot \color{blue}{\left(\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right) \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \]
    11. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto -2 \cdot \left(\color{blue}{\left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
      2. sin-sum99.7%

        \[\leadsto -2 \cdot \left(\color{blue}{\sin \left(x + 0.5 \cdot \varepsilon\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
    12. Applied egg-rr99.7%

      \[\leadsto -2 \cdot \left(\color{blue}{\sin \left(x + 0.5 \cdot \varepsilon\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-8} \lor \neg \left(x \leq 1.25 \cdot 10^{-39}\right):\\ \;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \varepsilon + x\right)\right)\\ \end{array} \]

Alternative 5: 67.7% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -5.0000000000000004e-16

    1. Initial program 78.2%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 78.4%

      \[\leadsto \color{blue}{\cos \varepsilon - 1} \]
    3. Step-by-step derivation
      1. flip--78.2%

        \[\leadsto \color{blue}{\frac{\cos \varepsilon \cdot \cos \varepsilon - 1 \cdot 1}{\cos \varepsilon + 1}} \]
      2. metadata-eval78.2%

        \[\leadsto \frac{\cos \varepsilon \cdot \cos \varepsilon - \color{blue}{1}}{\cos \varepsilon + 1} \]
      3. sub-1-cos80.4%

        \[\leadsto \frac{\color{blue}{-\sin \varepsilon \cdot \sin \varepsilon}}{\cos \varepsilon + 1} \]
      4. pow180.4%

        \[\leadsto \frac{-\color{blue}{{\sin \varepsilon}^{1}} \cdot \sin \varepsilon}{\cos \varepsilon + 1} \]
      5. pow180.4%

        \[\leadsto \frac{-{\sin \varepsilon}^{1} \cdot \color{blue}{{\sin \varepsilon}^{1}}}{\cos \varepsilon + 1} \]
      6. pow-prod-up80.4%

        \[\leadsto \frac{-\color{blue}{{\sin \varepsilon}^{\left(1 + 1\right)}}}{\cos \varepsilon + 1} \]
      7. metadata-eval80.4%

        \[\leadsto \frac{-{\sin \varepsilon}^{\color{blue}{2}}}{\cos \varepsilon + 1} \]
    4. Applied egg-rr80.4%

      \[\leadsto \color{blue}{\frac{-{\sin \varepsilon}^{2}}{\cos \varepsilon + 1}} \]
    5. Step-by-step derivation
      1. distribute-frac-neg80.4%

        \[\leadsto \color{blue}{-\frac{{\sin \varepsilon}^{2}}{\cos \varepsilon + 1}} \]
      2. /-rgt-identity80.4%

        \[\leadsto -\color{blue}{\frac{\frac{{\sin \varepsilon}^{2}}{\cos \varepsilon + 1}}{1}} \]
      3. associate-/r*80.4%

        \[\leadsto -\color{blue}{\frac{{\sin \varepsilon}^{2}}{\left(\cos \varepsilon + 1\right) \cdot 1}} \]
      4. unpow280.4%

        \[\leadsto -\frac{\color{blue}{\sin \varepsilon \cdot \sin \varepsilon}}{\left(\cos \varepsilon + 1\right) \cdot 1} \]
      5. times-frac80.7%

        \[\leadsto -\color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon + 1} \cdot \frac{\sin \varepsilon}{1}} \]
      6. +-commutative80.7%

        \[\leadsto -\frac{\sin \varepsilon}{\color{blue}{1 + \cos \varepsilon}} \cdot \frac{\sin \varepsilon}{1} \]
      7. hang-0p-tan81.0%

        \[\leadsto -\color{blue}{\tan \left(\frac{\varepsilon}{2}\right)} \cdot \frac{\sin \varepsilon}{1} \]
      8. /-rgt-identity81.0%

        \[\leadsto -\tan \left(\frac{\varepsilon}{2}\right) \cdot \color{blue}{\sin \varepsilon} \]
    6. Simplified81.0%

      \[\leadsto \color{blue}{-\tan \left(\frac{\varepsilon}{2}\right) \cdot \sin \varepsilon} \]

    if -5.0000000000000004e-16 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x))

    1. Initial program 18.8%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Step-by-step derivation
      1. diff-cos26.4%

        \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + \varepsilon\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right)} \]
      2. div-inv26.4%

        \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(\left(\left(x + \varepsilon\right) - x\right) \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
      3. metadata-eval26.4%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
      4. div-inv26.4%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \color{blue}{\left(\left(\left(x + \varepsilon\right) + x\right) \cdot \frac{1}{2}\right)}\right) \]
      5. +-commutative26.4%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\color{blue}{\left(x + \left(x + \varepsilon\right)\right)} \cdot \frac{1}{2}\right)\right) \]
      6. metadata-eval26.4%

        \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot \color{blue}{0.5}\right)\right) \]
    3. Applied egg-rr26.4%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutative26.4%

        \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(0.5 \cdot \left(\left(x + \varepsilon\right) - x\right)\right)} \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
      2. +-commutative26.4%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\color{blue}{\left(\varepsilon + x\right)} - x\right)\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
      3. associate--l+76.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x - x\right)\right)}\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
      4. *-commutative76.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right)}\right) \]
      5. associate-+r+76.9%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\left(x + x\right) + \varepsilon\right)}\right)\right) \]
      6. +-commutative76.9%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x + x\right)\right)}\right)\right) \]
    5. Simplified76.9%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in76.9%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \varepsilon + 0.5 \cdot \left(x + x\right)\right)}\right) \]
      2. sin-sum99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    7. Applied egg-rr99.5%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    8. Step-by-step derivation
      1. +-commutative99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
      2. *-commutative99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\color{blue}{\sin \left(0.5 \cdot \left(x + x\right)\right) \cdot \cos \left(0.5 \cdot \varepsilon\right)} + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      3. count-299.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      4. *-commutative99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      5. count-299.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      6. *-commutative99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \color{blue}{\left(\varepsilon \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
      7. count-299.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right)\right)\right) \]
      8. *-commutative99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)}\right)\right) \]
      9. count-299.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right)\right)\right) \]
      10. fma-def99.5%

        \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(x + x\right) \cdot 0.5\right), \cos \left(0.5 \cdot \varepsilon\right), \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\left(x + x\right) \cdot 0.5\right)\right)}\right) \]
    9. Simplified99.5%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
    10. Taylor expanded in eps around inf 99.5%

      \[\leadsto -2 \cdot \color{blue}{\left(\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right) \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \]
    11. Step-by-step derivation
      1. +-commutative99.5%

        \[\leadsto -2 \cdot \left(\color{blue}{\left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
      2. fma-def99.5%

        \[\leadsto -2 \cdot \left(\color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
      3. *-commutative99.5%

        \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)\right)} \]
    12. Simplified99.5%

      \[\leadsto -2 \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)\right)} \]
    13. Taylor expanded in eps around 0 68.8%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \color{blue}{\sin x}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-16}:\\ \;\;\;\;\tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin x\right)\\ \end{array} \]

Alternative 6: 66.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-16}:\\ \;\;\;\;\tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-\varepsilon \cdot \sin x\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= (- (cos (+ eps x)) (cos x)) -5e-16)
   (* (tan (/ eps 2.0)) (- (sin eps)))
   (log1p (- (* eps (sin x))))))
double code(double x, double eps) {
	double tmp;
	if ((cos((eps + x)) - cos(x)) <= -5e-16) {
		tmp = tan((eps / 2.0)) * -sin(eps);
	} else {
		tmp = log1p(-(eps * sin(x)));
	}
	return tmp;
}
public static double code(double x, double eps) {
	double tmp;
	if ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-16) {
		tmp = Math.tan((eps / 2.0)) * -Math.sin(eps);
	} else {
		tmp = Math.log1p(-(eps * Math.sin(x)));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (math.cos((eps + x)) - math.cos(x)) <= -5e-16:
		tmp = math.tan((eps / 2.0)) * -math.sin(eps)
	else:
		tmp = math.log1p(-(eps * math.sin(x)))
	return tmp
function code(x, eps)
	tmp = 0.0
	if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-16)
		tmp = Float64(tan(Float64(eps / 2.0)) * Float64(-sin(eps)));
	else
		tmp = log1p(Float64(-Float64(eps * sin(x))));
	end
	return tmp
end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-16], N[(N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision], N[Log[1 + (-N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -5.0000000000000004e-16

    1. Initial program 78.2%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 78.4%

      \[\leadsto \color{blue}{\cos \varepsilon - 1} \]
    3. Step-by-step derivation
      1. flip--78.2%

        \[\leadsto \color{blue}{\frac{\cos \varepsilon \cdot \cos \varepsilon - 1 \cdot 1}{\cos \varepsilon + 1}} \]
      2. metadata-eval78.2%

        \[\leadsto \frac{\cos \varepsilon \cdot \cos \varepsilon - \color{blue}{1}}{\cos \varepsilon + 1} \]
      3. sub-1-cos80.4%

        \[\leadsto \frac{\color{blue}{-\sin \varepsilon \cdot \sin \varepsilon}}{\cos \varepsilon + 1} \]
      4. pow180.4%

        \[\leadsto \frac{-\color{blue}{{\sin \varepsilon}^{1}} \cdot \sin \varepsilon}{\cos \varepsilon + 1} \]
      5. pow180.4%

        \[\leadsto \frac{-{\sin \varepsilon}^{1} \cdot \color{blue}{{\sin \varepsilon}^{1}}}{\cos \varepsilon + 1} \]
      6. pow-prod-up80.4%

        \[\leadsto \frac{-\color{blue}{{\sin \varepsilon}^{\left(1 + 1\right)}}}{\cos \varepsilon + 1} \]
      7. metadata-eval80.4%

        \[\leadsto \frac{-{\sin \varepsilon}^{\color{blue}{2}}}{\cos \varepsilon + 1} \]
    4. Applied egg-rr80.4%

      \[\leadsto \color{blue}{\frac{-{\sin \varepsilon}^{2}}{\cos \varepsilon + 1}} \]
    5. Step-by-step derivation
      1. distribute-frac-neg80.4%

        \[\leadsto \color{blue}{-\frac{{\sin \varepsilon}^{2}}{\cos \varepsilon + 1}} \]
      2. /-rgt-identity80.4%

        \[\leadsto -\color{blue}{\frac{\frac{{\sin \varepsilon}^{2}}{\cos \varepsilon + 1}}{1}} \]
      3. associate-/r*80.4%

        \[\leadsto -\color{blue}{\frac{{\sin \varepsilon}^{2}}{\left(\cos \varepsilon + 1\right) \cdot 1}} \]
      4. unpow280.4%

        \[\leadsto -\frac{\color{blue}{\sin \varepsilon \cdot \sin \varepsilon}}{\left(\cos \varepsilon + 1\right) \cdot 1} \]
      5. times-frac80.7%

        \[\leadsto -\color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon + 1} \cdot \frac{\sin \varepsilon}{1}} \]
      6. +-commutative80.7%

        \[\leadsto -\frac{\sin \varepsilon}{\color{blue}{1 + \cos \varepsilon}} \cdot \frac{\sin \varepsilon}{1} \]
      7. hang-0p-tan81.0%

        \[\leadsto -\color{blue}{\tan \left(\frac{\varepsilon}{2}\right)} \cdot \frac{\sin \varepsilon}{1} \]
      8. /-rgt-identity81.0%

        \[\leadsto -\tan \left(\frac{\varepsilon}{2}\right) \cdot \color{blue}{\sin \varepsilon} \]
    6. Simplified81.0%

      \[\leadsto \color{blue}{-\tan \left(\frac{\varepsilon}{2}\right) \cdot \sin \varepsilon} \]

    if -5.0000000000000004e-16 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x))

    1. Initial program 18.8%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Step-by-step derivation
      1. log1p-expm1-u18.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(x + \varepsilon\right) - \cos x\right)\right)} \]
    3. Applied egg-rr18.8%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(x + \varepsilon\right) - \cos x\right)\right)} \]
    4. Taylor expanded in eps around 0 67.1%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)}\right) \]
    5. Step-by-step derivation
      1. mul-1-neg67.1%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{-\varepsilon \cdot \sin x}\right) \]
      2. *-commutative67.1%

        \[\leadsto \mathsf{log1p}\left(-\color{blue}{\sin x \cdot \varepsilon}\right) \]
      3. distribute-rgt-neg-in67.1%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{\sin x \cdot \left(-\varepsilon\right)}\right) \]
    6. Simplified67.1%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\sin x \cdot \left(-\varepsilon\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-16}:\\ \;\;\;\;\tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-\varepsilon \cdot \sin x\right)\\ \end{array} \]

Alternative 7: 66.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-16}:\\ \;\;\;\;\cos \varepsilon - \cos x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-\varepsilon \cdot \sin x\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= (- (cos (+ eps x)) (cos x)) -5e-16)
   (- (cos eps) (cos x))
   (log1p (- (* eps (sin x))))))
double code(double x, double eps) {
	double tmp;
	if ((cos((eps + x)) - cos(x)) <= -5e-16) {
		tmp = cos(eps) - cos(x);
	} else {
		tmp = log1p(-(eps * sin(x)));
	}
	return tmp;
}
public static double code(double x, double eps) {
	double tmp;
	if ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-16) {
		tmp = Math.cos(eps) - Math.cos(x);
	} else {
		tmp = Math.log1p(-(eps * Math.sin(x)));
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (math.cos((eps + x)) - math.cos(x)) <= -5e-16:
		tmp = math.cos(eps) - math.cos(x)
	else:
		tmp = math.log1p(-(eps * math.sin(x)))
	return tmp
function code(x, eps)
	tmp = 0.0
	if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-16)
		tmp = Float64(cos(eps) - cos(x));
	else
		tmp = log1p(Float64(-Float64(eps * sin(x))));
	end
	return tmp
end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-16], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[Log[1 + (-N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -5.0000000000000004e-16

    1. Initial program 78.2%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 78.6%

      \[\leadsto \color{blue}{\cos \varepsilon} - \cos x \]

    if -5.0000000000000004e-16 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x))

    1. Initial program 18.8%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Step-by-step derivation
      1. log1p-expm1-u18.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(x + \varepsilon\right) - \cos x\right)\right)} \]
    3. Applied egg-rr18.8%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(x + \varepsilon\right) - \cos x\right)\right)} \]
    4. Taylor expanded in eps around 0 67.1%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)}\right) \]
    5. Step-by-step derivation
      1. mul-1-neg67.1%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{-\varepsilon \cdot \sin x}\right) \]
      2. *-commutative67.1%

        \[\leadsto \mathsf{log1p}\left(-\color{blue}{\sin x \cdot \varepsilon}\right) \]
      3. distribute-rgt-neg-in67.1%

        \[\leadsto \mathsf{log1p}\left(\color{blue}{\sin x \cdot \left(-\varepsilon\right)}\right) \]
    6. Simplified67.1%

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\sin x \cdot \left(-\varepsilon\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-16}:\\ \;\;\;\;\cos \varepsilon - \cos x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-\varepsilon \cdot \sin x\right)\\ \end{array} \]

Alternative 8: 76.5% accurate, 1.0× speedup?

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

\\
-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \varepsilon + x\right)\right)
\end{array}
Derivation
  1. Initial program 37.1%

    \[\cos \left(x + \varepsilon\right) - \cos x \]
  2. Step-by-step derivation
    1. diff-cos43.0%

      \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\frac{\left(x + \varepsilon\right) - x}{2}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right)} \]
    2. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(\left(\left(x + \varepsilon\right) - x\right) \cdot \frac{1}{2}\right)} \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    3. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot \color{blue}{0.5}\right) \cdot \sin \left(\frac{\left(x + \varepsilon\right) + x}{2}\right)\right) \]
    4. div-inv43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \color{blue}{\left(\left(\left(x + \varepsilon\right) + x\right) \cdot \frac{1}{2}\right)}\right) \]
    5. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\color{blue}{\left(x + \left(x + \varepsilon\right)\right)} \cdot \frac{1}{2}\right)\right) \]
    6. metadata-eval43.0%

      \[\leadsto -2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot \color{blue}{0.5}\right)\right) \]
  3. Applied egg-rr43.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(\left(\left(x + \varepsilon\right) - x\right) \cdot 0.5\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right)} \]
  4. Step-by-step derivation
    1. *-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \color{blue}{\left(0.5 \cdot \left(\left(x + \varepsilon\right) - x\right)\right)} \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    2. +-commutative43.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\color{blue}{\left(\varepsilon + x\right)} - x\right)\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    3. associate--l+77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x - x\right)\right)}\right) \cdot \sin \left(\left(x + \left(x + \varepsilon\right)\right) \cdot 0.5\right)\right) \]
    4. *-commutative77.7%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right)}\right) \]
    5. associate-+r+78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\left(x + x\right) + \varepsilon\right)}\right)\right) \]
    6. +-commutative78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \color{blue}{\left(\varepsilon + \left(x + x\right)\right)}\right)\right) \]
  5. Simplified78.0%

    \[\leadsto \color{blue}{-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-in78.0%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \color{blue}{\left(0.5 \cdot \varepsilon + 0.5 \cdot \left(x + x\right)\right)}\right) \]
    2. sin-sum99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  7. Applied egg-rr99.4%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right) + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
  8. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\left(\cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)}\right) \]
    2. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\color{blue}{\sin \left(0.5 \cdot \left(x + x\right)\right) \cdot \cos \left(0.5 \cdot \varepsilon\right)} + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    3. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    4. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    5. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(0.5 \cdot \varepsilon\right) \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    6. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \color{blue}{\left(\varepsilon \cdot 0.5\right)} \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right) \]
    7. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \color{blue}{\left(2 \cdot x\right)}\right)\right)\right) \]
    8. *-commutative99.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \color{blue}{\left(\left(2 \cdot x\right) \cdot 0.5\right)}\right)\right) \]
    9. count-299.4%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \left(\sin \left(\left(x + x\right) \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \varepsilon\right) + \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\color{blue}{\left(x + x\right)} \cdot 0.5\right)\right)\right) \]
    10. fma-def99.5%

      \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(x + x\right) \cdot 0.5\right), \cos \left(0.5 \cdot \varepsilon\right), \sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(\left(x + x\right) \cdot 0.5\right)\right)}\right) \]
  9. Simplified99.5%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)}\right) \]
  10. Taylor expanded in eps around inf 99.4%

    \[\leadsto -2 \cdot \color{blue}{\left(\left(\cos x \cdot \sin \left(0.5 \cdot \varepsilon\right) + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right) \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \]
  11. Step-by-step derivation
    1. +-commutative99.4%

      \[\leadsto -2 \cdot \left(\color{blue}{\left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + \cos x \cdot \sin \left(0.5 \cdot \varepsilon\right)\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
    2. sin-sum78.0%

      \[\leadsto -2 \cdot \left(\color{blue}{\sin \left(x + 0.5 \cdot \varepsilon\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
  12. Applied egg-rr78.0%

    \[\leadsto -2 \cdot \left(\color{blue}{\sin \left(x + 0.5 \cdot \varepsilon\right)} \cdot \sin \left(0.5 \cdot \varepsilon\right)\right) \]
  13. Final simplification78.0%

    \[\leadsto -2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \varepsilon + x\right)\right) \]

Alternative 9: 67.6% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;-\varepsilon \cdot \sin x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -4.19999999999999989e-8 or 6.4000000000000001e-7 < eps

    1. Initial program 52.7%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 54.5%

      \[\leadsto \color{blue}{\cos \varepsilon} - \cos x \]

    if -4.19999999999999989e-8 < eps < 6.4000000000000001e-7

    1. Initial program 22.4%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in eps around 0 88.3%

      \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)} \]
    3. Step-by-step derivation
      1. associate-*r*88.3%

        \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot \sin x} \]
      2. mul-1-neg88.3%

        \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot \sin x \]
    4. Simplified88.3%

      \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot \sin x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -4.2 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 6.4 \cdot 10^{-7}\right):\\ \;\;\;\;\cos \varepsilon - \cos x\\ \mathbf{else}:\\ \;\;\;\;-\varepsilon \cdot \sin x\\ \end{array} \]

Alternative 10: 45.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.00016:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\varepsilon \leq -3.8 \cdot 10^{-175}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\

\mathbf{elif}\;\varepsilon \leq 900:\\
\;\;\;\;-\varepsilon \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -1.60000000000000013e-4 or 900 < eps

    1. Initial program 53.5%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 53.4%

      \[\leadsto \color{blue}{\cos \varepsilon - 1} \]

    if -1.60000000000000013e-4 < eps < -3.8e-175

    1. Initial program 9.8%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 9.8%

      \[\leadsto \color{blue}{\cos \varepsilon - 1} \]
    3. Taylor expanded in eps around 0 33.6%

      \[\leadsto \color{blue}{-0.5 \cdot {\varepsilon}^{2}} \]
    4. Step-by-step derivation
      1. *-commutative33.6%

        \[\leadsto \color{blue}{{\varepsilon}^{2} \cdot -0.5} \]
      2. unpow233.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot \varepsilon\right)} \cdot -0.5 \]
    5. Simplified33.6%

      \[\leadsto \color{blue}{\left(\varepsilon \cdot \varepsilon\right) \cdot -0.5} \]

    if -3.8e-175 < eps < 900

    1. Initial program 28.3%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in eps around 0 93.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)} \]
    3. Step-by-step derivation
      1. associate-*r*93.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot \sin x} \]
      2. mul-1-neg93.0%

        \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot \sin x \]
    4. Simplified93.0%

      \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot \sin x} \]
    5. Taylor expanded in x around 0 41.3%

      \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot x\right)} \]
    6. Step-by-step derivation
      1. associate-*r*41.3%

        \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot x} \]
      2. neg-mul-141.3%

        \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot x \]
    7. Simplified41.3%

      \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification45.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.00016:\\ \;\;\;\;-1 + \cos \varepsilon\\ \mathbf{elif}\;\varepsilon \leq -3.8 \cdot 10^{-175}:\\ \;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\ \mathbf{elif}\;\varepsilon \leq 900:\\ \;\;\;\;-\varepsilon \cdot x\\ \mathbf{else}:\\ \;\;\;\;-1 + \cos \varepsilon\\ \end{array} \]

Alternative 11: 66.8% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;-\varepsilon \cdot \sin x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -4.49999999999999993e-8 or 900 < eps

    1. Initial program 53.1%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 53.1%

      \[\leadsto \color{blue}{\cos \varepsilon - 1} \]

    if -4.49999999999999993e-8 < eps < 900

    1. Initial program 22.3%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in eps around 0 87.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)} \]
    3. Step-by-step derivation
      1. associate-*r*87.7%

        \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot \sin x} \]
      2. mul-1-neg87.7%

        \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot \sin x \]
    4. Simplified87.7%

      \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot \sin x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -4.5 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 900\right):\\ \;\;\;\;-1 + \cos \varepsilon\\ \mathbf{else}:\\ \;\;\;\;-\varepsilon \cdot \sin x\\ \end{array} \]

Alternative 12: 25.0% accurate, 22.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{-93} \lor \neg \left(x \leq 8 \cdot 10^{-93}\right):\\
\;\;\;\;-\varepsilon \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.85000000000000001e-93 or 7.9999999999999992e-93 < x

    1. Initial program 20.1%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in eps around 0 53.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)} \]
    3. Step-by-step derivation
      1. associate-*r*53.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot \sin x} \]
      2. mul-1-neg53.0%

        \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot \sin x \]
    4. Simplified53.0%

      \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot \sin x} \]
    5. Taylor expanded in x around 0 12.3%

      \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot x\right)} \]
    6. Step-by-step derivation
      1. associate-*r*12.3%

        \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot x} \]
      2. neg-mul-112.3%

        \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot x \]
    7. Simplified12.3%

      \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot x} \]

    if -1.85000000000000001e-93 < x < 7.9999999999999992e-93

    1. Initial program 76.7%

      \[\cos \left(x + \varepsilon\right) - \cos x \]
    2. Taylor expanded in x around 0 76.7%

      \[\leadsto \color{blue}{\cos \varepsilon - 1} \]
    3. Taylor expanded in eps around 0 52.4%

      \[\leadsto \color{blue}{-0.5 \cdot {\varepsilon}^{2}} \]
    4. Step-by-step derivation
      1. *-commutative52.4%

        \[\leadsto \color{blue}{{\varepsilon}^{2} \cdot -0.5} \]
      2. unpow252.4%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot \varepsilon\right)} \cdot -0.5 \]
    5. Simplified52.4%

      \[\leadsto \color{blue}{\left(\varepsilon \cdot \varepsilon\right) \cdot -0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification24.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{-93} \lor \neg \left(x \leq 8 \cdot 10^{-93}\right):\\ \;\;\;\;-\varepsilon \cdot x\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\ \end{array} \]

Alternative 13: 17.9% accurate, 51.3× speedup?

\[\begin{array}{l} \\ -\varepsilon \cdot x \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(-Float64(eps * x))
end
function tmp = code(x, eps)
	tmp = -(eps * x);
end
code[x_, eps_] := (-N[(eps * x), $MachinePrecision])
\begin{array}{l}

\\
-\varepsilon \cdot x
\end{array}
Derivation
  1. Initial program 37.1%

    \[\cos \left(x + \varepsilon\right) - \cos x \]
  2. Taylor expanded in eps around 0 47.4%

    \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot \sin x\right)} \]
  3. Step-by-step derivation
    1. associate-*r*47.4%

      \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot \sin x} \]
    2. mul-1-neg47.4%

      \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot \sin x \]
  4. Simplified47.4%

    \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot \sin x} \]
  5. Taylor expanded in x around 0 19.0%

    \[\leadsto \color{blue}{-1 \cdot \left(\varepsilon \cdot x\right)} \]
  6. Step-by-step derivation
    1. associate-*r*19.0%

      \[\leadsto \color{blue}{\left(-1 \cdot \varepsilon\right) \cdot x} \]
    2. neg-mul-119.0%

      \[\leadsto \color{blue}{\left(-\varepsilon\right)} \cdot x \]
  7. Simplified19.0%

    \[\leadsto \color{blue}{\left(-\varepsilon\right) \cdot x} \]
  8. Final simplification19.0%

    \[\leadsto -\varepsilon \cdot x \]

Reproduce

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