2tan (problem 3.3.2)

Percentage Accurate: 62.5% → 99.6%
Time: 24.7s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\left(\left(-10000 \leq x \land x \leq 10000\right) \land 10^{-16} \cdot \left|x\right| < \varepsilon\right) \land \varepsilon < \left|x\right|\]
\[\begin{array}{l} \\ \tan \left(x + \varepsilon\right) - \tan x \end{array} \]
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
	return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
	return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps):
	return math.tan((x + eps)) - math.tan(x)
function code(x, eps)
	return Float64(tan(Float64(x + eps)) - tan(x))
end
function tmp = code(x, eps)
	tmp = tan((x + eps)) - tan(x);
end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\tan \left(x + \varepsilon\right) - \tan 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 14 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: 62.5% accurate, 1.0× speedup?

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

\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}

Alternative 1: 99.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin x}{\cos x}\\ t_1 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ t_2 := 1 + t_1\\ t_3 := 0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, t_2, t_1 \cdot 0.16666666666666666\right) + t_1 \cdot \left(-1 - t_1\right)\right)\\ \mathsf{fma}\left(\varepsilon, t_2, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_2}}\right) - \left({\varepsilon}^{3} \cdot t_3 + {\varepsilon}^{4} \cdot \left(t_3 \cdot t_0 + \left(t_2 \cdot t_0\right) \cdot -0.3333333333333333\right)\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (/ (sin x) (cos x)))
        (t_1 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))
        (t_2 (+ 1.0 t_1))
        (t_3
         (+
          0.16666666666666666
          (+
           (fma -0.5 t_2 (* t_1 0.16666666666666666))
           (* t_1 (- -1.0 t_1))))))
   (-
    (fma eps t_2 (/ (pow eps 2.0) (/ (/ (cos x) (sin x)) t_2)))
    (+
     (* (pow eps 3.0) t_3)
     (* (pow eps 4.0) (+ (* t_3 t_0) (* (* t_2 t_0) -0.3333333333333333)))))))
double code(double x, double eps) {
	double t_0 = sin(x) / cos(x);
	double t_1 = pow(sin(x), 2.0) / pow(cos(x), 2.0);
	double t_2 = 1.0 + t_1;
	double t_3 = 0.16666666666666666 + (fma(-0.5, t_2, (t_1 * 0.16666666666666666)) + (t_1 * (-1.0 - t_1)));
	return fma(eps, t_2, (pow(eps, 2.0) / ((cos(x) / sin(x)) / t_2))) - ((pow(eps, 3.0) * t_3) + (pow(eps, 4.0) * ((t_3 * t_0) + ((t_2 * t_0) * -0.3333333333333333))));
}
function code(x, eps)
	t_0 = Float64(sin(x) / cos(x))
	t_1 = Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))
	t_2 = Float64(1.0 + t_1)
	t_3 = Float64(0.16666666666666666 + Float64(fma(-0.5, t_2, Float64(t_1 * 0.16666666666666666)) + Float64(t_1 * Float64(-1.0 - t_1))))
	return Float64(fma(eps, t_2, Float64((eps ^ 2.0) / Float64(Float64(cos(x) / sin(x)) / t_2))) - Float64(Float64((eps ^ 3.0) * t_3) + Float64((eps ^ 4.0) * Float64(Float64(t_3 * t_0) + Float64(Float64(t_2 * t_0) * -0.3333333333333333)))))
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(0.16666666666666666 + N[(N[(-0.5 * t$95$2 + N[(t$95$1 * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(eps * t$95$2 + N[(N[Power[eps, 2.0], $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[eps, 3.0], $MachinePrecision] * t$95$3), $MachinePrecision] + N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(t$95$3 * t$95$0), $MachinePrecision] + N[(N[(t$95$2 * t$95$0), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
t_1 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_2 := 1 + t_1\\
t_3 := 0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, t_2, t_1 \cdot 0.16666666666666666\right) + t_1 \cdot \left(-1 - t_1\right)\right)\\
\mathsf{fma}\left(\varepsilon, t_2, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_2}}\right) - \left({\varepsilon}^{3} \cdot t_3 + {\varepsilon}^{4} \cdot \left(t_3 \cdot t_0 + \left(t_2 \cdot t_0\right) \cdot -0.3333333333333333\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

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

    \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(-1 \cdot \frac{{\sin x}^{2} \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{{\cos x}^{2}} + \left(-0.5 \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right) + \left(-1 \cdot \left({\varepsilon}^{4} \cdot \left(-0.5 \cdot \frac{\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{\cos x} + \left(0.16666666666666666 \cdot \frac{\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{\cos x} + \frac{\sin x \cdot \left(0.16666666666666666 + \left(-1 \cdot \frac{{\sin x}^{2} \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{{\cos x}^{2}} + \left(-0.5 \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)}{\cos x}\right)\right)\right) + \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right)\right)} \]
  3. Simplified99.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}\right) - \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) + {\varepsilon}^{4} \cdot \left(\frac{\sin x}{\cos x} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) + \left(\frac{\sin x}{\cos x} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right) \cdot -0.3333333333333333\right)\right)} \]
  4. Final simplification99.7%

    \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}\right) - \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot 0.16666666666666666\right) + \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(-1 - \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) + {\varepsilon}^{4} \cdot \left(\left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot 0.16666666666666666\right) + \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(-1 - \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) \cdot \frac{\sin x}{\cos x} + \left(\left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) \cdot \frac{\sin x}{\cos x}\right) \cdot -0.3333333333333333\right)\right) \]

Alternative 2: 99.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\cos x}^{-2}\\ t_1 := {\sin x}^{3}\\ t_2 := {\sin x}^{4}\\ t_3 := {\sin x}^{2}\\ t_4 := t_3 \cdot t_0\\ \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left(t_4 - \mathsf{fma}\left(-0.3333333333333333, t_4, \frac{-t_2}{{\cos x}^{4}}\right)\right), \varepsilon \cdot \mathsf{fma}\left(t_3, t_0, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, t_1 \cdot {\cos x}^{-3}, \tan x \cdot \left(t_0 \cdot \left(t_3 \cdot -0.3333333333333333\right) - t_2 \cdot {\cos x}^{-4}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + t_4}}\right)\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{t_1}{{\cos x}^{3}}\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (pow (cos x) -2.0))
        (t_1 (pow (sin x) 3.0))
        (t_2 (pow (sin x) 4.0))
        (t_3 (pow (sin x) 2.0))
        (t_4 (* t_3 t_0)))
   (+
    (-
     (fma
      (pow eps 3.0)
      (+
       0.3333333333333333
       (- t_4 (fma -0.3333333333333333 t_4 (/ (- t_2) (pow (cos x) 4.0)))))
      (* eps (fma t_3 t_0 1.0)))
     (*
      (pow eps 4.0)
      (-
       (+
        (* -0.3333333333333333 (tan x))
        (fma
         -0.3333333333333333
         (* t_1 (pow (cos x) -3.0))
         (*
          (tan x)
          (- (* t_0 (* t_3 -0.3333333333333333)) (* t_2 (pow (cos x) -4.0))))))
       (/ (sin x) (/ (cos x) (+ 0.3333333333333333 t_4))))))
    (* (pow eps 2.0) (+ (/ (sin x) (cos x)) (/ t_1 (pow (cos x) 3.0)))))))
double code(double x, double eps) {
	double t_0 = pow(cos(x), -2.0);
	double t_1 = pow(sin(x), 3.0);
	double t_2 = pow(sin(x), 4.0);
	double t_3 = pow(sin(x), 2.0);
	double t_4 = t_3 * t_0;
	return (fma(pow(eps, 3.0), (0.3333333333333333 + (t_4 - fma(-0.3333333333333333, t_4, (-t_2 / pow(cos(x), 4.0))))), (eps * fma(t_3, t_0, 1.0))) - (pow(eps, 4.0) * (((-0.3333333333333333 * tan(x)) + fma(-0.3333333333333333, (t_1 * pow(cos(x), -3.0)), (tan(x) * ((t_0 * (t_3 * -0.3333333333333333)) - (t_2 * pow(cos(x), -4.0)))))) - (sin(x) / (cos(x) / (0.3333333333333333 + t_4)))))) + (pow(eps, 2.0) * ((sin(x) / cos(x)) + (t_1 / pow(cos(x), 3.0))));
}
function code(x, eps)
	t_0 = cos(x) ^ -2.0
	t_1 = sin(x) ^ 3.0
	t_2 = sin(x) ^ 4.0
	t_3 = sin(x) ^ 2.0
	t_4 = Float64(t_3 * t_0)
	return Float64(Float64(fma((eps ^ 3.0), Float64(0.3333333333333333 + Float64(t_4 - fma(-0.3333333333333333, t_4, Float64(Float64(-t_2) / (cos(x) ^ 4.0))))), Float64(eps * fma(t_3, t_0, 1.0))) - Float64((eps ^ 4.0) * Float64(Float64(Float64(-0.3333333333333333 * tan(x)) + fma(-0.3333333333333333, Float64(t_1 * (cos(x) ^ -3.0)), Float64(tan(x) * Float64(Float64(t_0 * Float64(t_3 * -0.3333333333333333)) - Float64(t_2 * (cos(x) ^ -4.0)))))) - Float64(sin(x) / Float64(cos(x) / Float64(0.3333333333333333 + t_4)))))) + Float64((eps ^ 2.0) * Float64(Float64(sin(x) / cos(x)) + Float64(t_1 / (cos(x) ^ 3.0)))))
end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Cos[x], $MachinePrecision], -2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * t$95$0), $MachinePrecision]}, N[(N[(N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 + N[(t$95$4 - N[(-0.3333333333333333 * t$95$4 + N[((-t$95$2) / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(t$95$3 * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(-0.3333333333333333 * N[(t$95$1 * N[Power[N[Cos[x], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(t$95$0 * N[(t$95$3 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * N[Power[N[Cos[x], $MachinePrecision], -4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[(0.3333333333333333 + t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\cos x}^{-2}\\
t_1 := {\sin x}^{3}\\
t_2 := {\sin x}^{4}\\
t_3 := {\sin x}^{2}\\
t_4 := t_3 \cdot t_0\\
\left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left(t_4 - \mathsf{fma}\left(-0.3333333333333333, t_4, \frac{-t_2}{{\cos x}^{4}}\right)\right), \varepsilon \cdot \mathsf{fma}\left(t_3, t_0, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, t_1 \cdot {\cos x}^{-3}, \tan x \cdot \left(t_0 \cdot \left(t_3 \cdot -0.3333333333333333\right) - t_2 \cdot {\cos x}^{-4}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + t_4}}\right)\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{t_1}{{\cos x}^{3}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. tan-sum62.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. div-inv62.9%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. *-un-lft-identity62.9%

      \[\leadsto \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \color{blue}{1 \cdot \tan x} \]
    4. prod-diff62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right)} \]
    5. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    6. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{\tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    7. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
    8. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{\tan x}\right) \]
  3. Applied egg-rr62.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right)} \]
    2. fma-udef62.9%

      \[\leadsto \mathsf{fma}\left(-\tan x, 1, \tan x\right) + \color{blue}{\left(\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} + \left(-\tan x\right)\right)} \]
    3. associate-+r+62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right)} \]
    4. unsub-neg62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) - \tan x} \]
  5. Simplified62.8%

    \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x} \]
  6. Taylor expanded in eps around 0 99.7%

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

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\mathsf{fma}\left(-0.3333333333333333, \frac{\sin x}{\cos x}, \mathsf{fma}\left(-0.3333333333333333, \frac{{\sin x}^{3}}{{\cos x}^{3}}, \frac{\sin x}{\frac{\cos x}{\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)} \]
  8. Step-by-step derivation
    1. fma-udef99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \frac{\sin x}{\cos x} + \mathsf{fma}\left(-0.3333333333333333, \frac{{\sin x}^{3}}{{\cos x}^{3}}, \frac{\sin x}{\frac{\cos x}{\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}}\right)\right)} - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    2. tan-quot99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \color{blue}{\tan x} + \mathsf{fma}\left(-0.3333333333333333, \frac{{\sin x}^{3}}{{\cos x}^{3}}, \frac{\sin x}{\frac{\cos x}{\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    3. div-inv99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, \color{blue}{{\sin x}^{3} \cdot \frac{1}{{\cos x}^{3}}}, \frac{\sin x}{\frac{\cos x}{\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    4. pow-flip99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot \color{blue}{{\cos x}^{\left(-3\right)}}, \frac{\sin x}{\frac{\cos x}{\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    5. metadata-eval99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{\color{blue}{-3}}, \frac{\sin x}{\frac{\cos x}{\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    6. associate-/r/99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \color{blue}{\frac{\sin x}{\cos x} \cdot \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    7. tan-quot99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \color{blue}{\tan x} \cdot \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    8. div-inv99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \color{blue}{\left(-{\sin x}^{4}\right) \cdot \frac{1}{{\cos x}^{4}}}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
  9. Applied egg-rr99.7%

    \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \left(-{\sin x}^{4}\right) \cdot {\cos x}^{-4}\right)\right)\right)} - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
  10. Step-by-step derivation
    1. fma-udef99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \color{blue}{\left(-0.3333333333333333 \cdot \left({\sin x}^{2} \cdot {\cos x}^{-2}\right) + \left(-{\sin x}^{4}\right) \cdot {\cos x}^{-4}\right)}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    2. distribute-lft-neg-out99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \left(-0.3333333333333333 \cdot \left({\sin x}^{2} \cdot {\cos x}^{-2}\right) + \color{blue}{\left(-{\sin x}^{4} \cdot {\cos x}^{-4}\right)}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
  11. Applied egg-rr99.7%

    \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \color{blue}{\left(-0.3333333333333333 \cdot \left({\sin x}^{2} \cdot {\cos x}^{-2}\right) + \left(-{\sin x}^{4} \cdot {\cos x}^{-4}\right)\right)}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
  12. Step-by-step derivation
    1. unsub-neg99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \color{blue}{\left(-0.3333333333333333 \cdot \left({\sin x}^{2} \cdot {\cos x}^{-2}\right) - {\sin x}^{4} \cdot {\cos x}^{-4}\right)}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
    2. associate-*r*99.7%

      \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot {\sin x}^{2}\right) \cdot {\cos x}^{-2}} - {\sin x}^{4} \cdot {\cos x}^{-4}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
  13. Simplified99.7%

    \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \color{blue}{\left(\left(-0.3333333333333333 \cdot {\sin x}^{2}\right) \cdot {\cos x}^{-2} - {\sin x}^{4} \cdot {\cos x}^{-4}\right)}\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]
  14. Final simplification99.7%

    \[\leadsto \left(\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left({\sin x}^{2} \cdot {\cos x}^{-2} - \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{4} \cdot \left(\left(-0.3333333333333333 \cdot \tan x + \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{3} \cdot {\cos x}^{-3}, \tan x \cdot \left({\cos x}^{-2} \cdot \left({\sin x}^{2} \cdot -0.3333333333333333\right) - {\sin x}^{4} \cdot {\cos x}^{-4}\right)\right)\right) - \frac{\sin x}{\frac{\cos x}{0.3333333333333333 + {\sin x}^{2} \cdot {\cos x}^{-2}}}\right)\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]

Alternative 3: 99.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{\sin x}^{3}}{{\cos x}^{3}}\\ t_1 := \frac{\sin x}{\cos x}\\ t_2 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ t_3 := \frac{{\sin x}^{4}}{{\cos x}^{4}} - t_2 \cdot -0.3333333333333333\\ {\varepsilon}^{2} \cdot \left(t_1 + t_0\right) + \left({\varepsilon}^{4} \cdot \left(\frac{\sin x \cdot \left(t_2 + 0.3333333333333333\right)}{\cos x} + \left(\left(\frac{\sin x \cdot t_3}{\cos x} - -0.3333333333333333 \cdot t_0\right) - t_1 \cdot -0.3333333333333333\right)\right) + \left(\varepsilon \cdot \left(1 + t_2\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(t_2 + t_3\right)\right)\right)\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))
        (t_1 (/ (sin x) (cos x)))
        (t_2 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))
        (t_3
         (-
          (/ (pow (sin x) 4.0) (pow (cos x) 4.0))
          (* t_2 -0.3333333333333333))))
   (+
    (* (pow eps 2.0) (+ t_1 t_0))
    (+
     (*
      (pow eps 4.0)
      (+
       (/ (* (sin x) (+ t_2 0.3333333333333333)) (cos x))
       (-
        (- (/ (* (sin x) t_3) (cos x)) (* -0.3333333333333333 t_0))
        (* t_1 -0.3333333333333333))))
     (+
      (* eps (+ 1.0 t_2))
      (* (pow eps 3.0) (+ 0.3333333333333333 (+ t_2 t_3))))))))
double code(double x, double eps) {
	double t_0 = pow(sin(x), 3.0) / pow(cos(x), 3.0);
	double t_1 = sin(x) / cos(x);
	double t_2 = pow(sin(x), 2.0) / pow(cos(x), 2.0);
	double t_3 = (pow(sin(x), 4.0) / pow(cos(x), 4.0)) - (t_2 * -0.3333333333333333);
	return (pow(eps, 2.0) * (t_1 + t_0)) + ((pow(eps, 4.0) * (((sin(x) * (t_2 + 0.3333333333333333)) / cos(x)) + ((((sin(x) * t_3) / cos(x)) - (-0.3333333333333333 * t_0)) - (t_1 * -0.3333333333333333)))) + ((eps * (1.0 + t_2)) + (pow(eps, 3.0) * (0.3333333333333333 + (t_2 + t_3)))));
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    t_0 = (sin(x) ** 3.0d0) / (cos(x) ** 3.0d0)
    t_1 = sin(x) / cos(x)
    t_2 = (sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)
    t_3 = ((sin(x) ** 4.0d0) / (cos(x) ** 4.0d0)) - (t_2 * (-0.3333333333333333d0))
    code = ((eps ** 2.0d0) * (t_1 + t_0)) + (((eps ** 4.0d0) * (((sin(x) * (t_2 + 0.3333333333333333d0)) / cos(x)) + ((((sin(x) * t_3) / cos(x)) - ((-0.3333333333333333d0) * t_0)) - (t_1 * (-0.3333333333333333d0))))) + ((eps * (1.0d0 + t_2)) + ((eps ** 3.0d0) * (0.3333333333333333d0 + (t_2 + t_3)))))
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0);
	double t_1 = Math.sin(x) / Math.cos(x);
	double t_2 = Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0);
	double t_3 = (Math.pow(Math.sin(x), 4.0) / Math.pow(Math.cos(x), 4.0)) - (t_2 * -0.3333333333333333);
	return (Math.pow(eps, 2.0) * (t_1 + t_0)) + ((Math.pow(eps, 4.0) * (((Math.sin(x) * (t_2 + 0.3333333333333333)) / Math.cos(x)) + ((((Math.sin(x) * t_3) / Math.cos(x)) - (-0.3333333333333333 * t_0)) - (t_1 * -0.3333333333333333)))) + ((eps * (1.0 + t_2)) + (Math.pow(eps, 3.0) * (0.3333333333333333 + (t_2 + t_3)))));
}
def code(x, eps):
	t_0 = math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)
	t_1 = math.sin(x) / math.cos(x)
	t_2 = math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)
	t_3 = (math.pow(math.sin(x), 4.0) / math.pow(math.cos(x), 4.0)) - (t_2 * -0.3333333333333333)
	return (math.pow(eps, 2.0) * (t_1 + t_0)) + ((math.pow(eps, 4.0) * (((math.sin(x) * (t_2 + 0.3333333333333333)) / math.cos(x)) + ((((math.sin(x) * t_3) / math.cos(x)) - (-0.3333333333333333 * t_0)) - (t_1 * -0.3333333333333333)))) + ((eps * (1.0 + t_2)) + (math.pow(eps, 3.0) * (0.3333333333333333 + (t_2 + t_3)))))
function code(x, eps)
	t_0 = Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))
	t_1 = Float64(sin(x) / cos(x))
	t_2 = Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))
	t_3 = Float64(Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - Float64(t_2 * -0.3333333333333333))
	return Float64(Float64((eps ^ 2.0) * Float64(t_1 + t_0)) + Float64(Float64((eps ^ 4.0) * Float64(Float64(Float64(sin(x) * Float64(t_2 + 0.3333333333333333)) / cos(x)) + Float64(Float64(Float64(Float64(sin(x) * t_3) / cos(x)) - Float64(-0.3333333333333333 * t_0)) - Float64(t_1 * -0.3333333333333333)))) + Float64(Float64(eps * Float64(1.0 + t_2)) + Float64((eps ^ 3.0) * Float64(0.3333333333333333 + Float64(t_2 + t_3))))))
end
function tmp = code(x, eps)
	t_0 = (sin(x) ^ 3.0) / (cos(x) ^ 3.0);
	t_1 = sin(x) / cos(x);
	t_2 = (sin(x) ^ 2.0) / (cos(x) ^ 2.0);
	t_3 = ((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - (t_2 * -0.3333333333333333);
	tmp = ((eps ^ 2.0) * (t_1 + t_0)) + (((eps ^ 4.0) * (((sin(x) * (t_2 + 0.3333333333333333)) / cos(x)) + ((((sin(x) * t_3) / cos(x)) - (-0.3333333333333333 * t_0)) - (t_1 * -0.3333333333333333)))) + ((eps * (1.0 + t_2)) + ((eps ^ 3.0) * (0.3333333333333333 + (t_2 + t_3)))));
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] * N[(t$95$2 + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[Sin[x], $MachinePrecision] * t$95$3), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(-0.3333333333333333 * t$95$0), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 + N[(t$95$2 + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{3}}{{\cos x}^{3}}\\
t_1 := \frac{\sin x}{\cos x}\\
t_2 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_3 := \frac{{\sin x}^{4}}{{\cos x}^{4}} - t_2 \cdot -0.3333333333333333\\
{\varepsilon}^{2} \cdot \left(t_1 + t_0\right) + \left({\varepsilon}^{4} \cdot \left(\frac{\sin x \cdot \left(t_2 + 0.3333333333333333\right)}{\cos x} + \left(\left(\frac{\sin x \cdot t_3}{\cos x} - -0.3333333333333333 \cdot t_0\right) - t_1 \cdot -0.3333333333333333\right)\right) + \left(\varepsilon \cdot \left(1 + t_2\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(t_2 + t_3\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. tan-sum62.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. div-inv62.9%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. *-un-lft-identity62.9%

      \[\leadsto \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \color{blue}{1 \cdot \tan x} \]
    4. prod-diff62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right)} \]
    5. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    6. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{\tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    7. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
    8. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{\tan x}\right) \]
  3. Applied egg-rr62.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right)} \]
    2. fma-udef62.9%

      \[\leadsto \mathsf{fma}\left(-\tan x, 1, \tan x\right) + \color{blue}{\left(\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} + \left(-\tan x\right)\right)} \]
    3. associate-+r+62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right)} \]
    4. unsub-neg62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) - \tan x} \]
  5. Simplified62.8%

    \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x} \]
  6. Taylor expanded in eps around 0 99.7%

    \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{2} \cdot \left(-1 \cdot \frac{\sin x}{\cos x} + -1 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right) + \left(-1 \cdot \left({\varepsilon}^{4} \cdot \left(-1 \cdot \frac{\sin x \cdot \left(0.3333333333333333 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{\cos x} + \left(-0.3333333333333333 \cdot \frac{\sin x}{\cos x} + \left(-0.3333333333333333 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}} + \frac{\sin x \cdot \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{\cos x}\right)\right)\right)\right) + \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)\right)} \]
  7. Final simplification99.7%

    \[\leadsto {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) + \left({\varepsilon}^{4} \cdot \left(\frac{\sin x \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 0.3333333333333333\right)}{\cos x} + \left(\left(\frac{\sin x \cdot \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot -0.3333333333333333\right)}{\cos x} - -0.3333333333333333 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) - \frac{\sin x}{\cos x} \cdot -0.3333333333333333\right)\right) + \left(\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot -0.3333333333333333\right)\right)\right)\right)\right) \]

Alternative 4: 99.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ t_1 := 1 + t_0\\ t_2 := \frac{\sin x}{\cos x}\\ t_3 := -1 - t_0\\ \mathsf{fma}\left(\varepsilon, t_1, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_1}}\right) + \left({\varepsilon}^{4} \cdot \left(-0.3333333333333333 \cdot \left(t_2 \cdot t_3\right) - t_2 \cdot -0.3333333333333333\right) - {\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, t_1, t_0 \cdot 0.16666666666666666\right) + t_0 \cdot t_3\right)\right)\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))
        (t_1 (+ 1.0 t_0))
        (t_2 (/ (sin x) (cos x)))
        (t_3 (- -1.0 t_0)))
   (+
    (fma eps t_1 (/ (pow eps 2.0) (/ (/ (cos x) (sin x)) t_1)))
    (-
     (*
      (pow eps 4.0)
      (- (* -0.3333333333333333 (* t_2 t_3)) (* t_2 -0.3333333333333333)))
     (*
      (pow eps 3.0)
      (+
       0.16666666666666666
       (+ (fma -0.5 t_1 (* t_0 0.16666666666666666)) (* t_0 t_3))))))))
double code(double x, double eps) {
	double t_0 = pow(sin(x), 2.0) / pow(cos(x), 2.0);
	double t_1 = 1.0 + t_0;
	double t_2 = sin(x) / cos(x);
	double t_3 = -1.0 - t_0;
	return fma(eps, t_1, (pow(eps, 2.0) / ((cos(x) / sin(x)) / t_1))) + ((pow(eps, 4.0) * ((-0.3333333333333333 * (t_2 * t_3)) - (t_2 * -0.3333333333333333))) - (pow(eps, 3.0) * (0.16666666666666666 + (fma(-0.5, t_1, (t_0 * 0.16666666666666666)) + (t_0 * t_3)))));
}
function code(x, eps)
	t_0 = Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))
	t_1 = Float64(1.0 + t_0)
	t_2 = Float64(sin(x) / cos(x))
	t_3 = Float64(-1.0 - t_0)
	return Float64(fma(eps, t_1, Float64((eps ^ 2.0) / Float64(Float64(cos(x) / sin(x)) / t_1))) + Float64(Float64((eps ^ 4.0) * Float64(Float64(-0.3333333333333333 * Float64(t_2 * t_3)) - Float64(t_2 * -0.3333333333333333))) - Float64((eps ^ 3.0) * Float64(0.16666666666666666 + Float64(fma(-0.5, t_1, Float64(t_0 * 0.16666666666666666)) + Float64(t_0 * t_3))))))
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-1.0 - t$95$0), $MachinePrecision]}, N[(N[(eps * t$95$1 + N[(N[Power[eps, 2.0], $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(-0.3333333333333333 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.16666666666666666 + N[(N[(-0.5 * t$95$1 + N[(t$95$0 * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_1 := 1 + t_0\\
t_2 := \frac{\sin x}{\cos x}\\
t_3 := -1 - t_0\\
\mathsf{fma}\left(\varepsilon, t_1, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_1}}\right) + \left({\varepsilon}^{4} \cdot \left(-0.3333333333333333 \cdot \left(t_2 \cdot t_3\right) - t_2 \cdot -0.3333333333333333\right) - {\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, t_1, t_0 \cdot 0.16666666666666666\right) + t_0 \cdot t_3\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

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

    \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(-1 \cdot \frac{{\sin x}^{2} \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{{\cos x}^{2}} + \left(-0.5 \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right) + \left(-1 \cdot \left({\varepsilon}^{4} \cdot \left(-0.5 \cdot \frac{\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{\cos x} + \left(0.16666666666666666 \cdot \frac{\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{\cos x} + \frac{\sin x \cdot \left(0.16666666666666666 + \left(-1 \cdot \frac{{\sin x}^{2} \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{{\cos x}^{2}} + \left(-0.5 \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)}{\cos x}\right)\right)\right) + \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right)\right)} \]
  3. Simplified99.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}\right) - \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) + {\varepsilon}^{4} \cdot \left(\frac{\sin x}{\cos x} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) + \left(\frac{\sin x}{\cos x} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right) \cdot -0.3333333333333333\right)\right)} \]
  4. Taylor expanded in x around 0 99.6%

    \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}\right) - \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) + {\varepsilon}^{4} \cdot \left(\frac{\sin x}{\cos x} \cdot \color{blue}{-0.3333333333333333} + \left(\frac{\sin x}{\cos x} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right) \cdot -0.3333333333333333\right)\right) \]
  5. Final simplification99.6%

    \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}\right) + \left({\varepsilon}^{4} \cdot \left(-0.3333333333333333 \cdot \left(\frac{\sin x}{\cos x} \cdot \left(-1 - \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right) - \frac{\sin x}{\cos x} \cdot -0.3333333333333333\right) - {\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot 0.16666666666666666\right) + \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(-1 - \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right) \]

Alternative 5: 99.5% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_1 := 1 + t_0\\
\mathsf{fma}\left(\varepsilon, t_1, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{t_1}}{\sin x}}\right) - {\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, t_1, t_0 \cdot 0.16666666666666666\right) + t_0 \cdot \left(-1 - t_0\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

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

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

      \[\leadsto \color{blue}{\left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right) + -1 \cdot \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(-1 \cdot \frac{{\sin x}^{2} \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{{\cos x}^{2}} + \left(-0.5 \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)} \]
    2. mul-1-neg99.6%

      \[\leadsto \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right) + \color{blue}{\left(-{\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(-1 \cdot \frac{{\sin x}^{2} \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}{{\cos x}^{2}} + \left(-0.5 \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)} \]
  4. Simplified99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}{\sin x}}\right) - {\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, 0.16666666666666666 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)} \]
  5. Final simplification99.6%

    \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}{\sin x}}\right) - {\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\mathsf{fma}\left(-0.5, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot 0.16666666666666666\right) + \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \left(-1 - \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right) \]

Alternative 6: 99.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin x}^{2}\\ t_1 := {\cos x}^{2}\\ t_2 := \frac{t_0}{t_1}\\ \mathsf{fma}\left(-1, \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \cdot \left(-{\varepsilon}^{2}\right), \mathsf{fma}\left(\varepsilon, 1 + t_2, {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \mathsf{fma}\left(-1, t_2, \mathsf{fma}\left(-1, \frac{{\sin x}^{4}}{{\cos x}^{4}}, \frac{t_0 \cdot -0.3333333333333333}{t_1}\right)\right)\right)\right)\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (pow (sin x) 2.0)) (t_1 (pow (cos x) 2.0)) (t_2 (/ t_0 t_1)))
   (fma
    -1.0
    (*
     (+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))
     (- (pow eps 2.0)))
    (fma
     eps
     (+ 1.0 t_2)
     (*
      (pow eps 3.0)
      (-
       0.3333333333333333
       (fma
        -1.0
        t_2
        (fma
         -1.0
         (/ (pow (sin x) 4.0) (pow (cos x) 4.0))
         (/ (* t_0 -0.3333333333333333) t_1)))))))))
double code(double x, double eps) {
	double t_0 = pow(sin(x), 2.0);
	double t_1 = pow(cos(x), 2.0);
	double t_2 = t_0 / t_1;
	return fma(-1.0, (((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))) * -pow(eps, 2.0)), fma(eps, (1.0 + t_2), (pow(eps, 3.0) * (0.3333333333333333 - fma(-1.0, t_2, fma(-1.0, (pow(sin(x), 4.0) / pow(cos(x), 4.0)), ((t_0 * -0.3333333333333333) / t_1)))))));
}
function code(x, eps)
	t_0 = sin(x) ^ 2.0
	t_1 = cos(x) ^ 2.0
	t_2 = Float64(t_0 / t_1)
	return fma(-1.0, Float64(Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))) * Float64(-(eps ^ 2.0))), fma(eps, Float64(1.0 + t_2), Float64((eps ^ 3.0) * Float64(0.3333333333333333 - fma(-1.0, t_2, fma(-1.0, Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0)), Float64(Float64(t_0 * -0.3333333333333333) / t_1)))))))
end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / t$95$1), $MachinePrecision]}, N[(-1.0 * N[(N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-N[Power[eps, 2.0], $MachinePrecision])), $MachinePrecision] + N[(eps * N[(1.0 + t$95$2), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 - N[(-1.0 * t$95$2 + N[(-1.0 * N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * -0.3333333333333333), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := {\cos x}^{2}\\
t_2 := \frac{t_0}{t_1}\\
\mathsf{fma}\left(-1, \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \cdot \left(-{\varepsilon}^{2}\right), \mathsf{fma}\left(\varepsilon, 1 + t_2, {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \mathsf{fma}\left(-1, t_2, \mathsf{fma}\left(-1, \frac{{\sin x}^{4}}{{\cos x}^{4}}, \frac{t_0 \cdot -0.3333333333333333}{t_1}\right)\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. tan-sum62.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. div-inv62.9%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. *-un-lft-identity62.9%

      \[\leadsto \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \color{blue}{1 \cdot \tan x} \]
    4. prod-diff62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right)} \]
    5. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    6. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{\tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    7. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
    8. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{\tan x}\right) \]
  3. Applied egg-rr62.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right)} \]
    2. fma-udef62.9%

      \[\leadsto \mathsf{fma}\left(-\tan x, 1, \tan x\right) + \color{blue}{\left(\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} + \left(-\tan x\right)\right)} \]
    3. associate-+r+62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right)} \]
    4. unsub-neg62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) - \tan x} \]
  5. Simplified62.8%

    \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x} \]
  6. Taylor expanded in eps around 0 99.6%

    \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{2} \cdot \left(-1 \cdot \frac{\sin x}{\cos x} + -1 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right) + \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)} \]
  7. Step-by-step derivation
    1. fma-def99.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {\varepsilon}^{2} \cdot \left(-1 \cdot \frac{\sin x}{\cos x} + -1 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}}\right), \varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)} \]
    2. distribute-lft-out99.6%

      \[\leadsto \mathsf{fma}\left(-1, {\varepsilon}^{2} \cdot \color{blue}{\left(-1 \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right)}, \varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right) \]
    3. fma-def99.6%

      \[\leadsto \mathsf{fma}\left(-1, {\varepsilon}^{2} \cdot \left(-1 \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right), \color{blue}{\mathsf{fma}\left(\varepsilon, 1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}, {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)}\right) \]
  8. Simplified99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {\varepsilon}^{2} \cdot \left(-1 \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right), \mathsf{fma}\left(\varepsilon, 1 - \left(-\frac{{\sin x}^{2}}{{\cos x}^{2}}\right), {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \mathsf{fma}\left(-1, \frac{{\sin x}^{2}}{{\cos x}^{2}}, \mathsf{fma}\left(-1, \frac{{\sin x}^{4}}{{\cos x}^{4}}, \frac{-0.3333333333333333 \cdot {\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)\right)} \]
  9. Final simplification99.6%

    \[\leadsto \mathsf{fma}\left(-1, \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \cdot \left(-{\varepsilon}^{2}\right), \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \mathsf{fma}\left(-1, \frac{{\sin x}^{2}}{{\cos x}^{2}}, \mathsf{fma}\left(-1, \frac{{\sin x}^{4}}{{\cos x}^{4}}, \frac{{\sin x}^{2} \cdot -0.3333333333333333}{{\cos x}^{2}}\right)\right)\right)\right)\right) \]

Alternative 7: 99.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin x}^{2}\\ t_1 := {\cos x}^{-2}\\ t_2 := t_0 \cdot t_1\\ \mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left(t_2 - \mathsf{fma}\left(-0.3333333333333333, t_2, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)\right), \varepsilon \cdot \mathsf{fma}\left(t_0, t_1, 1\right)\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (pow (sin x) 2.0)) (t_1 (pow (cos x) -2.0)) (t_2 (* t_0 t_1)))
   (+
    (fma
     (pow eps 3.0)
     (+
      0.3333333333333333
      (-
       t_2
       (fma
        -0.3333333333333333
        t_2
        (/ (- (pow (sin x) 4.0)) (pow (cos x) 4.0)))))
     (* eps (fma t_0 t_1 1.0)))
    (*
     (pow eps 2.0)
     (+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))))
double code(double x, double eps) {
	double t_0 = pow(sin(x), 2.0);
	double t_1 = pow(cos(x), -2.0);
	double t_2 = t_0 * t_1;
	return fma(pow(eps, 3.0), (0.3333333333333333 + (t_2 - fma(-0.3333333333333333, t_2, (-pow(sin(x), 4.0) / pow(cos(x), 4.0))))), (eps * fma(t_0, t_1, 1.0))) + (pow(eps, 2.0) * ((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
}
function code(x, eps)
	t_0 = sin(x) ^ 2.0
	t_1 = cos(x) ^ -2.0
	t_2 = Float64(t_0 * t_1)
	return Float64(fma((eps ^ 3.0), Float64(0.3333333333333333 + Float64(t_2 - fma(-0.3333333333333333, t_2, Float64(Float64(-(sin(x) ^ 4.0)) / (cos(x) ^ 4.0))))), Float64(eps * fma(t_0, t_1, 1.0))) + Float64((eps ^ 2.0) * Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))))
end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Cos[x], $MachinePrecision], -2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, N[(N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 + N[(t$95$2 - N[(-0.3333333333333333 * t$95$2 + N[((-N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision]) / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(t$95$0 * t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := {\cos x}^{-2}\\
t_2 := t_0 \cdot t_1\\
\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left(t_2 - \mathsf{fma}\left(-0.3333333333333333, t_2, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)\right), \varepsilon \cdot \mathsf{fma}\left(t_0, t_1, 1\right)\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. tan-sum62.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. div-inv62.9%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. *-un-lft-identity62.9%

      \[\leadsto \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \color{blue}{1 \cdot \tan x} \]
    4. prod-diff62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right)} \]
    5. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    6. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{\tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    7. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
    8. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{\tan x}\right) \]
  3. Applied egg-rr62.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right)} \]
    2. fma-udef62.9%

      \[\leadsto \mathsf{fma}\left(-\tan x, 1, \tan x\right) + \color{blue}{\left(\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} + \left(-\tan x\right)\right)} \]
    3. associate-+r+62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right)} \]
    4. unsub-neg62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) - \tan x} \]
  5. Simplified62.8%

    \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x} \]
  6. Taylor expanded in eps around 0 99.6%

    \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{2} \cdot \left(-1 \cdot \frac{\sin x}{\cos x} + -1 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right) + \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)} \]
  7. Simplified99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 - \left(\mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right) - {\sin x}^{2} \cdot {\cos x}^{-2}\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) - {\varepsilon}^{2} \cdot \left(\frac{-\sin x}{\cos x} - \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)} \]
  8. Final simplification99.6%

    \[\leadsto \mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left({\sin x}^{2} \cdot {\cos x}^{-2} - \mathsf{fma}\left(-0.3333333333333333, {\sin x}^{2} \cdot {\cos x}^{-2}, \frac{-{\sin x}^{4}}{{\cos x}^{4}}\right)\right), \varepsilon \cdot \mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, 1\right)\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \]

Alternative 8: 99.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) + \left(\varepsilon \cdot \left(1 + t_0\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(t_0 + \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - t_0 \cdot -0.3333333333333333\right)\right)\right)\right) \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
   (+
    (*
     (pow eps 2.0)
     (+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0))))
    (+
     (* eps (+ 1.0 t_0))
     (*
      (pow eps 3.0)
      (+
       0.3333333333333333
       (+
        t_0
        (-
         (/ (pow (sin x) 4.0) (pow (cos x) 4.0))
         (* t_0 -0.3333333333333333)))))))))
double code(double x, double eps) {
	double t_0 = pow(sin(x), 2.0) / pow(cos(x), 2.0);
	return (pow(eps, 2.0) * ((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0)))) + ((eps * (1.0 + t_0)) + (pow(eps, 3.0) * (0.3333333333333333 + (t_0 + ((pow(sin(x), 4.0) / pow(cos(x), 4.0)) - (t_0 * -0.3333333333333333))))));
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    t_0 = (sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)
    code = ((eps ** 2.0d0) * ((sin(x) / cos(x)) + ((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0)))) + ((eps * (1.0d0 + t_0)) + ((eps ** 3.0d0) * (0.3333333333333333d0 + (t_0 + (((sin(x) ** 4.0d0) / (cos(x) ** 4.0d0)) - (t_0 * (-0.3333333333333333d0)))))))
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0);
	return (Math.pow(eps, 2.0) * ((Math.sin(x) / Math.cos(x)) + (Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0)))) + ((eps * (1.0 + t_0)) + (Math.pow(eps, 3.0) * (0.3333333333333333 + (t_0 + ((Math.pow(Math.sin(x), 4.0) / Math.pow(Math.cos(x), 4.0)) - (t_0 * -0.3333333333333333))))));
}
def code(x, eps):
	t_0 = math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)
	return (math.pow(eps, 2.0) * ((math.sin(x) / math.cos(x)) + (math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)))) + ((eps * (1.0 + t_0)) + (math.pow(eps, 3.0) * (0.3333333333333333 + (t_0 + ((math.pow(math.sin(x), 4.0) / math.pow(math.cos(x), 4.0)) - (t_0 * -0.3333333333333333))))))
function code(x, eps)
	t_0 = Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))
	return Float64(Float64((eps ^ 2.0) * Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))) + Float64(Float64(eps * Float64(1.0 + t_0)) + Float64((eps ^ 3.0) * Float64(0.3333333333333333 + Float64(t_0 + Float64(Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - Float64(t_0 * -0.3333333333333333)))))))
end
function tmp = code(x, eps)
	t_0 = (sin(x) ^ 2.0) / (cos(x) ^ 2.0);
	tmp = ((eps ^ 2.0) * ((sin(x) / cos(x)) + ((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))) + ((eps * (1.0 + t_0)) + ((eps ^ 3.0) * (0.3333333333333333 + (t_0 + (((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - (t_0 * -0.3333333333333333))))));
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 + N[(t$95$0 + N[(N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
{\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) + \left(\varepsilon \cdot \left(1 + t_0\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(t_0 + \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - t_0 \cdot -0.3333333333333333\right)\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. tan-sum62.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. div-inv62.9%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. *-un-lft-identity62.9%

      \[\leadsto \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \color{blue}{1 \cdot \tan x} \]
    4. prod-diff62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right)} \]
    5. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    6. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\color{blue}{\tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
    7. *-commutative62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
    8. *-un-lft-identity62.8%

      \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{\tan x}\right) \]
  3. Applied egg-rr62.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right)} \]
    2. fma-udef62.9%

      \[\leadsto \mathsf{fma}\left(-\tan x, 1, \tan x\right) + \color{blue}{\left(\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} + \left(-\tan x\right)\right)} \]
    3. associate-+r+62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right)} \]
    4. unsub-neg62.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) - \tan x} \]
  5. Simplified62.8%

    \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x} \]
  6. Taylor expanded in eps around 0 99.6%

    \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{2} \cdot \left(-1 \cdot \frac{\sin x}{\cos x} + -1 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right) + \left(\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 - \left(-1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)\right)\right)} \]
  7. Final simplification99.6%

    \[\leadsto {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) + \left(\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - \frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot -0.3333333333333333\right)\right)\right)\right) \]

Alternative 9: 99.3% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathsf{fma}\left(\varepsilon, t_0, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{t_0}}{\sin x}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 62.7%

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

    \[\leadsto \color{blue}{\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}} \]
  3. Step-by-step derivation
    1. fma-def99.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\varepsilon, 1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right)} \]
    2. cancel-sign-sub-inv99.4%

      \[\leadsto \mathsf{fma}\left(\varepsilon, \color{blue}{1 + \left(--1\right) \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}}, \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right) \]
    3. metadata-eval99.4%

      \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \color{blue}{1} \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right) \]
    4. *-lft-identity99.4%

      \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}}}, \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x}\right) \]
    5. associate-/l*99.4%

      \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \color{blue}{\frac{{\varepsilon}^{2}}{\frac{\cos x}{\sin x \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)}}}\right) \]
    6. *-commutative99.4%

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}{\sin x}}\right)} \]
  5. Final simplification99.4%

    \[\leadsto \mathsf{fma}\left(\varepsilon, 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}}}{\sin x}}\right) \]

Alternative 10: 99.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ \varepsilon \cdot t_0 + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot t_0\right)}{\cos x} \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))))
   (+ (* eps t_0) (/ (* (pow eps 2.0) (* (sin x) t_0)) (cos x)))))
double code(double x, double eps) {
	double t_0 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
	return (eps * t_0) + ((pow(eps, 2.0) * (sin(x) * t_0)) / cos(x));
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    t_0 = 1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0))
    code = (eps * t_0) + (((eps ** 2.0d0) * (sin(x) * t_0)) / cos(x))
end function
public static double code(double x, double eps) {
	double t_0 = 1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0));
	return (eps * t_0) + ((Math.pow(eps, 2.0) * (Math.sin(x) * t_0)) / Math.cos(x));
}
def code(x, eps):
	t_0 = 1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))
	return (eps * t_0) + ((math.pow(eps, 2.0) * (math.sin(x) * t_0)) / math.cos(x))
function code(x, eps)
	t_0 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))
	return Float64(Float64(eps * t_0) + Float64(Float64((eps ^ 2.0) * Float64(sin(x) * t_0)) / cos(x)))
end
function tmp = code(x, eps)
	t_0 = 1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0));
	tmp = (eps * t_0) + (((eps ^ 2.0) * (sin(x) * t_0)) / cos(x));
end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(eps * t$95$0), $MachinePrecision] + N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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

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

    \[\leadsto \varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right)}{\cos x} \]

Alternative 11: 98.9% accurate, 0.5× speedup?

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

\\
\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)
\end{array}
Derivation
  1. Initial program 62.7%

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

    \[\leadsto \color{blue}{\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)} \]
  3. Step-by-step derivation
    1. cancel-sign-sub-inv99.0%

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

      \[\leadsto \varepsilon \cdot \left(1 + \color{blue}{1} \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) \]
    3. *-lft-identity99.0%

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

    \[\leadsto \color{blue}{\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)} \]
  5. Final simplification99.0%

    \[\leadsto \varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) \]

Alternative 12: 97.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\sin \varepsilon}{\cos \varepsilon} \end{array} \]
(FPCore (x eps) :precision binary64 (/ (sin eps) (cos eps)))
double code(double x, double eps) {
	return sin(eps) / cos(eps);
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = sin(eps) / cos(eps)
end function
public static double code(double x, double eps) {
	return Math.sin(eps) / Math.cos(eps);
}
def code(x, eps):
	return math.sin(eps) / math.cos(eps)
function code(x, eps)
	return Float64(sin(eps) / cos(eps))
end
function tmp = code(x, eps)
	tmp = sin(eps) / cos(eps);
end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sin \varepsilon}{\cos \varepsilon}
\end{array}
Derivation
  1. Initial program 62.7%

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

    \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
  3. Final simplification98.2%

    \[\leadsto \frac{\sin \varepsilon}{\cos \varepsilon} \]

Alternative 13: 60.8% accurate, 2.0× speedup?

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

\\
\tan \left(\varepsilon + x\right) - x
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. *-un-lft-identity62.7%

      \[\leadsto \color{blue}{1 \cdot \tan \left(x + \varepsilon\right)} - \tan x \]
    2. *-commutative62.7%

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

      \[\leadsto \tan \left(x + \varepsilon\right) \cdot 1 - \color{blue}{\frac{\sin x}{\cos x}} \]
    4. div-inv62.7%

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan \left(x + \varepsilon\right), 1, -\frac{1}{\cos x} \cdot \sin x\right) + \mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \mathsf{fma}\left(\tan \left(x + \varepsilon\right), 1, -\frac{1}{\cos x} \cdot \sin x\right)} \]
    2. fma-udef62.7%

      \[\leadsto \mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \color{blue}{\left(\tan \left(x + \varepsilon\right) \cdot 1 + \left(-\frac{1}{\cos x} \cdot \sin x\right)\right)} \]
    3. *-rgt-identity62.7%

      \[\leadsto \mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \left(\color{blue}{\tan \left(x + \varepsilon\right)} + \left(-\frac{1}{\cos x} \cdot \sin x\right)\right) \]
    4. associate-+r+62.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \tan \left(x + \varepsilon\right)\right) + \left(-\frac{1}{\cos x} \cdot \sin x\right)} \]
    5. unsub-neg62.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \tan \left(x + \varepsilon\right)\right) - \frac{1}{\cos x} \cdot \sin x} \]
  5. Simplified62.7%

    \[\leadsto \color{blue}{\left(0 + \tan \left(\varepsilon + x\right)\right) - \frac{\sin x}{\cos x}} \]
  6. Taylor expanded in x around 0 61.3%

    \[\leadsto \left(0 + \tan \left(\varepsilon + x\right)\right) - \color{blue}{x} \]
  7. Step-by-step derivation
    1. +-lft-identity61.3%

      \[\leadsto \left(0 + \color{blue}{\left(0 + \tan \left(\varepsilon + x\right)\right)}\right) - x \]
    2. associate--l+61.3%

      \[\leadsto \color{blue}{0 + \left(\left(0 + \tan \left(\varepsilon + x\right)\right) - x\right)} \]
    3. +-lft-identity61.3%

      \[\leadsto 0 + \left(\color{blue}{\tan \left(\varepsilon + x\right)} - x\right) \]
    4. +-commutative61.3%

      \[\leadsto 0 + \left(\tan \color{blue}{\left(x + \varepsilon\right)} - x\right) \]
  8. Applied egg-rr61.3%

    \[\leadsto \color{blue}{0 + \left(\tan \left(x + \varepsilon\right) - x\right)} \]
  9. Step-by-step derivation
    1. +-lft-identity61.3%

      \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right) - x} \]
  10. Simplified61.3%

    \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right) - x} \]
  11. Final simplification61.3%

    \[\leadsto \tan \left(\varepsilon + x\right) - x \]

Alternative 14: 8.0% accurate, 102.5× speedup?

\[\begin{array}{l} \\ -x \end{array} \]
(FPCore (x eps) :precision binary64 (- x))
double code(double x, double eps) {
	return -x;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = -x
end function
public static double code(double x, double eps) {
	return -x;
}
def code(x, eps):
	return -x
function code(x, eps)
	return Float64(-x)
end
function tmp = code(x, eps)
	tmp = -x;
end
code[x_, eps_] := (-x)
\begin{array}{l}

\\
-x
\end{array}
Derivation
  1. Initial program 62.7%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Step-by-step derivation
    1. *-un-lft-identity62.7%

      \[\leadsto \color{blue}{1 \cdot \tan \left(x + \varepsilon\right)} - \tan x \]
    2. *-commutative62.7%

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

      \[\leadsto \tan \left(x + \varepsilon\right) \cdot 1 - \color{blue}{\frac{\sin x}{\cos x}} \]
    4. div-inv62.7%

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\tan \left(x + \varepsilon\right), 1, -\frac{1}{\cos x} \cdot \sin x\right) + \mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right)} \]
  4. Step-by-step derivation
    1. +-commutative62.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \mathsf{fma}\left(\tan \left(x + \varepsilon\right), 1, -\frac{1}{\cos x} \cdot \sin x\right)} \]
    2. fma-udef62.7%

      \[\leadsto \mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \color{blue}{\left(\tan \left(x + \varepsilon\right) \cdot 1 + \left(-\frac{1}{\cos x} \cdot \sin x\right)\right)} \]
    3. *-rgt-identity62.7%

      \[\leadsto \mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \left(\color{blue}{\tan \left(x + \varepsilon\right)} + \left(-\frac{1}{\cos x} \cdot \sin x\right)\right) \]
    4. associate-+r+62.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \tan \left(x + \varepsilon\right)\right) + \left(-\frac{1}{\cos x} \cdot \sin x\right)} \]
    5. unsub-neg62.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\frac{1}{\cos x}, \sin x, \frac{1}{\cos x} \cdot \sin x\right) + \tan \left(x + \varepsilon\right)\right) - \frac{1}{\cos x} \cdot \sin x} \]
  5. Simplified62.7%

    \[\leadsto \color{blue}{\left(0 + \tan \left(\varepsilon + x\right)\right) - \frac{\sin x}{\cos x}} \]
  6. Taylor expanded in x around 0 61.3%

    \[\leadsto \left(0 + \tan \left(\varepsilon + x\right)\right) - \color{blue}{x} \]
  7. Taylor expanded in x around inf 7.6%

    \[\leadsto \color{blue}{-1 \cdot x} \]
  8. Step-by-step derivation
    1. neg-mul-17.6%

      \[\leadsto \color{blue}{-x} \]
  9. Simplified7.6%

    \[\leadsto \color{blue}{-x} \]
  10. Final simplification7.6%

    \[\leadsto -x \]

Developer target: 99.9% accurate, 0.7× speedup?

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

\\
\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}
\end{array}

Reproduce

?
herbie shell --seed 2023333 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"
  :precision binary64
  :pre (and (and (and (<= -10000.0 x) (<= x 10000.0)) (< (* 1e-16 (fabs x)) eps)) (< eps (fabs x)))

  :herbie-target
  (/ (sin eps) (* (cos x) (cos (+ x eps))))

  (- (tan (+ x eps)) (tan x)))