\[\tan \left(x + \varepsilon\right) - \tan x
\]
↓
\[\begin{array}{l}
t_0 := -\tan x\\
t_1 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_2 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.95 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{t_2}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, t_0\right)\\
\mathbf{elif}\;\varepsilon \leq 3.05 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}, \varepsilon \cdot \varepsilon, \mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left(t_1 + \mathsf{fma}\left(0.3333333333333333, t_1, \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right), \varepsilon + \varepsilon \cdot t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_2, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, t_0\right)\\
\end{array}
\]
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
↓
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x)))
(t_1 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))
(t_2 (+ (tan x) (tan eps))))
(if (<= eps -2.95e-5)
(fma
(fma (tan x) (tan eps) 1.0)
(/ t_2 (- 1.0 (pow (* (tan x) (tan eps)) 2.0)))
t_0)
(if (<= eps 3.05e-5)
(fma
(+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))
(* eps eps)
(fma
(pow eps 3.0)
(+
0.3333333333333333
(+
t_1
(fma
0.3333333333333333
t_1
(/ (pow (sin x) 4.0) (pow (cos x) 4.0)))))
(+ eps (* eps t_1))))
(fma t_2 (/ -1.0 (fma (tan x) (tan eps) -1.0)) t_0)))))double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
↓
double code(double x, double eps) {
double t_0 = -tan(x);
double t_1 = pow(sin(x), 2.0) / pow(cos(x), 2.0);
double t_2 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.95e-5) {
tmp = fma(fma(tan(x), tan(eps), 1.0), (t_2 / (1.0 - pow((tan(x) * tan(eps)), 2.0))), t_0);
} else if (eps <= 3.05e-5) {
tmp = fma(((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))), (eps * eps), fma(pow(eps, 3.0), (0.3333333333333333 + (t_1 + fma(0.3333333333333333, t_1, (pow(sin(x), 4.0) / pow(cos(x), 4.0))))), (eps + (eps * t_1))));
} else {
tmp = fma(t_2, (-1.0 / fma(tan(x), tan(eps), -1.0)), t_0);
}
return tmp;
}
function code(x, eps)
return Float64(tan(Float64(x + eps)) - tan(x))
end
↓
function code(x, eps)
t_0 = Float64(-tan(x))
t_1 = Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))
t_2 = Float64(tan(x) + tan(eps))
tmp = 0.0
if (eps <= -2.95e-5)
tmp = fma(fma(tan(x), tan(eps), 1.0), Float64(t_2 / Float64(1.0 - (Float64(tan(x) * tan(eps)) ^ 2.0))), t_0);
elseif (eps <= 3.05e-5)
tmp = fma(Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))), Float64(eps * eps), fma((eps ^ 3.0), Float64(0.3333333333333333 + Float64(t_1 + fma(0.3333333333333333, t_1, Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0))))), Float64(eps + Float64(eps * t_1))));
else
tmp = fma(t_2, Float64(-1.0 / fma(tan(x), tan(eps), -1.0)), t_0);
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[Tan[x], $MachinePrecision])}, Block[{t$95$1 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.95e-5], N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + 1.0), $MachinePrecision] * N[(t$95$2 / N[(1.0 - N[Power[N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[eps, 3.05e-5], N[(N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 + N[(t$95$1 + N[(0.3333333333333333 * t$95$1 + N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps + N[(eps * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[(-1.0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]]
\tan \left(x + \varepsilon\right) - \tan x
↓
\begin{array}{l}
t_0 := -\tan x\\
t_1 := \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_2 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.95 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{t_2}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, t_0\right)\\
\mathbf{elif}\;\varepsilon \leq 3.05 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}, \varepsilon \cdot \varepsilon, \mathsf{fma}\left({\varepsilon}^{3}, 0.3333333333333333 + \left(t_1 + \mathsf{fma}\left(0.3333333333333333, t_1, \frac{{\sin x}^{4}}{{\cos x}^{4}}\right)\right), \varepsilon + \varepsilon \cdot t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_2, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, t_0\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.3 |
|---|
| Cost | 78984 |
|---|
\[\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \frac{{\sin x}^{2}}{\cos x}\\
\mathbf{if}\;\varepsilon \leq -0.00034:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 0.00039:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(\cos x + t_1\right) + {\varepsilon}^{3} \cdot \left(\cos x \cdot 0.3333333333333333 + 0.3333333333333333 \cdot t_1\right)}{1 - \tan x \cdot \tan \varepsilon}}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, -\tan x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.3 |
|---|
| Cost | 65736 |
|---|
\[\begin{array}{l}
t_0 := -\tan x\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.35 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{t_1}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, t_0\right)\\
\mathbf{elif}\;\varepsilon \leq 2.8 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, t_0\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 65092 |
|---|
\[\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := -\tan x\\
t_2 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -5.5 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{t_2}{1 - {t_0}^{2}}, t_1\right)\\
\mathbf{elif}\;\varepsilon \leq 8.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(\cos x + \frac{{\sin x}^{2}}{\cos x}\right)}{1 - t_0}}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_2, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, t_1\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.4 |
|---|
| Cost | 46088 |
|---|
\[\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -7 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 4.1 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(\cos x + \frac{{\sin x}^{2}}{\cos x}\right)}{1 - \tan x \cdot \tan \varepsilon}}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, -\tan x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.4 |
|---|
| Cost | 45704 |
|---|
\[\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 1.75 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, -\tan x\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.4 |
|---|
| Cost | 39432 |
|---|
\[\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.9 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 1.95 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{-1}{t_1 + -1}, -\tan x\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.4 |
|---|
| Cost | 39432 |
|---|
\[\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 1.95 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{-1}{\tan x \cdot \tan \varepsilon + -1}, -\tan x\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 0.4 |
|---|
| Cost | 32969 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.95 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 1.95 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 14.4 |
|---|
| Cost | 13448 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -8.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{elif}\;\varepsilon \leq 0.000135:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon - \tan x\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 26.8 |
|---|
| Cost | 13257 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00048 \lor \neg \left(\varepsilon \leq 1.25 \cdot 10^{-6}\right):\\
\;\;\;\;\tan \varepsilon - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \left(0.5 - \frac{\cos \left(x + x\right)}{2}\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 27.3 |
|---|
| Cost | 12992 |
|---|
\[\frac{\sin \varepsilon}{\cos \varepsilon}
\]
| Alternative 12 |
|---|
| Error | 43.8 |
|---|
| Cost | 7104 |
|---|
\[\varepsilon + \varepsilon \cdot \left(0.5 - \frac{\cos \left(x + x\right)}{2}\right)
\]
| Alternative 13 |
|---|
| Error | 47.0 |
|---|
| Cost | 704 |
|---|
\[\varepsilon + \left(-1 + \left(1 + x \cdot \left(\varepsilon \cdot x\right)\right)\right)
\]
| Alternative 14 |
|---|
| Error | 47.6 |
|---|
| Cost | 448 |
|---|
\[\varepsilon + \varepsilon \cdot \left(x \cdot x\right)
\]
| Alternative 15 |
|---|
| Error | 47.5 |
|---|
| Cost | 448 |
|---|
\[\varepsilon + x \cdot \left(\varepsilon \cdot x\right)
\]