2tan (problem 3.3.2)

Percentage Accurate: 42.5% → 99.6%
Time: 17.9s
Alternatives: 16
Speedup: 1.9×

Specification

?
\[\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 16 alternatives:

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

Initial Program: 42.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.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\cos x}^{3}\\ t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\ t_2 := {\sin x}^{2}\\ t_3 := {\cos x}^{2}\\ t_4 := -0.3333333333333333 \cdot \frac{t_2}{t_3}\\ t_5 := \tan x + \tan \varepsilon\\ t_6 := \frac{{\sin x}^{4}}{{\cos x}^{4}}\\ t_7 := {\sin x}^{3}\\ \mathbf{if}\;\varepsilon \leq -0.00025:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_5, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 0.000185:\\ \;\;\;\;\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} + \left({\varepsilon}^{3} \cdot \left(t_6 - t_4\right) + \left(\left(\frac{\varepsilon \cdot t_2}{t_3} + \frac{t_7 \cdot {\varepsilon}^{2}}{t_0}\right) - {\varepsilon}^{4} \cdot \left(-0.3333333333333333 \cdot \frac{t_7}{t_0} + \frac{\sin x \cdot \left(t_4 - t_6\right)}{\cos x}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_5}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (pow (cos x) 3.0))
        (t_1 (/ (sin eps) (cos eps)))
        (t_2 (pow (sin x) 2.0))
        (t_3 (pow (cos x) 2.0))
        (t_4 (* -0.3333333333333333 (/ t_2 t_3)))
        (t_5 (+ (tan x) (tan eps)))
        (t_6 (/ (pow (sin x) 4.0) (pow (cos x) 4.0)))
        (t_7 (pow (sin x) 3.0)))
   (if (<= eps -0.00025)
     (fma (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_5 (- (tan x)))
     (if (<= eps 0.000185)
       (+
        (/ t_1 (- 1.0 (* t_1 (/ (sin x) (cos x)))))
        (+
         (* (pow eps 3.0) (- t_6 t_4))
         (-
          (+ (/ (* eps t_2) t_3) (/ (* t_7 (pow eps 2.0)) t_0))
          (*
           (pow eps 4.0)
           (+
            (* -0.3333333333333333 (/ t_7 t_0))
            (/ (* (sin x) (- t_4 t_6)) (cos x)))))))
       (- (/ t_5 (- 1.0 (/ (* (tan eps) (sin x)) (cos x)))) (tan x))))))
double code(double x, double eps) {
	double t_0 = pow(cos(x), 3.0);
	double t_1 = sin(eps) / cos(eps);
	double t_2 = pow(sin(x), 2.0);
	double t_3 = pow(cos(x), 2.0);
	double t_4 = -0.3333333333333333 * (t_2 / t_3);
	double t_5 = tan(x) + tan(eps);
	double t_6 = pow(sin(x), 4.0) / pow(cos(x), 4.0);
	double t_7 = pow(sin(x), 3.0);
	double tmp;
	if (eps <= -0.00025) {
		tmp = fma((1.0 / (1.0 - (tan(x) * tan(eps)))), t_5, -tan(x));
	} else if (eps <= 0.000185) {
		tmp = (t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) + ((pow(eps, 3.0) * (t_6 - t_4)) + ((((eps * t_2) / t_3) + ((t_7 * pow(eps, 2.0)) / t_0)) - (pow(eps, 4.0) * ((-0.3333333333333333 * (t_7 / t_0)) + ((sin(x) * (t_4 - t_6)) / cos(x))))));
	} else {
		tmp = (t_5 / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
	}
	return tmp;
}
function code(x, eps)
	t_0 = cos(x) ^ 3.0
	t_1 = Float64(sin(eps) / cos(eps))
	t_2 = sin(x) ^ 2.0
	t_3 = cos(x) ^ 2.0
	t_4 = Float64(-0.3333333333333333 * Float64(t_2 / t_3))
	t_5 = Float64(tan(x) + tan(eps))
	t_6 = Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0))
	t_7 = sin(x) ^ 3.0
	tmp = 0.0
	if (eps <= -0.00025)
		tmp = fma(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_5, Float64(-tan(x)));
	elseif (eps <= 0.000185)
		tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(t_1 * Float64(sin(x) / cos(x))))) + Float64(Float64((eps ^ 3.0) * Float64(t_6 - t_4)) + Float64(Float64(Float64(Float64(eps * t_2) / t_3) + Float64(Float64(t_7 * (eps ^ 2.0)) / t_0)) - Float64((eps ^ 4.0) * Float64(Float64(-0.3333333333333333 * Float64(t_7 / t_0)) + Float64(Float64(sin(x) * Float64(t_4 - t_6)) / cos(x)))))));
	else
		tmp = Float64(Float64(t_5 / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - tan(x));
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(-0.3333333333333333 * N[(t$95$2 / t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision]}, If[LessEqual[eps, -0.00025], N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$5 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 0.000185], N[(N[(t$95$1 / N[(1.0 - N[(t$95$1 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[eps, 3.0], $MachinePrecision] * N[(t$95$6 - t$95$4), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(eps * t$95$2), $MachinePrecision] / t$95$3), $MachinePrecision] + N[(N[(t$95$7 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(-0.3333333333333333 * N[(t$95$7 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[x], $MachinePrecision] * N[(t$95$4 - t$95$6), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$5 / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\cos x}^{3}\\
t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_2 := {\sin x}^{2}\\
t_3 := {\cos x}^{2}\\
t_4 := -0.3333333333333333 \cdot \frac{t_2}{t_3}\\
t_5 := \tan x + \tan \varepsilon\\
t_6 := \frac{{\sin x}^{4}}{{\cos x}^{4}}\\
t_7 := {\sin x}^{3}\\
\mathbf{if}\;\varepsilon \leq -0.00025:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_5, -\tan x\right)\\

\mathbf{elif}\;\varepsilon \leq 0.000185:\\
\;\;\;\;\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} + \left({\varepsilon}^{3} \cdot \left(t_6 - t_4\right) + \left(\left(\frac{\varepsilon \cdot t_2}{t_3} + \frac{t_7 \cdot {\varepsilon}^{2}}{t_0}\right) - {\varepsilon}^{4} \cdot \left(-0.3333333333333333 \cdot \frac{t_7}{t_0} + \frac{\sin x \cdot \left(t_4 - t_6\right)}{\cos x}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_5}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\


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

    1. Initial program 47.6%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.4%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. clear-num99.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
      2. associate-/r/99.3%

        \[\leadsto \color{blue}{\frac{1}{1 - \tan x \cdot \tan \varepsilon} \cdot \left(\tan x + \tan \varepsilon\right)} - \tan x \]
      3. fma-neg99.4%

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

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

    if -2.5000000000000001e-4 < eps < 1.85e-4

    1. Initial program 33.7%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr35.6%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/35.7%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified35.7%

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

      \[\leadsto \color{blue}{\left(\frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)} + \frac{\sin x}{\cos x \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)}\right) - \frac{\sin x}{\cos x}} \]
    7. Step-by-step derivation
      1. associate--l+63.4%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\frac{\sin x}{\cos x}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} - \frac{\sin x}{\cos x}\right)} \]
    9. Step-by-step derivation
      1. tan-quot62.1%

        \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\frac{\sin x}{\cos x}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} - \color{blue}{\tan x}\right) \]
      2. sub-neg62.1%

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

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

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

        \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\tan x}{1 - \tan \varepsilon \cdot \color{blue}{\tan x}} + \left(-\tan x\right)\right) \]
    10. Applied egg-rr63.5%

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

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

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

      \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \color{blue}{\left(\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x\right)} \]
    13. Taylor expanded in eps around 0 99.6%

      \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \color{blue}{\left(-1 \cdot \left({\varepsilon}^{3} \cdot \left(-1 \cdot \frac{{\sin x}^{4}}{{\cos x}^{4}} + -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\right) + \left(-1 \cdot \left({\varepsilon}^{4} \cdot \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) + \left(\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}} + \frac{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right)\right)\right)} \]

    if 1.85e-4 < eps

    1. Initial program 52.9%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.6%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.7%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\tan \varepsilon \cdot \tan x}} - \tan x \]
      2. tan-quot99.6%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos x}}} - \tan x \]
      3. associate-*r/99.7%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
    7. Applied egg-rr99.7%

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.00025:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, \tan x + \tan \varepsilon, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 0.000185:\\ \;\;\;\;\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left({\varepsilon}^{3} \cdot \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - -0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\left(\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}} + \frac{{\sin x}^{3} \cdot {\varepsilon}^{2}}{{\cos x}^{3}}\right) - {\varepsilon}^{4} \cdot \left(-0.3333333333333333 \cdot \frac{{\sin x}^{3}}{{\cos x}^{3}} + \frac{\sin x \cdot \left(-0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} - \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)}{\cos x}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \]

Alternative 2: 99.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin x}^{2}\\ t_1 := {\cos x}^{2}\\ t_2 := \frac{\sin \varepsilon}{\cos \varepsilon}\\ t_3 := \tan x + \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{t_3}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 6.5 \cdot 10^{-5}:\\ \;\;\;\;\frac{t_2}{1 - t_2 \cdot \frac{\sin x}{\cos x}} + \left(\left(\frac{\varepsilon \cdot t_0}{t_1} + \frac{{\sin x}^{3} \cdot {\varepsilon}^{2}}{{\cos x}^{3}}\right) - {\varepsilon}^{3} \cdot \left(-0.3333333333333333 \cdot \frac{t_0}{t_1} - \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_3}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \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 (/ (sin eps) (cos eps)))
        (t_3 (+ (tan x) (tan eps))))
   (if (<= eps -4.6e-5)
     (- (/ t_3 (- 1.0 (* (tan x) (tan eps)))) (tan x))
     (if (<= eps 6.5e-5)
       (+
        (/ t_2 (- 1.0 (* t_2 (/ (sin x) (cos x)))))
        (-
         (+
          (/ (* eps t_0) t_1)
          (/ (* (pow (sin x) 3.0) (pow eps 2.0)) (pow (cos x) 3.0)))
         (*
          (pow eps 3.0)
          (-
           (* -0.3333333333333333 (/ t_0 t_1))
           (/ (pow (sin x) 4.0) (pow (cos x) 4.0))))))
       (- (/ t_3 (- 1.0 (/ (* (tan eps) (sin x)) (cos x)))) (tan x))))))
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 = sin(eps) / cos(eps);
	double t_3 = tan(x) + tan(eps);
	double tmp;
	if (eps <= -4.6e-5) {
		tmp = (t_3 / (1.0 - (tan(x) * tan(eps)))) - tan(x);
	} else if (eps <= 6.5e-5) {
		tmp = (t_2 / (1.0 - (t_2 * (sin(x) / cos(x))))) + ((((eps * t_0) / t_1) + ((pow(sin(x), 3.0) * pow(eps, 2.0)) / pow(cos(x), 3.0))) - (pow(eps, 3.0) * ((-0.3333333333333333 * (t_0 / t_1)) - (pow(sin(x), 4.0) / pow(cos(x), 4.0)))));
	} else {
		tmp = (t_3 / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = sin(x) ** 2.0d0
    t_1 = cos(x) ** 2.0d0
    t_2 = sin(eps) / cos(eps)
    t_3 = tan(x) + tan(eps)
    if (eps <= (-4.6d-5)) then
        tmp = (t_3 / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
    else if (eps <= 6.5d-5) then
        tmp = (t_2 / (1.0d0 - (t_2 * (sin(x) / cos(x))))) + ((((eps * t_0) / t_1) + (((sin(x) ** 3.0d0) * (eps ** 2.0d0)) / (cos(x) ** 3.0d0))) - ((eps ** 3.0d0) * (((-0.3333333333333333d0) * (t_0 / t_1)) - ((sin(x) ** 4.0d0) / (cos(x) ** 4.0d0)))))
    else
        tmp = (t_3 / (1.0d0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow(Math.sin(x), 2.0);
	double t_1 = Math.pow(Math.cos(x), 2.0);
	double t_2 = Math.sin(eps) / Math.cos(eps);
	double t_3 = Math.tan(x) + Math.tan(eps);
	double tmp;
	if (eps <= -4.6e-5) {
		tmp = (t_3 / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
	} else if (eps <= 6.5e-5) {
		tmp = (t_2 / (1.0 - (t_2 * (Math.sin(x) / Math.cos(x))))) + ((((eps * t_0) / t_1) + ((Math.pow(Math.sin(x), 3.0) * Math.pow(eps, 2.0)) / Math.pow(Math.cos(x), 3.0))) - (Math.pow(eps, 3.0) * ((-0.3333333333333333 * (t_0 / t_1)) - (Math.pow(Math.sin(x), 4.0) / Math.pow(Math.cos(x), 4.0)))));
	} else {
		tmp = (t_3 / (1.0 - ((Math.tan(eps) * Math.sin(x)) / Math.cos(x)))) - Math.tan(x);
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow(math.sin(x), 2.0)
	t_1 = math.pow(math.cos(x), 2.0)
	t_2 = math.sin(eps) / math.cos(eps)
	t_3 = math.tan(x) + math.tan(eps)
	tmp = 0
	if eps <= -4.6e-5:
		tmp = (t_3 / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x)
	elif eps <= 6.5e-5:
		tmp = (t_2 / (1.0 - (t_2 * (math.sin(x) / math.cos(x))))) + ((((eps * t_0) / t_1) + ((math.pow(math.sin(x), 3.0) * math.pow(eps, 2.0)) / math.pow(math.cos(x), 3.0))) - (math.pow(eps, 3.0) * ((-0.3333333333333333 * (t_0 / t_1)) - (math.pow(math.sin(x), 4.0) / math.pow(math.cos(x), 4.0)))))
	else:
		tmp = (t_3 / (1.0 - ((math.tan(eps) * math.sin(x)) / math.cos(x)))) - math.tan(x)
	return tmp
function code(x, eps)
	t_0 = sin(x) ^ 2.0
	t_1 = cos(x) ^ 2.0
	t_2 = Float64(sin(eps) / cos(eps))
	t_3 = Float64(tan(x) + tan(eps))
	tmp = 0.0
	if (eps <= -4.6e-5)
		tmp = Float64(Float64(t_3 / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x));
	elseif (eps <= 6.5e-5)
		tmp = Float64(Float64(t_2 / Float64(1.0 - Float64(t_2 * Float64(sin(x) / cos(x))))) + Float64(Float64(Float64(Float64(eps * t_0) / t_1) + Float64(Float64((sin(x) ^ 3.0) * (eps ^ 2.0)) / (cos(x) ^ 3.0))) - Float64((eps ^ 3.0) * Float64(Float64(-0.3333333333333333 * Float64(t_0 / t_1)) - Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0))))));
	else
		tmp = Float64(Float64(t_3 / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - tan(x));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = sin(x) ^ 2.0;
	t_1 = cos(x) ^ 2.0;
	t_2 = sin(eps) / cos(eps);
	t_3 = tan(x) + tan(eps);
	tmp = 0.0;
	if (eps <= -4.6e-5)
		tmp = (t_3 / (1.0 - (tan(x) * tan(eps)))) - tan(x);
	elseif (eps <= 6.5e-5)
		tmp = (t_2 / (1.0 - (t_2 * (sin(x) / cos(x))))) + ((((eps * t_0) / t_1) + (((sin(x) ^ 3.0) * (eps ^ 2.0)) / (cos(x) ^ 3.0))) - ((eps ^ 3.0) * ((-0.3333333333333333 * (t_0 / t_1)) - ((sin(x) ^ 4.0) / (cos(x) ^ 4.0)))));
	else
		tmp = (t_3 / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
	end
	tmp_2 = tmp;
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[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.6e-5], N[(N[(t$95$3 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 6.5e-5], N[(N[(t$95$2 / N[(1.0 - N[(t$95$2 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(eps * t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 3.0], $MachinePrecision] * N[(N[(-0.3333333333333333 * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$3 / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := {\cos x}^{2}\\
t_2 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_3 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{t_3}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\

\mathbf{elif}\;\varepsilon \leq 6.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{t_2}{1 - t_2 \cdot \frac{\sin x}{\cos x}} + \left(\left(\frac{\varepsilon \cdot t_0}{t_1} + \frac{{\sin x}^{3} \cdot {\varepsilon}^{2}}{{\cos x}^{3}}\right) - {\varepsilon}^{3} \cdot \left(-0.3333333333333333 \cdot \frac{t_0}{t_1} - \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_3}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -4.6e-5

    1. Initial program 47.0%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.2%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]

    if -4.6e-5 < eps < 6.49999999999999943e-5

    1. Initial program 34.0%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr35.2%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/35.2%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified35.2%

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

      \[\leadsto \color{blue}{\left(\frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)} + \frac{\sin x}{\cos x \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)}\right) - \frac{\sin x}{\cos x}} \]
    7. Step-by-step derivation
      1. associate--l+63.2%

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

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

        \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}}} + \left(\frac{\sin x}{\cos x \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)} - \frac{\sin x}{\cos x}\right) \]
    8. Simplified63.3%

      \[\leadsto \color{blue}{\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\frac{\sin x}{\cos x}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} - \frac{\sin x}{\cos x}\right)} \]
    9. Step-by-step derivation
      1. tan-quot62.0%

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

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

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

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

        \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\tan x}{1 - \tan \varepsilon \cdot \color{blue}{\tan x}} + \left(-\tan x\right)\right) \]
    10. Applied egg-rr63.3%

      \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \color{blue}{\left(\frac{\tan x}{1 - \tan \varepsilon \cdot \tan x} + \left(-\tan x\right)\right)} \]
    11. Step-by-step derivation
      1. sub-neg63.3%

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

        \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\tan x}{1 - \color{blue}{\tan x \cdot \tan \varepsilon}} - \tan x\right) \]
    12. Simplified63.3%

      \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \color{blue}{\left(\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x\right)} \]
    13. Taylor expanded in eps around 0 99.5%

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

    if 6.49999999999999943e-5 < eps

    1. Initial program 52.9%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.6%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.7%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\tan \varepsilon \cdot \tan x}} - \tan x \]
      2. tan-quot99.6%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos x}}} - \tan x \]
      3. associate-*r/99.7%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
    7. Applied egg-rr99.7%

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 6.5 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\left(\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}} + \frac{{\sin x}^{3} \cdot {\varepsilon}^{2}}{{\cos x}^{3}}\right) - {\varepsilon}^{3} \cdot \left(-0.3333333333333333 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}} - \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \]

Alternative 3: 99.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\\ t_1 := \tan x + \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -1.55 \cdot 10^{-7}:\\ \;\;\;\;\frac{t_1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 3.1 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(\varepsilon, t_0, \frac{{\varepsilon}^{2}}{\cos x} \cdot \left(\sin x \cdot t_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
        (t_1 (+ (tan x) (tan eps))))
   (if (<= eps -1.55e-7)
     (- (/ t_1 (- 1.0 (* (tan x) (tan eps)))) (tan x))
     (if (<= eps 3.1e-7)
       (fma eps t_0 (* (/ (pow eps 2.0) (cos x)) (* (sin x) t_0)))
       (- (/ t_1 (- 1.0 (/ (* (tan eps) (sin x)) (cos x)))) (tan x))))))
double code(double x, double eps) {
	double t_0 = (pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0;
	double t_1 = tan(x) + tan(eps);
	double tmp;
	if (eps <= -1.55e-7) {
		tmp = (t_1 / (1.0 - (tan(x) * tan(eps)))) - tan(x);
	} else if (eps <= 3.1e-7) {
		tmp = fma(eps, t_0, ((pow(eps, 2.0) / cos(x)) * (sin(x) * t_0)));
	} else {
		tmp = (t_1 / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)
	t_1 = Float64(tan(x) + tan(eps))
	tmp = 0.0
	if (eps <= -1.55e-7)
		tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x));
	elseif (eps <= 3.1e-7)
		tmp = fma(eps, t_0, Float64(Float64((eps ^ 2.0) / cos(x)) * Float64(sin(x) * t_0)));
	else
		tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - tan(x));
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.55e-7], N[(N[(t$95$1 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.1e-7], N[(eps * t$95$0 + N[(N[(N[Power[eps, 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.55 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\

\mathbf{elif}\;\varepsilon \leq 3.1 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, t_0, \frac{{\varepsilon}^{2}}{\cos x} \cdot \left(\sin x \cdot t_0\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -1.55e-7

    1. Initial program 47.0%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.2%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]

    if -1.55e-7 < eps < 3.1e-7

    1. Initial program 34.2%

      \[\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. associate-/r/99.4%

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

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

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

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

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

    if 3.1e-7 < eps

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.4%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\tan \varepsilon \cdot \tan x}} - \tan x \]
      2. tan-quot99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos x}}} - \tan x \]
      3. associate-*r/99.5%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
    7. Applied egg-rr99.5%

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -1.55 \cdot 10^{-7}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 3.1 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(\varepsilon, \frac{{\sin x}^{2}}{{\cos x}^{2}} + 1, \frac{{\varepsilon}^{2}}{\cos x} \cdot \left(\sin x \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \]

Alternative 4: 99.5% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_0}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\

\mathbf{elif}\;\varepsilon \leq 6.2 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -3.3000000000000002e-7

    1. Initial program 47.0%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.2%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]

    if -3.3000000000000002e-7 < eps < 6.1999999999999999e-7

    1. Initial program 34.2%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/34.8%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity34.8%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified34.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.4%

      \[\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) + \varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)} \]
    7. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(1 - -1 \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + -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)} \]
      2. mul-1-neg99.4%

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

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

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

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

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

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

    if 6.1999999999999999e-7 < eps

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.4%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\tan \varepsilon \cdot \tan x}} - \tan x \]
      2. tan-quot99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos x}}} - \tan x \]
      3. associate-*r/99.5%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
    7. Applied egg-rr99.5%

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-7}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 6.2 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \]

Alternative 5: 99.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\ t_1 := \tan x + \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_1, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 7.3 \cdot 10^{-9}:\\ \;\;\;\;\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (/ (sin eps) (cos eps))) (t_1 (+ (tan x) (tan eps))))
   (if (<= eps -4.8e-9)
     (fma (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_1 (- (tan x)))
     (if (<= eps 7.3e-9)
       (+
        (/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
        (/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
       (- (/ t_1 (- 1.0 (/ (* (tan eps) (sin x)) (cos x)))) (tan x))))))
double code(double x, double eps) {
	double t_0 = sin(eps) / cos(eps);
	double t_1 = tan(x) + tan(eps);
	double tmp;
	if (eps <= -4.8e-9) {
		tmp = fma((1.0 / (1.0 - (tan(x) * tan(eps)))), t_1, -tan(x));
	} else if (eps <= 7.3e-9) {
		tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
	} else {
		tmp = (t_1 / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64(sin(eps) / cos(eps))
	t_1 = Float64(tan(x) + tan(eps))
	tmp = 0.0
	if (eps <= -4.8e-9)
		tmp = fma(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_1, Float64(-tan(x)));
	elseif (eps <= 7.3e-9)
		tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)));
	else
		tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - tan(x));
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.8e-9], N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 7.3e-9], N[(N[(t$95$0 / N[(1.0 - N[(t$95$0 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_1, -\tan x\right)\\

\mathbf{elif}\;\varepsilon \leq 7.3 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -4.8e-9

    1. Initial program 47.1%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/98.8%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity98.8%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. clear-num98.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
      2. associate-/r/98.7%

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

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

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

    if -4.8e-9 < eps < 7.30000000000000002e-9

    1. Initial program 34.1%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr34.4%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/34.5%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity34.5%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified34.5%

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

      \[\leadsto \color{blue}{\left(\frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)} + \frac{\sin x}{\cos x \cdot \left(1 - \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}\right)}\right) - \frac{\sin x}{\cos x}} \]
    7. Step-by-step derivation
      1. associate--l+63.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\frac{\sin x}{\cos x}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} - \frac{\sin x}{\cos x}\right)} \]
    9. Taylor expanded in eps around 0 99.5%

      \[\leadsto \frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \color{blue}{\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}} \]

    if 7.30000000000000002e-9 < eps

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.4%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\tan \varepsilon \cdot \tan x}} - \tan x \]
      2. tan-quot99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos x}}} - \tan x \]
      3. associate-*r/99.5%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
    7. Applied egg-rr99.5%

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, \tan x + \tan \varepsilon, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 7.3 \cdot 10^{-9}:\\ \;\;\;\;\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \]

Alternative 6: 99.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan x + \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -3.65 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_0, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (+ (tan x) (tan eps))))
   (if (<= eps -3.65e-9)
     (fma (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_0 (- (tan x)))
     (if (<= eps 3.2e-9)
       (* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
       (- (/ t_0 (- 1.0 (/ (* (tan eps) (sin x)) (cos x)))) (tan x))))))
double code(double x, double eps) {
	double t_0 = tan(x) + tan(eps);
	double tmp;
	if (eps <= -3.65e-9) {
		tmp = fma((1.0 / (1.0 - (tan(x) * tan(eps)))), t_0, -tan(x));
	} else if (eps <= 3.2e-9) {
		tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
	} else {
		tmp = (t_0 / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64(tan(x) + tan(eps))
	tmp = 0.0
	if (eps <= -3.65e-9)
		tmp = fma(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_0, Float64(-tan(x)));
	elseif (eps <= 3.2e-9)
		tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0));
	else
		tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - tan(x));
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.65e-9], N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 3.2e-9], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.65 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_0, -\tan x\right)\\

\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -3.65000000000000001e-9

    1. Initial program 47.1%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/98.8%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity98.8%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. clear-num98.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
      2. associate-/r/98.7%

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

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

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

    if -3.65000000000000001e-9 < eps < 3.20000000000000012e-9

    1. Initial program 34.1%

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

      \[\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.5%

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

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

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

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

    if 3.20000000000000012e-9 < eps

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.4%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. *-commutative99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\tan \varepsilon \cdot \tan x}} - \tan x \]
      2. tan-quot99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos x}}} - \tan x \]
      3. associate-*r/99.5%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
    7. Applied egg-rr99.5%

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan \varepsilon \cdot \sin x}{\cos x}}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -3.65 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, \tan x + \tan \varepsilon, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\ \end{array} \]

Alternative 7: 99.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \tan x \cdot \tan \varepsilon\\ t_1 := \tan x + \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -3.2 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{t_0}, t_1, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 4.8 \cdot 10^{-9}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{t_0} - \tan x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- 1.0 (* (tan x) (tan eps)))) (t_1 (+ (tan x) (tan eps))))
   (if (<= eps -3.2e-9)
     (fma (/ 1.0 t_0) t_1 (- (tan x)))
     (if (<= eps 4.8e-9)
       (* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
       (- (/ t_1 t_0) (tan x))))))
double code(double x, double eps) {
	double t_0 = 1.0 - (tan(x) * tan(eps));
	double t_1 = tan(x) + tan(eps);
	double tmp;
	if (eps <= -3.2e-9) {
		tmp = fma((1.0 / t_0), t_1, -tan(x));
	} else if (eps <= 4.8e-9) {
		tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
	} else {
		tmp = (t_1 / t_0) - tan(x);
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64(1.0 - Float64(tan(x) * tan(eps)))
	t_1 = Float64(tan(x) + tan(eps))
	tmp = 0.0
	if (eps <= -3.2e-9)
		tmp = fma(Float64(1.0 / t_0), t_1, Float64(-tan(x)));
	elseif (eps <= 4.8e-9)
		tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0));
	else
		tmp = Float64(Float64(t_1 / t_0) - tan(x));
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.2e-9], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 4.8e-9], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{t_0}, t_1, -\tan x\right)\\

\mathbf{elif}\;\varepsilon \leq 4.8 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - \tan x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -3.20000000000000012e-9

    1. Initial program 47.1%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/98.8%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity98.8%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    6. Step-by-step derivation
      1. clear-num98.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
      2. associate-/r/98.7%

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

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

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

    if -3.20000000000000012e-9 < eps < 4.8e-9

    1. Initial program 34.1%

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

      \[\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.5%

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

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

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

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

    if 4.8e-9 < eps

    1. Initial program 52.2%

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

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.4%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -3.2 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, \tan x + \tan \varepsilon, -\tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 4.8 \cdot 10^{-9}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \end{array} \]

Alternative 8: 99.3% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.62 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.1 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -1.61999999999999999e-9 or 3.10000000000000005e-9 < eps

    1. Initial program 49.7%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.0%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.1%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.1%

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]

    if -1.61999999999999999e-9 < eps < 3.10000000000000005e-9

    1. Initial program 34.1%

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

      \[\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.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -1.62 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.1 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\ \end{array} \]

Alternative 9: 78.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.0016:\\ \;\;\;\;\frac{1}{\frac{1}{\sin \left(\varepsilon + x\right)} \cdot \left(\cos \varepsilon - x \cdot \sin \varepsilon\right)} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-5}:\\ \;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= eps -0.0016)
   (-
    (/ 1.0 (* (/ 1.0 (sin (+ eps x))) (- (cos eps) (* x (sin eps)))))
    (tan x))
   (if (<= eps 5e-5)
     (* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
     (/ (sin eps) (cos eps)))))
double code(double x, double eps) {
	double tmp;
	if (eps <= -0.0016) {
		tmp = (1.0 / ((1.0 / sin((eps + x))) * (cos(eps) - (x * sin(eps))))) - tan(x);
	} else if (eps <= 5e-5) {
		tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
	} else {
		tmp = sin(eps) / cos(eps);
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: tmp
    if (eps <= (-0.0016d0)) then
        tmp = (1.0d0 / ((1.0d0 / sin((eps + x))) * (cos(eps) - (x * sin(eps))))) - tan(x)
    else if (eps <= 5d-5) then
        tmp = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
    else
        tmp = sin(eps) / cos(eps)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if (eps <= -0.0016) {
		tmp = (1.0 / ((1.0 / Math.sin((eps + x))) * (Math.cos(eps) - (x * Math.sin(eps))))) - Math.tan(x);
	} else if (eps <= 5e-5) {
		tmp = eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
	} else {
		tmp = Math.sin(eps) / Math.cos(eps);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if eps <= -0.0016:
		tmp = (1.0 / ((1.0 / math.sin((eps + x))) * (math.cos(eps) - (x * math.sin(eps))))) - math.tan(x)
	elif eps <= 5e-5:
		tmp = eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0)
	else:
		tmp = math.sin(eps) / math.cos(eps)
	return tmp
function code(x, eps)
	tmp = 0.0
	if (eps <= -0.0016)
		tmp = Float64(Float64(1.0 / Float64(Float64(1.0 / sin(Float64(eps + x))) * Float64(cos(eps) - Float64(x * sin(eps))))) - tan(x));
	elseif (eps <= 5e-5)
		tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0));
	else
		tmp = Float64(sin(eps) / cos(eps));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if (eps <= -0.0016)
		tmp = (1.0 / ((1.0 / sin((eps + x))) * (cos(eps) - (x * sin(eps))))) - tan(x);
	elseif (eps <= 5e-5)
		tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0);
	else
		tmp = sin(eps) / cos(eps);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[LessEqual[eps, -0.0016], N[(N[(1.0 / N[(N[(1.0 / N[Sin[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e-5], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0016:\\
\;\;\;\;\frac{1}{\frac{1}{\sin \left(\varepsilon + x\right)} \cdot \left(\cos \varepsilon - x \cdot \sin \varepsilon\right)} - \tan x\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if eps < -0.00160000000000000008

    1. Initial program 47.6%

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

        \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. clear-num99.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
    3. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
    4. Step-by-step derivation
      1. clear-num99.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}}}} - \tan x \]
      2. tan-sum47.6%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan \left(x + \varepsilon\right)}}} - \tan x \]
      3. tan-quot47.5%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{\sin \left(x + \varepsilon\right)}{\cos \left(x + \varepsilon\right)}}}} - \tan x \]
      4. associate-/r/47.5%

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

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

      \[\leadsto \frac{1}{\frac{1}{\sin \left(x + \varepsilon\right)} \cdot \color{blue}{\left(\cos \varepsilon + -1 \cdot \left(x \cdot \sin \varepsilon\right)\right)}} - \tan x \]
    7. Step-by-step derivation
      1. associate-*r*49.5%

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

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

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

    if -0.00160000000000000008 < eps < 5.00000000000000024e-5

    1. Initial program 33.7%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Taylor expanded in eps around 0 98.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-inv98.0%

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

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

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

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

    if 5.00000000000000024e-5 < eps

    1. Initial program 52.9%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.6%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.7%

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

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.7%

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

      \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.9%

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

Alternative 10: 78.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00023 \lor \neg \left(\varepsilon \leq 2.7 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -2.3000000000000001e-4 or 2.6999999999999999e-5 < eps

    1. Initial program 50.4%

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

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

        \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    3. Applied egg-rr99.5%

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    4. Step-by-step derivation
      1. associate-*r/99.5%

        \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. *-rgt-identity99.5%

        \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
    5. Simplified99.5%

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

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

    if -2.3000000000000001e-4 < eps < 2.6999999999999999e-5

    1. Initial program 33.7%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Taylor expanded in eps around 0 98.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-inv98.0%

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

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

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

      \[\leadsto \color{blue}{\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.9%

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

Alternative 11: 58.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 3.7 \cdot 10^{-5}\right):\\
\;\;\;\;\tan \varepsilon - \tan x\\

\mathbf{else}:\\
\;\;\;\;\varepsilon\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -6.9999999999999994e-5 or 3.69999999999999981e-5 < eps

    1. Initial program 50.4%

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

      \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} - \tan x \]
    3. Step-by-step derivation
      1. tan-quot53.0%

        \[\leadsto \color{blue}{\tan \varepsilon} - \tan x \]
      2. expm1-log1p-u40.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \varepsilon\right)\right)} - \tan x \]
      3. expm1-udef39.8%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan \varepsilon\right)} - 1\right)} - \tan x \]
    4. Applied egg-rr39.8%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan \varepsilon\right)} - 1\right)} - \tan x \]
    5. Step-by-step derivation
      1. expm1-def40.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \varepsilon\right)\right)} - \tan x \]
      2. expm1-log1p53.0%

        \[\leadsto \color{blue}{\tan \varepsilon} - \tan x \]
    6. Simplified53.0%

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

    if -6.9999999999999994e-5 < eps < 3.69999999999999981e-5

    1. Initial program 33.7%

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

        \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. clear-num35.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
    3. Applied egg-rr35.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
    4. Step-by-step derivation
      1. clear-num35.4%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}}}} - \tan x \]
      2. tan-sum33.4%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan \left(x + \varepsilon\right)}}} - \tan x \]
      3. tan-quot33.5%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{\sin \left(x + \varepsilon\right)}{\cos \left(x + \varepsilon\right)}}}} - \tan x \]
      4. associate-/r/33.6%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\sin \left(x + \varepsilon\right)} \cdot \cos \left(x + \varepsilon\right)}} - \tan x \]
    5. Applied egg-rr33.6%

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

      \[\leadsto \frac{1}{\frac{1}{\sin \left(x + \varepsilon\right)} \cdot \color{blue}{\cos x}} - \tan x \]
    7. Taylor expanded in eps around 0 61.5%

      \[\leadsto \color{blue}{\varepsilon} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -7 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 3.7 \cdot 10^{-5}\right):\\ \;\;\;\;\tan \varepsilon - \tan x\\ \mathbf{else}:\\ \;\;\;\;\varepsilon\\ \end{array} \]

Alternative 12: 58.5% 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 43.0%

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

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

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

    \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
  4. Step-by-step derivation
    1. associate-*r/71.4%

      \[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot 1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. *-rgt-identity71.4%

      \[\leadsto \frac{\color{blue}{\tan x + \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x \]
  5. Simplified71.4%

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

    \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
  7. Final simplification56.8%

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

Alternative 13: 57.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3400000 \lor \neg \left(\varepsilon \leq 2.8 \cdot 10^{-5}\right):\\
\;\;\;\;\tan \left(\varepsilon + x\right)\\

\mathbf{else}:\\
\;\;\;\;\sin \varepsilon\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -3.4e6 or 2.79999999999999996e-5 < eps

    1. Initial program 51.0%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Step-by-step derivation
      1. add-cube-cbrt50.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)} \cdot \sqrt[3]{\tan \left(x + \varepsilon\right)}\right) \cdot \sqrt[3]{\tan \left(x + \varepsilon\right)}} - \tan x \]
      2. pow350.6%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{3}} - \tan x \]
    3. Applied egg-rr50.6%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{3}} - \tan x \]
    4. Step-by-step derivation
      1. add-sqr-sqrt30.3%

        \[\leadsto {\color{blue}{\left(\sqrt{\sqrt[3]{\tan \left(x + \varepsilon\right)}} \cdot \sqrt{\sqrt[3]{\tan \left(x + \varepsilon\right)}}\right)}}^{3} - \tan x \]
      2. sqrt-unprod35.3%

        \[\leadsto {\color{blue}{\left(\sqrt{\sqrt[3]{\tan \left(x + \varepsilon\right)} \cdot \sqrt[3]{\tan \left(x + \varepsilon\right)}}\right)}}^{3} - \tan x \]
      3. pow235.3%

        \[\leadsto {\left(\sqrt{\color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{2}}}\right)}^{3} - \tan x \]
    5. Applied egg-rr35.3%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{2}}\right)}}^{3} - \tan x \]
    6. Step-by-step derivation
      1. unpow235.3%

        \[\leadsto {\left(\sqrt{\color{blue}{\sqrt[3]{\tan \left(x + \varepsilon\right)} \cdot \sqrt[3]{\tan \left(x + \varepsilon\right)}}}\right)}^{3} - \tan x \]
      2. rem-sqrt-square35.3%

        \[\leadsto {\color{blue}{\left(\left|\sqrt[3]{\tan \left(x + \varepsilon\right)}\right|\right)}}^{3} - \tan x \]
      3. +-commutative35.3%

        \[\leadsto {\left(\left|\sqrt[3]{\tan \color{blue}{\left(\varepsilon + x\right)}}\right|\right)}^{3} - \tan x \]
    7. Simplified35.3%

      \[\leadsto {\color{blue}{\left(\left|\sqrt[3]{\tan \left(\varepsilon + x\right)}\right|\right)}}^{3} - \tan x \]
    8. Taylor expanded in x around 0 30.9%

      \[\leadsto \color{blue}{{\left(\left|{\tan \left(\varepsilon + x\right)}^{0.3333333333333333}\right|\right)}^{3}} \]
    9. Step-by-step derivation
      1. +-commutative30.9%

        \[\leadsto {\left(\left|{\tan \color{blue}{\left(x + \varepsilon\right)}}^{0.3333333333333333}\right|\right)}^{3} \]
      2. metadata-eval30.9%

        \[\leadsto {\left(\left|{\tan \left(x + \varepsilon\right)}^{\color{blue}{\left(2 \cdot 0.16666666666666666\right)}}\right|\right)}^{3} \]
      3. pow-sqr30.6%

        \[\leadsto {\left(\left|\color{blue}{{\tan \left(x + \varepsilon\right)}^{0.16666666666666666} \cdot {\tan \left(x + \varepsilon\right)}^{0.16666666666666666}}\right|\right)}^{3} \]
      4. fabs-sqr30.6%

        \[\leadsto {\color{blue}{\left({\tan \left(x + \varepsilon\right)}^{0.16666666666666666} \cdot {\tan \left(x + \varepsilon\right)}^{0.16666666666666666}\right)}}^{3} \]
      5. pow-sqr30.9%

        \[\leadsto {\color{blue}{\left({\tan \left(x + \varepsilon\right)}^{\left(2 \cdot 0.16666666666666666\right)}\right)}}^{3} \]
      6. metadata-eval30.9%

        \[\leadsto {\left({\tan \left(x + \varepsilon\right)}^{\color{blue}{0.3333333333333333}}\right)}^{3} \]
      7. unpow1/350.6%

        \[\leadsto {\color{blue}{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}}^{3} \]
      8. rem-cube-cbrt51.6%

        \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right)} \]
    10. Simplified51.6%

      \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right)} \]

    if -3.4e6 < eps < 2.79999999999999996e-5

    1. Initial program 33.2%

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

        \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
      2. clear-num36.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
    3. Applied egg-rr36.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
    4. Step-by-step derivation
      1. clear-num36.5%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan \left(x + \varepsilon\right)}}} - \tan x \]
      3. tan-quot32.9%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{\sin \left(x + \varepsilon\right)}{\cos \left(x + \varepsilon\right)}}}} - \tan x \]
      4. associate-/r/33.1%

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

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

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

      \[\leadsto \color{blue}{\sin \varepsilon} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -3400000 \lor \neg \left(\varepsilon \leq 2.8 \cdot 10^{-5}\right):\\ \;\;\;\;\tan \left(\varepsilon + x\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \varepsilon\\ \end{array} \]

Alternative 14: 35.5% accurate, 2.0× speedup?

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

\\
\sin \varepsilon
\end{array}
Derivation
  1. Initial program 43.0%

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. clear-num71.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
  3. Applied egg-rr71.1%

    \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
  4. Step-by-step derivation
    1. clear-num71.1%

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

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan \left(x + \varepsilon\right)}}} - \tan x \]
    3. tan-quot42.8%

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{\sin \left(x + \varepsilon\right)}{\cos \left(x + \varepsilon\right)}}}} - \tan x \]
    4. associate-/r/42.9%

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\sin \left(x + \varepsilon\right)} \cdot \cos \left(x + \varepsilon\right)}} - \tan x \]
  5. Applied egg-rr42.9%

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

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

    \[\leadsto \color{blue}{\sin \varepsilon} \]
  8. Final simplification32.9%

    \[\leadsto \sin \varepsilon \]

Alternative 15: 4.3% accurate, 205.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 43.0%

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)} \cdot \sqrt[3]{\tan \left(x + \varepsilon\right)}\right) \cdot \sqrt[3]{\tan \left(x + \varepsilon\right)}} - \tan x \]
    2. pow342.2%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{3}} - \tan x \]
  3. Applied egg-rr42.2%

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{3}} - \tan x \]
  4. Taylor expanded in eps around 0 4.1%

    \[\leadsto \color{blue}{{1}^{0.3333333333333333} \cdot \frac{\sin x}{\cos x} - \frac{\sin x}{\cos x}} \]
  5. Step-by-step derivation
    1. pow-base-14.1%

      \[\leadsto \color{blue}{1} \cdot \frac{\sin x}{\cos x} - \frac{\sin x}{\cos x} \]
    2. *-lft-identity4.1%

      \[\leadsto \color{blue}{\frac{\sin x}{\cos x}} - \frac{\sin x}{\cos x} \]
    3. +-inverses4.1%

      \[\leadsto \color{blue}{0} \]
  6. Simplified4.1%

    \[\leadsto \color{blue}{0} \]
  7. Final simplification4.1%

    \[\leadsto 0 \]

Alternative 16: 31.7% accurate, 205.0× speedup?

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

\\
\varepsilon
\end{array}
Derivation
  1. Initial program 43.0%

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x \]
    2. clear-num71.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
  3. Applied egg-rr71.1%

    \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x \]
  4. Step-by-step derivation
    1. clear-num71.1%

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

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan \left(x + \varepsilon\right)}}} - \tan x \]
    3. tan-quot42.8%

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{\sin \left(x + \varepsilon\right)}{\cos \left(x + \varepsilon\right)}}}} - \tan x \]
    4. associate-/r/42.9%

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\sin \left(x + \varepsilon\right)} \cdot \cos \left(x + \varepsilon\right)}} - \tan x \]
  5. Applied egg-rr42.9%

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

    \[\leadsto \frac{1}{\frac{1}{\sin \left(x + \varepsilon\right)} \cdot \color{blue}{\cos x}} - \tan x \]
  7. Taylor expanded in eps around 0 29.4%

    \[\leadsto \color{blue}{\varepsilon} \]
  8. Final simplification29.4%

    \[\leadsto \varepsilon \]

Developer target: 77.3% 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 2023318 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"
  :precision binary64

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

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