2tan (problem 3.3.2)

Percentage Accurate: 42.6% → 99.4%
Time: 20.5s
Alternatives: 13
Speedup: 2.0×

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 13 alternatives:

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

Initial Program: 42.6% 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.4% accurate, 0.1× speedup?

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

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

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

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


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

    1. Initial program 51.4%

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

        \[\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. *-un-lft-identity99.3%

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative67.4%

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      7. *-un-lft-identity67.4%

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
      9. *-un-lft-identity67.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.3%

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

      \[\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}} \]
    8. Step-by-step derivation
      1. associate--l+99.1%

        \[\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*99.1%

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

        \[\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) \]
    9. Simplified99.1%

      \[\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)} \]
    10. Step-by-step derivation
      1. tan-quot99.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-neg99.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-quot99.2%

        \[\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-quot99.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-quot99.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) \]
    11. Applied egg-rr99.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)} \]
    12. Step-by-step derivation
      1. sub-neg99.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. *-commutative99.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) \]
    13. Simplified99.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)} \]
    14. Step-by-step derivation
      1. clear-num99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.8000000000000001e-5 < eps < 5.2000000000000001e-11

    1. Initial program 28.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative29.0%

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      7. *-un-lft-identity29.0%

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
      9. *-un-lft-identity29.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative29.0%

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

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

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

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

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

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

    if 5.2000000000000001e-11 < eps

    1. Initial program 52.2%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. 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.4%

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative68.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.4%

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

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

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

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

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

Alternative 2: 99.4% 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 := 1 - \tan x \cdot \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -0.0009:\\ \;\;\;\;\frac{t_2}{t_3} + \left(\frac{\tan x}{t_3} - \tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;\frac{t_2}{1 - t_2 \cdot \frac{\sin x}{\cos x}} + \left(\left(\frac{\varepsilon \cdot t_0}{t_1} + \frac{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right) - {\varepsilon}^{3} \cdot \left(\frac{t_0}{t_1} \cdot -0.3333333333333333 - \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}} - \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 (- 1.0 (* (tan x) (tan eps)))))
   (if (<= eps -0.0009)
     (+ (/ t_2 t_3) (- (/ (tan x) t_3) (tan x)))
     (if (<= eps 5.2e-11)
       (+
        (/ t_2 (- 1.0 (* t_2 (/ (sin x) (cos x)))))
        (-
         (+
          (/ (* eps t_0) t_1)
          (/ (* (pow eps 2.0) (pow (sin x) 3.0)) (pow (cos x) 3.0)))
         (*
          (pow eps 3.0)
          (-
           (* (/ t_0 t_1) -0.3333333333333333)
           (/ (pow (sin x) 4.0) (pow (cos x) 4.0))))))
       (-
        (/ (+ (tan x) (tan eps)) (- 1.0 (/ (* (sin eps) (tan x)) (cos eps))))
        (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 = 1.0 - (tan(x) * tan(eps));
	double tmp;
	if (eps <= -0.0009) {
		tmp = (t_2 / t_3) + ((tan(x) / t_3) - tan(x));
	} else if (eps <= 5.2e-11) {
		tmp = (t_2 / (1.0 - (t_2 * (sin(x) / cos(x))))) + ((((eps * t_0) / t_1) + ((pow(eps, 2.0) * pow(sin(x), 3.0)) / pow(cos(x), 3.0))) - (pow(eps, 3.0) * (((t_0 / t_1) * -0.3333333333333333) - (pow(sin(x), 4.0) / pow(cos(x), 4.0)))));
	} else {
		tmp = ((tan(x) + tan(eps)) / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))) - 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 = 1.0d0 - (tan(x) * tan(eps))
    if (eps <= (-0.0009d0)) then
        tmp = (t_2 / t_3) + ((tan(x) / t_3) - tan(x))
    else if (eps <= 5.2d-11) then
        tmp = (t_2 / (1.0d0 - (t_2 * (sin(x) / cos(x))))) + ((((eps * t_0) / t_1) + (((eps ** 2.0d0) * (sin(x) ** 3.0d0)) / (cos(x) ** 3.0d0))) - ((eps ** 3.0d0) * (((t_0 / t_1) * (-0.3333333333333333d0)) - ((sin(x) ** 4.0d0) / (cos(x) ** 4.0d0)))))
    else
        tmp = ((tan(x) + tan(eps)) / (1.0d0 - ((sin(eps) * tan(x)) / cos(eps)))) - 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 = 1.0 - (Math.tan(x) * Math.tan(eps));
	double tmp;
	if (eps <= -0.0009) {
		tmp = (t_2 / t_3) + ((Math.tan(x) / t_3) - Math.tan(x));
	} else if (eps <= 5.2e-11) {
		tmp = (t_2 / (1.0 - (t_2 * (Math.sin(x) / Math.cos(x))))) + ((((eps * t_0) / t_1) + ((Math.pow(eps, 2.0) * Math.pow(Math.sin(x), 3.0)) / Math.pow(Math.cos(x), 3.0))) - (Math.pow(eps, 3.0) * (((t_0 / t_1) * -0.3333333333333333) - (Math.pow(Math.sin(x), 4.0) / Math.pow(Math.cos(x), 4.0)))));
	} else {
		tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - ((Math.sin(eps) * Math.tan(x)) / Math.cos(eps)))) - 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 = 1.0 - (math.tan(x) * math.tan(eps))
	tmp = 0
	if eps <= -0.0009:
		tmp = (t_2 / t_3) + ((math.tan(x) / t_3) - math.tan(x))
	elif eps <= 5.2e-11:
		tmp = (t_2 / (1.0 - (t_2 * (math.sin(x) / math.cos(x))))) + ((((eps * t_0) / t_1) + ((math.pow(eps, 2.0) * math.pow(math.sin(x), 3.0)) / math.pow(math.cos(x), 3.0))) - (math.pow(eps, 3.0) * (((t_0 / t_1) * -0.3333333333333333) - (math.pow(math.sin(x), 4.0) / math.pow(math.cos(x), 4.0)))))
	else:
		tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - ((math.sin(eps) * math.tan(x)) / math.cos(eps)))) - 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(1.0 - Float64(tan(x) * tan(eps)))
	tmp = 0.0
	if (eps <= -0.0009)
		tmp = Float64(Float64(t_2 / t_3) + Float64(Float64(tan(x) / t_3) - tan(x)));
	elseif (eps <= 5.2e-11)
		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((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0))) - Float64((eps ^ 3.0) * Float64(Float64(Float64(t_0 / t_1) * -0.3333333333333333) - Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0))))));
	else
		tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(Float64(sin(eps) * tan(x)) / cos(eps)))) - 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 = 1.0 - (tan(x) * tan(eps));
	tmp = 0.0;
	if (eps <= -0.0009)
		tmp = (t_2 / t_3) + ((tan(x) / t_3) - tan(x));
	elseif (eps <= 5.2e-11)
		tmp = (t_2 / (1.0 - (t_2 * (sin(x) / cos(x))))) + ((((eps * t_0) / t_1) + (((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0))) - ((eps ^ 3.0) * (((t_0 / t_1) * -0.3333333333333333) - ((sin(x) ^ 4.0) / (cos(x) ^ 4.0)))));
	else
		tmp = ((tan(x) + tan(eps)) / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))) - 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[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0009], N[(N[(t$95$2 / t$95$3), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / t$95$3), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.2e-11], 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[eps, 2.0], $MachinePrecision] * N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 3.0], $MachinePrecision] * N[(N[(N[(t$95$0 / t$95$1), $MachinePrecision] * -0.3333333333333333), $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[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $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 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0009:\\
\;\;\;\;\frac{t_2}{t_3} + \left(\frac{\tan x}{t_3} - \tan x\right)\\

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

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


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

    1. Initial program 50.7%

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

        \[\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. *-un-lft-identity99.3%

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative66.9%

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      7. *-un-lft-identity66.9%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative66.9%

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.3%

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

      \[\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}} \]
    8. Step-by-step derivation
      1. associate--l+99.1%

        \[\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*99.1%

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

        \[\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) \]
    9. Simplified99.1%

      \[\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)} \]
    10. Step-by-step derivation
      1. tan-quot99.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-neg99.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-quot99.1%

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

        \[\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-quot99.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) \]
    11. Applied egg-rr99.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)} \]
    12. Step-by-step derivation
      1. sub-neg99.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. *-commutative99.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) \]
    13. Simplified99.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)} \]
    14. Step-by-step derivation
      1. clear-num99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.9999999999999998e-4 < eps < 5.2000000000000001e-11

    1. Initial program 29.5%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. tan-sum30.0%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative29.6%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative29.6%

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified30.0%

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

      \[\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}} \]
    8. Step-by-step derivation
      1. associate--l+61.9%

        \[\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*61.9%

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

        \[\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) \]
    9. Simplified61.9%

      \[\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)} \]
    10. Step-by-step derivation
      1. tan-quot60.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-neg60.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-quot61.9%

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

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

        \[\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) \]
    11. Applied egg-rr61.9%

      \[\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)} \]
    12. Step-by-step derivation
      1. sub-neg61.9%

        \[\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. *-commutative61.9%

        \[\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) \]
    13. Simplified61.9%

      \[\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)} \]
    14. Taylor expanded in eps around 0 99.7%

      \[\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 5.2000000000000001e-11 < eps

    1. Initial program 52.2%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. 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.4%

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative68.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -0.0009:\\ \;\;\;\;\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} + \left(\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x\right)\\ \mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;\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{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right) - {\varepsilon}^{3} \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot -0.3333333333333333 - \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}} - \tan x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.3% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\

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


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

    1. Initial program 51.5%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative67.2%

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      7. *-un-lft-identity67.2%

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
      9. *-un-lft-identity67.2%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative67.2%

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

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

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

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

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

      \[\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}} \]
    8. Step-by-step derivation
      1. associate--l+98.7%

        \[\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*98.7%

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

        \[\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) \]
    9. Simplified98.7%

      \[\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)} \]
    10. Step-by-step derivation
      1. tan-quot98.6%

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

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

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

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

        \[\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) \]
    11. Applied egg-rr98.9%

      \[\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)} \]
    12. Step-by-step derivation
      1. sub-neg98.9%

        \[\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. *-commutative98.9%

        \[\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) \]
    13. Simplified98.9%

      \[\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)} \]
    14. Step-by-step derivation
      1. clear-num98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.20000000000000012e-9 < eps < 5.2000000000000001e-11

    1. Initial program 28.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.8%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.8%

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

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

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

        \[\leadsto \left(\tan x \cdot \color{blue}{\tan x}\right) \cdot \varepsilon + 1 \cdot \varepsilon \]
      8. pow299.8%

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.8%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.8%

      \[\leadsto \color{blue}{{\tan x}^{2} \cdot \varepsilon + \varepsilon} \]

    if 5.2000000000000001e-11 < eps

    1. Initial program 52.2%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. 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.4%

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative68.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.4%

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

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

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

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

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

Alternative 4: 99.4% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\


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

    1. Initial program 51.9%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. 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.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
      9. *-un-lft-identity67.7%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative67.7%

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.1%

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

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

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

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

    if -4.00000000000000025e-9 < eps < 5.2000000000000001e-11

    1. Initial program 28.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.8%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.8%

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

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

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

        \[\leadsto \left(\tan x \cdot \color{blue}{\tan x}\right) \cdot \varepsilon + 1 \cdot \varepsilon \]
      8. pow299.8%

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.8%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.8%

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

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

Alternative 5: 99.3% accurate, 0.3× speedup?

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

\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\

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


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

    1. Initial program 51.5%

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{3}} - \tan x \]
    5. Step-by-step derivation
      1. rem-cube-cbrt51.5%

        \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right)} - \tan x \]
      2. remove-double-div51.6%

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    6. Applied egg-rr25.2%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    7. Step-by-step derivation
      1. reciprocal-undefine51.6%

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

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

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

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

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

    if -4.00000000000000025e-9 < eps < 5.2000000000000001e-11

    1. Initial program 28.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.8%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.8%

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

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

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

        \[\leadsto \left(\tan x \cdot \color{blue}{\tan x}\right) \cdot \varepsilon + 1 \cdot \varepsilon \]
      8. pow299.8%

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.8%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.8%

      \[\leadsto \color{blue}{{\tan x}^{2} \cdot \varepsilon + \varepsilon} \]

    if 5.2000000000000001e-11 < eps

    1. Initial program 52.2%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. 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.4%

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative68.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.4%

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

        \[\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 \]
    8. Applied egg-rr99.5%

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

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \frac{\color{blue}{\sin x \cdot \tan \varepsilon}}{\cos x}} - \tan x \]
      2. associate-/l*99.4%

        \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}}} - \tan x \]
    10. Simplified99.4%

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

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

Alternative 6: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan x + \tan \varepsilon\\ t_1 := \tan x \cdot \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -2.7 \cdot 10^{-9}:\\ \;\;\;\;\frac{t_0}{1 - t_1} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{-1}{t_1 + -1} - \tan x\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (+ (tan x) (tan eps))) (t_1 (* (tan x) (tan eps))))
   (if (<= eps -2.7e-9)
     (- (/ t_0 (- 1.0 t_1)) (tan x))
     (if (<= eps 5.2e-11)
       (+ eps (* eps (pow (tan x) 2.0)))
       (- (* t_0 (/ -1.0 (+ t_1 -1.0))) (tan x))))))
double code(double x, double eps) {
	double t_0 = tan(x) + tan(eps);
	double t_1 = tan(x) * tan(eps);
	double tmp;
	if (eps <= -2.7e-9) {
		tmp = (t_0 / (1.0 - t_1)) - tan(x);
	} else if (eps <= 5.2e-11) {
		tmp = eps + (eps * pow(tan(x), 2.0));
	} else {
		tmp = (t_0 * (-1.0 / (t_1 + -1.0))) - 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) :: tmp
    t_0 = tan(x) + tan(eps)
    t_1 = tan(x) * tan(eps)
    if (eps <= (-2.7d-9)) then
        tmp = (t_0 / (1.0d0 - t_1)) - tan(x)
    else if (eps <= 5.2d-11) then
        tmp = eps + (eps * (tan(x) ** 2.0d0))
    else
        tmp = (t_0 * ((-1.0d0) / (t_1 + (-1.0d0)))) - 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 t_1 = Math.tan(x) * Math.tan(eps);
	double tmp;
	if (eps <= -2.7e-9) {
		tmp = (t_0 / (1.0 - t_1)) - Math.tan(x);
	} else if (eps <= 5.2e-11) {
		tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
	} else {
		tmp = (t_0 * (-1.0 / (t_1 + -1.0))) - Math.tan(x);
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.tan(x) + math.tan(eps)
	t_1 = math.tan(x) * math.tan(eps)
	tmp = 0
	if eps <= -2.7e-9:
		tmp = (t_0 / (1.0 - t_1)) - math.tan(x)
	elif eps <= 5.2e-11:
		tmp = eps + (eps * math.pow(math.tan(x), 2.0))
	else:
		tmp = (t_0 * (-1.0 / (t_1 + -1.0))) - math.tan(x)
	return tmp
function code(x, eps)
	t_0 = Float64(tan(x) + tan(eps))
	t_1 = Float64(tan(x) * tan(eps))
	tmp = 0.0
	if (eps <= -2.7e-9)
		tmp = Float64(Float64(t_0 / Float64(1.0 - t_1)) - tan(x));
	elseif (eps <= 5.2e-11)
		tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0)));
	else
		tmp = Float64(Float64(t_0 * Float64(-1.0 / Float64(t_1 + -1.0))) - tan(x));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = tan(x) + tan(eps);
	t_1 = tan(x) * tan(eps);
	tmp = 0.0;
	if (eps <= -2.7e-9)
		tmp = (t_0 / (1.0 - t_1)) - tan(x);
	elseif (eps <= 5.2e-11)
		tmp = eps + (eps * (tan(x) ^ 2.0));
	else
		tmp = (t_0 * (-1.0 / (t_1 + -1.0))) - tan(x);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.7e-9], N[(N[(t$95$0 / N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.2e-11], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(-1.0 / N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\

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


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

    1. Initial program 51.5%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \color{blue}{\mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)}, -\tan x \cdot 1\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      6. *-commutative67.2%

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\color{blue}{1 \cdot \tan x}\right) + \mathsf{fma}\left(-\tan x, 1, \tan x \cdot 1\right) \]
      7. *-un-lft-identity67.2%

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
      9. *-un-lft-identity67.2%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative67.2%

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

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

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

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

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

    if -2.7000000000000002e-9 < eps < 5.2000000000000001e-11

    1. Initial program 28.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.8%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.8%

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

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

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

        \[\leadsto \left(\tan x \cdot \color{blue}{\tan x}\right) \cdot \varepsilon + 1 \cdot \varepsilon \]
      8. pow299.8%

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.8%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.8%

      \[\leadsto \color{blue}{{\tan x}^{2} \cdot \varepsilon + \varepsilon} \]

    if 5.2000000000000001e-11 < eps

    1. Initial program 52.2%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt51.8%

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

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

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

        \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right)} - \tan x \]
      2. remove-double-div52.2%

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    6. Applied egg-rr25.2%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    7. Step-by-step derivation
      1. reciprocal-undefine52.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -2.7 \cdot 10^{-9}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{-1}{\tan x \cdot \tan \varepsilon + -1} - \tan x\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\

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


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

    1. Initial program 51.5%

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\tan \left(x + \varepsilon\right)}\right)}^{3}} - \tan x \]
    5. Step-by-step derivation
      1. rem-cube-cbrt51.5%

        \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right)} - \tan x \]
      2. remove-double-div51.6%

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    6. Applied egg-rr25.2%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    7. Step-by-step derivation
      1. reciprocal-undefine51.6%

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

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

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

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

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

    if -2.7000000000000002e-9 < eps < 5.2000000000000001e-11

    1. Initial program 28.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.8%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.8%

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

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

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

        \[\leadsto \left(\tan x \cdot \color{blue}{\tan x}\right) \cdot \varepsilon + 1 \cdot \varepsilon \]
      8. pow299.8%

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.8%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.8%

      \[\leadsto \color{blue}{{\tan x}^{2} \cdot \varepsilon + \varepsilon} \]

    if 5.2000000000000001e-11 < eps

    1. Initial program 52.2%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt51.8%

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

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

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

        \[\leadsto \color{blue}{\tan \left(x + \varepsilon\right)} - \tan x \]
      2. remove-double-div52.2%

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    6. Applied egg-rr25.2%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{reciprocal}\left(\tan \left(x + \varepsilon\right)\right)}} - \tan x \]
    7. Step-by-step derivation
      1. reciprocal-undefine52.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -2.7 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \frac{1}{\tan x + \tan \varepsilon}} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{-1}{\tan x \cdot \tan \varepsilon + -1} - \tan x\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 99.4% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\


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

    1. Initial program 51.9%

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Add Preprocessing
    3. 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.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \color{blue}{1 \cdot \tan x}\right) \]
      9. *-un-lft-identity67.7%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right), -\tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)} \]
    5. Step-by-step derivation
      1. +-commutative67.7%

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(-\tan x, 1, \tan x\right) + \left(\tan x + \tan \varepsilon\right) \cdot \mathsf{reciprocal}\left(\left(1 - \tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x} \]
    6. Simplified99.1%

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

    if -1.75e-9 < eps < 5.2000000000000001e-11

    1. Initial program 28.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.8%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.8%

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

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

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

        \[\leadsto \left(\tan x \cdot \color{blue}{\tan x}\right) \cdot \varepsilon + 1 \cdot \varepsilon \]
      8. pow299.8%

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.8%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -1.75 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 5.2 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{else}:\\ \;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 77.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.35 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 5.2 \cdot 10^{-11}\right):\\
\;\;\;\;\tan \varepsilon\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < -2.34999999999999995e-6 or 5.2000000000000001e-11 < eps

    1. Initial program 51.9%

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

      \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
    4. Step-by-step derivation
      1. tan-quot54.6%

        \[\leadsto \color{blue}{\tan \varepsilon} \]
      2. expm1-log1p-u41.5%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\tan \varepsilon\right)} - 1} \]
    5. Applied egg-rr40.2%

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

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

        \[\leadsto \color{blue}{\tan \varepsilon} \]
    7. Simplified54.6%

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

    if -2.34999999999999995e-6 < eps < 5.2000000000000001e-11

    1. Initial program 28.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \varepsilon \cdot \left(1 + \color{blue}{1 \cdot {\tan x}^{2}}\right) \]
    8. Step-by-step derivation
      1. *-lft-identity99.2%

        \[\leadsto \varepsilon \cdot \left(1 + \color{blue}{{\tan x}^{2}}\right) \]
    9. Simplified99.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -2.35 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 5.2 \cdot 10^{-11}\right):\\ \;\;\;\;\tan \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left(1 + {\tan x}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 77.7% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\


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

    1. Initial program 51.9%

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

      \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
    4. Step-by-step derivation
      1. tan-quot54.6%

        \[\leadsto \color{blue}{\tan \varepsilon} \]
      2. expm1-log1p-u41.5%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\tan \varepsilon\right)} - 1} \]
    5. Applied egg-rr40.2%

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

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

        \[\leadsto \color{blue}{\tan \varepsilon} \]
    7. Simplified54.6%

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

    if -3.3000000000000003e-5 < eps < 5.2000000000000001e-11

    1. Initial program 28.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon} \]
      3. unpow299.3%

        \[\leadsto \frac{\color{blue}{\sin x \cdot \sin x}}{{\cos x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      4. unpow299.3%

        \[\leadsto \frac{\sin x \cdot \sin x}{\color{blue}{\cos x \cdot \cos x}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      5. frac-times99.2%

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

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

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

        \[\leadsto \color{blue}{{\tan x}^{2}} \cdot \varepsilon + 1 \cdot \varepsilon \]
      9. *-un-lft-identity99.4%

        \[\leadsto {\tan x}^{2} \cdot \varepsilon + \color{blue}{\varepsilon} \]
    7. Applied egg-rr99.4%

      \[\leadsto \color{blue}{{\tan x}^{2} \cdot \varepsilon + \varepsilon} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification75.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 5.2 \cdot 10^{-11}\right):\\ \;\;\;\;\tan \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 58.7% accurate, 2.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
  4. Step-by-step derivation
    1. tan-quot57.7%

      \[\leadsto \color{blue}{\tan \varepsilon} \]
    2. expm1-log1p-u50.7%

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

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

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

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

      \[\leadsto \color{blue}{\tan \varepsilon} \]
  7. Simplified57.7%

    \[\leadsto \color{blue}{\tan \varepsilon} \]
  8. Final simplification57.7%

    \[\leadsto \tan \varepsilon \]
  9. Add Preprocessing

Alternative 12: 4.2% 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 41.1%

    \[\tan \left(x + \varepsilon\right) - \tan x \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt39.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  7. Simplified4.5%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification4.5%

    \[\leadsto 0 \]
  9. Add Preprocessing

Alternative 13: 31.1% 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 41.1%

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

    \[\leadsto \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}} \]
  4. Taylor expanded in eps around 0 31.3%

    \[\leadsto \color{blue}{\varepsilon} \]
  5. Final simplification31.3%

    \[\leadsto \varepsilon \]
  6. Add Preprocessing

Developer target: 76.6% 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 2024024 
(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)))