?

Average Error: 37.6 → 15.0
Time: 17.0s
Precision: binary64
Cost: 386824

?

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

\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot t_6 + \left(\frac{t_6 \cdot \left({\varepsilon}^{2} \cdot \sin x\right)}{\cos x} + \left(\left(-{\varepsilon}^{3} \cdot t_7\right) + \left(-\left(-0.5 \cdot t_8 + \left(\frac{\sin x \cdot t_7}{\cos x} + 0.16666666666666666 \cdot t_8\right)\right) \cdot {\varepsilon}^{4}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \left(\left(\tan x - t_3\right) + t_0\right) - t_2 \cdot t_2}{4 - -2 \cdot t_2}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.6
Target15.6
Herbie15.0
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation?

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

    1. Initial program 30.9

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

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

    if -0.0269999999999999997 < eps < 4.99999999999999977e-7

    1. Initial program 45.2

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

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

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

      [Start]0.3

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

    if 4.99999999999999977e-7 < eps

    1. Initial program 29.6

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

      \[\leadsto \color{blue}{\frac{-2 \cdot \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right) - \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right) \cdot \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right)}{4 - -2 \cdot \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right)}} \]
    3. Taylor expanded in x around 0 28.2

      \[\leadsto \frac{-2 \cdot \left(\left(\tan x - \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}}\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right) - \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right) \cdot \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right)}{4 - -2 \cdot \left(\left(\tan x - \tan \left(x + \varepsilon\right)\right) + \left(\tan x - \tan \left(x + \varepsilon\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.0

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

Alternatives

Alternative 1
Error15.0
Cost184136
\[\begin{array}{l} t_0 := {\cos x}^{2}\\ t_1 := \tan x - \tan \left(x + \varepsilon\right)\\ t_2 := \frac{\sin \varepsilon}{\cos \varepsilon}\\ t_3 := t_1 + t_1\\ t_4 := {\sin x}^{2}\\ t_5 := \frac{t_4}{t_0}\\ t_6 := -1 \cdot t_5\\ t_7 := 1 - t_6\\ \mathbf{if}\;\varepsilon \leq -0.0215:\\ \;\;\;\;t_2 - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-7}:\\ \;\;\;\;-1 \cdot \left({\varepsilon}^{3} \cdot \left(0.16666666666666666 + \left(\left(-1 \cdot \frac{t_4 \cdot t_7}{t_0} + \left(-0.5 - -0.5 \cdot t_6\right)\right) + 0.16666666666666666 \cdot t_5\right)\right)\right) + \left(\varepsilon \cdot t_7 + \frac{\sin x \cdot \left({\varepsilon}^{2} \cdot t_7\right)}{\cos x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \left(\left(\tan x - t_2\right) + t_1\right) - t_3 \cdot t_3}{4 - -2 \cdot t_3}\\ \end{array} \]
Alternative 2
Error15.0
Cost183688
\[\begin{array}{l} t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\ t_1 := {\cos x}^{2}\\ t_2 := {\sin x}^{2}\\ t_3 := \frac{t_2}{t_1}\\ t_4 := 1 - \left(-t_3\right)\\ t_5 := \tan x - \tan \left(x + \varepsilon\right)\\ t_6 := t_5 + t_5\\ \mathbf{if}\;\varepsilon \leq -0.033:\\ \;\;\;\;t_0 - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot t_4 + \left(\frac{t_4 \cdot \left({\varepsilon}^{2} \cdot \sin x\right)}{\cos x} + \left(-{\varepsilon}^{3} \cdot \left(\left(-\frac{t_2 \cdot t_4}{t_1}\right) + \left(\left(0.16666666666666666 + \left(-0.5 - t_3 \cdot 0.5\right)\right) + 0.16666666666666666 \cdot t_3\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \left(\left(\tan x - t_0\right) + t_5\right) - t_6 \cdot t_6}{4 - -2 \cdot t_6}\\ \end{array} \]
Alternative 3
Error15.0
Cost112456
\[\begin{array}{l} t_0 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ t_1 := \tan x - \tan \left(x + \varepsilon\right)\\ t_2 := \frac{\sin \varepsilon}{\cos \varepsilon}\\ t_3 := t_1 + t_1\\ \mathbf{if}\;\varepsilon \leq -5.5 \cdot 10^{-5}:\\ \;\;\;\;t_2 - \tan x\\ \mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot t_0 + \frac{{\varepsilon}^{2} \cdot \left(t_0 \cdot \sin x\right)}{\cos x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \left(\left(\tan x - t_2\right) + t_1\right) - t_3 \cdot t_3}{4 - -2 \cdot t_3}\\ \end{array} \]
Alternative 4
Error15.0
Cost72200
\[\begin{array}{l} t_0 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ t_1 := \frac{\sin \varepsilon}{\cos \varepsilon} - \tan x\\ \mathbf{if}\;\varepsilon \leq -5.5 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot t_0 + \frac{{\varepsilon}^{2} \cdot \left(t_0 \cdot \sin x\right)}{\cos x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error15.1
Cost26440
\[\begin{array}{l} t_0 := \frac{\sin \varepsilon}{\cos \varepsilon} - \tan x\\ \mathbf{if}\;\varepsilon \leq -5.4 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\varepsilon \leq 4.5 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error15.1
Cost26440
\[\begin{array}{l} t_0 := \frac{\sin \varepsilon}{\cos \varepsilon} - \tan x\\ \mathbf{if}\;\varepsilon \leq -3.35 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error27.5
Cost12992
\[\frac{\sin \varepsilon}{\cos \varepsilon} \]
Alternative 8
Error42.2
Cost6592
\[\frac{\sin \varepsilon}{1} \]
Alternative 9
Error44.6
Cost64
\[\varepsilon \]

Error

Reproduce?

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