Average Error: 36.5 → 1.7
Time: 20.9s
Precision: binary64
Cost: 65544
\[\tan \left(x + \varepsilon\right) - \tan x \]
\[\begin{array}{l} t_0 := \frac{\sin x}{\cos x}\\ t_1 := \tan x + \tan \varepsilon\\ t_2 := 1 - \tan x \cdot \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -7.262701961593762 \cdot 10^{+25}:\\ \;\;\;\;\frac{t_1}{t_2} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 3.6785749218739517 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(\varepsilon \cdot \varepsilon, t_0 + {t_0}^{3}, \varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{t_2}, -\tan x\right)\\ \end{array} \]
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (/ (sin x) (cos x)))
        (t_1 (+ (tan x) (tan eps)))
        (t_2 (- 1.0 (* (tan x) (tan eps)))))
   (if (<= eps -7.262701961593762e+25)
     (- (/ t_1 t_2) (tan x))
     (if (<= eps 3.6785749218739517e-10)
       (fma
        (* eps eps)
        (+ t_0 (pow t_0 3.0))
        (+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))))
       (fma t_1 (/ 1.0 t_2) (- (tan x)))))))
double code(double x, double eps) {
	return tan((x + eps)) - tan(x);
}
double code(double x, double eps) {
	double t_0 = sin(x) / cos(x);
	double t_1 = tan(x) + tan(eps);
	double t_2 = 1.0 - (tan(x) * tan(eps));
	double tmp;
	if (eps <= -7.262701961593762e+25) {
		tmp = (t_1 / t_2) - tan(x);
	} else if (eps <= 3.6785749218739517e-10) {
		tmp = fma((eps * eps), (t_0 + pow(t_0, 3.0)), (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))));
	} else {
		tmp = fma(t_1, (1.0 / t_2), -tan(x));
	}
	return tmp;
}
function code(x, eps)
	return Float64(tan(Float64(x + eps)) - tan(x))
end
function code(x, eps)
	t_0 = Float64(sin(x) / cos(x))
	t_1 = Float64(tan(x) + tan(eps))
	t_2 = Float64(1.0 - Float64(tan(x) * tan(eps)))
	tmp = 0.0
	if (eps <= -7.262701961593762e+25)
		tmp = Float64(Float64(t_1 / t_2) - tan(x));
	elseif (eps <= 3.6785749218739517e-10)
		tmp = fma(Float64(eps * eps), Float64(t_0 + (t_0 ^ 3.0)), Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))));
	else
		tmp = fma(t_1, Float64(1.0 / t_2), Float64(-tan(x)));
	end
	return tmp
end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7.262701961593762e+25], N[(N[(t$95$1 / t$95$2), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.6785749218739517e-10], N[(N[(eps * eps), $MachinePrecision] * N[(t$95$0 + N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision] + N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 / t$95$2), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]]
\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
t_1 := \tan x + \tan \varepsilon\\
t_2 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -7.262701961593762 \cdot 10^{+25}:\\
\;\;\;\;\frac{t_1}{t_2} - \tan x\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{t_2}, -\tan x\right)\\


\end{array}

Error

Target

Original36.5
Target14.5
Herbie1.7
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes
  2. if eps < -7.2627019615937622e25

    1. Initial program 29.3

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Applied egg-rr0.3

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

    if -7.2627019615937622e25 < eps < 3.6785749218739517e-10

    1. Initial program 44.1

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Applied egg-rr42.2

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{\mathsf{fma}\left(\tan x, -\tan \varepsilon, 1\right)}} - \tan x \]
    4. Taylor expanded in eps around 0 2.9

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\varepsilon \cdot \varepsilon, \frac{\sin x}{\cos x} + {\left(\frac{\sin x}{\cos x}\right)}^{3}, \varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)} \]
      Proof
      (fma.f64 (*.f64 eps eps) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (pow.f64 (/.f64 (sin.f64 x) (cos.f64 x)) 3)) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (Rewrite<= unpow2_binary64 (pow.f64 eps 2)) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (pow.f64 (/.f64 (sin.f64 x) (cos.f64 x)) 3)) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (Rewrite<= cube-unmult_binary64 (*.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (*.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (sin.f64 x) (cos.f64 x)))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 1 points increase in error, 1 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (*.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (sin.f64 x) (sin.f64 x)) (*.f64 (cos.f64 x) (cos.f64 x)))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 2 points increase in error, 1 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (*.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sin.f64 x) 2)) (*.f64 (cos.f64 x) (cos.f64 x))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (*.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (pow.f64 (sin.f64 x) 2) (Rewrite<= unpow2_binary64 (pow.f64 (cos.f64 x) 2))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (sin.f64 x) (pow.f64 (sin.f64 x) 2)) (*.f64 (cos.f64 x) (pow.f64 (cos.f64 x) 2))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 3 points increase in error, 3 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (*.f64 (sin.f64 x) (Rewrite=> unpow2_binary64 (*.f64 (sin.f64 x) (sin.f64 x)))) (*.f64 (cos.f64 x) (pow.f64 (cos.f64 x) 2)))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (Rewrite<= cube-mult_binary64 (pow.f64 (sin.f64 x) 3)) (*.f64 (cos.f64 x) (pow.f64 (cos.f64 x) 2)))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 4 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (pow.f64 (sin.f64 x) 3) (*.f64 (cos.f64 x) (Rewrite=> unpow2_binary64 (*.f64 (cos.f64 x) (cos.f64 x)))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (+.f64 (/.f64 (sin.f64 x) (cos.f64 x)) (/.f64 (pow.f64 (sin.f64 x) 3) (Rewrite<= cube-mult_binary64 (pow.f64 (cos.f64 x) 3)))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 2 points decrease in error
      (fma.f64 (pow.f64 eps 2) (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3)) (/.f64 (sin.f64 x) (cos.f64 x)))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (+.f64 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3)) (/.f64 (sin.f64 x) (cos.f64 x)))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (+.f64 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3)) (/.f64 (sin.f64 x) (cos.f64 x)))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x)))))) (+.f64 eps (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))) (+.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 eps 1)) (*.f64 eps (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))) (Rewrite=> distribute-lft-out_binary64 (*.f64 eps (+.f64 1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2)))))): 15 points increase in error, 8 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))) (*.f64 eps (+.f64 1 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))) (*.f64 eps (+.f64 1 (*.f64 (Rewrite<= metadata-eval (neg.f64 -1)) (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2)))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (pow.f64 eps 2) (neg.f64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))) (*.f64 eps (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 1 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (pow.f64 eps 2) (neg.f64 (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x)))))) (*.f64 eps (-.f64 1 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))))): 1 points increase in error, 1 points decrease in error
      (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (pow.f64 eps 2) (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))))) (*.f64 eps (-.f64 1 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 (pow.f64 eps 2) (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x))))))) (*.f64 eps (-.f64 1 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 eps (-.f64 1 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 2) (pow.f64 (cos.f64 x) 2))))) (*.f64 -1 (*.f64 (pow.f64 eps 2) (+.f64 (*.f64 -1 (/.f64 (pow.f64 (sin.f64 x) 3) (pow.f64 (cos.f64 x) 3))) (*.f64 -1 (/.f64 (sin.f64 x) (cos.f64 x)))))))): 0 points increase in error, 0 points decrease in error

    if 3.6785749218739517e-10 < eps

    1. Initial program 27.7

      \[\tan \left(x + \varepsilon\right) - \tan x \]
    2. Applied egg-rr36.5

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(x + \varepsilon\right)\right)\right)} - \tan x \]
    3. Applied egg-rr0.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, -\tan x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.7

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

Alternatives

Alternative 1
Error1.8
Cost39432
\[\begin{array}{l} t_0 := \tan x + \tan \varepsilon\\ t_1 := 1 - \tan x \cdot \tan \varepsilon\\ \mathbf{if}\;\varepsilon \leq -7.262701961593762 \cdot 10^{+25}:\\ \;\;\;\;\frac{t_0}{t_1} - \tan x\\ \mathbf{elif}\;\varepsilon \leq 3.6785749218739517 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(\varepsilon, \frac{0.5 + \cos \left(x \cdot 2\right) \cdot -0.5}{{\cos x}^{2}}, \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\ \end{array} \]
Alternative 2
Error1.8
Cost32968
\[\begin{array}{l} t_0 := \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{if}\;\varepsilon \leq -7.262701961593762 \cdot 10^{+25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\varepsilon \leq 3.6785749218739517 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(\varepsilon, \frac{0.5 + \cos \left(x \cdot 2\right) \cdot -0.5}{{\cos x}^{2}}, \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error14.7
Cost26632
\[\begin{array}{l} \mathbf{if}\;\varepsilon \leq -7.262701961593762 \cdot 10^{+25}:\\ \;\;\;\;\tan \varepsilon - \tan x\\ \mathbf{elif}\;\varepsilon \leq 699.0834557798377:\\ \;\;\;\;\mathsf{fma}\left(\varepsilon, \frac{0.5 + \cos \left(x \cdot 2\right) \cdot -0.5}{{\cos x}^{2}}, \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\tan \varepsilon\\ \end{array} \]
Alternative 4
Error14.7
Cost19976
\[\begin{array}{l} \mathbf{if}\;\varepsilon \leq -7.262701961593762 \cdot 10^{+25}:\\ \;\;\;\;\tan \varepsilon - \tan x\\ \mathbf{elif}\;\varepsilon \leq 699.0834557798377:\\ \;\;\;\;\varepsilon + \varepsilon \cdot {\left(\frac{\sin x}{\cos x}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\tan \varepsilon\\ \end{array} \]
Alternative 5
Error26.4
Cost6464
\[\tan \varepsilon \]
Alternative 6
Error44.1
Cost64
\[\varepsilon \]

Error

Reproduce

herbie shell --seed 2022318 
(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)))