
(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:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (sin x) 2.0))
(t_1 (pow (cos x) 2.0))
(t_2 (fma (tan x) (tan eps) -1.0))
(t_3 (+ (tan x) (tan eps)))
(t_4 (/ t_0 t_1))
(t_5 (+ 1.0 t_4)))
(if (<= eps -5e-5)
(/ (fma (cos x) t_3 (* (sin x) t_2)) (* t_2 (- (cos x))))
(if (<= eps 5.4e-6)
(+
(* eps t_5)
(+
(*
(pow eps 3.0)
(+
0.3333333333333333
(- (* t_4 0.3333333333333333) (/ (* t_0 (- -1.0 t_4)) t_1))))
(/ (* (pow eps 2.0) (* (sin x) t_5)) (cos x))))
(- (- (tan x)) (/ t_3 t_2))))))
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 = fma(tan(x), tan(eps), -1.0);
double t_3 = tan(x) + tan(eps);
double t_4 = t_0 / t_1;
double t_5 = 1.0 + t_4;
double tmp;
if (eps <= -5e-5) {
tmp = fma(cos(x), t_3, (sin(x) * t_2)) / (t_2 * -cos(x));
} else if (eps <= 5.4e-6) {
tmp = (eps * t_5) + ((pow(eps, 3.0) * (0.3333333333333333 + ((t_4 * 0.3333333333333333) - ((t_0 * (-1.0 - t_4)) / t_1)))) + ((pow(eps, 2.0) * (sin(x) * t_5)) / cos(x)));
} else {
tmp = -tan(x) - (t_3 / t_2);
}
return tmp;
}
function code(x, eps) t_0 = sin(x) ^ 2.0 t_1 = cos(x) ^ 2.0 t_2 = fma(tan(x), tan(eps), -1.0) t_3 = Float64(tan(x) + tan(eps)) t_4 = Float64(t_0 / t_1) t_5 = Float64(1.0 + t_4) tmp = 0.0 if (eps <= -5e-5) tmp = Float64(fma(cos(x), t_3, Float64(sin(x) * t_2)) / Float64(t_2 * Float64(-cos(x)))); elseif (eps <= 5.4e-6) tmp = Float64(Float64(eps * t_5) + Float64(Float64((eps ^ 3.0) * Float64(0.3333333333333333 + Float64(Float64(t_4 * 0.3333333333333333) - Float64(Float64(t_0 * Float64(-1.0 - t_4)) / t_1)))) + Float64(Float64((eps ^ 2.0) * Float64(sin(x) * t_5)) / cos(x)))); else tmp = Float64(Float64(-tan(x)) - Float64(t_3 / t_2)); end return 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[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 / t$95$1), $MachinePrecision]}, Block[{t$95$5 = N[(1.0 + t$95$4), $MachinePrecision]}, If[LessEqual[eps, -5e-5], N[(N[(N[Cos[x], $MachinePrecision] * t$95$3 + N[(N[Sin[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * (-N[Cos[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.4e-6], N[(N[(eps * t$95$5), $MachinePrecision] + N[(N[(N[Power[eps, 3.0], $MachinePrecision] * N[(0.3333333333333333 + N[(N[(t$95$4 * 0.3333333333333333), $MachinePrecision] - N[(N[(t$95$0 * N[(-1.0 - t$95$4), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Tan[x], $MachinePrecision]) - N[(t$95$3 / t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := {\cos x}^{2}\\
t_2 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
t_3 := \tan x + \tan \varepsilon\\
t_4 := \frac{t_0}{t_1}\\
t_5 := 1 + t_4\\
\mathbf{if}\;\varepsilon \leq -5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos x, t_3, \sin x \cdot t_2\right)}{t_2 \cdot \left(-\cos x\right)}\\
\mathbf{elif}\;\varepsilon \leq 5.4 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon \cdot t_5 + \left({\varepsilon}^{3} \cdot \left(0.3333333333333333 + \left(t_4 \cdot 0.3333333333333333 - \frac{t_0 \cdot \left(-1 - t_4\right)}{t_1}\right)\right) + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot t_5\right)}{\cos x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\tan x\right) - \frac{t_3}{t_2}\\
\end{array}
\end{array}
if eps < -5.00000000000000024e-5Initial program 59.1%
add-sqr-sqrt28.3%
pow228.3%
Applied egg-rr28.3%
unpow228.3%
add-sqr-sqrt59.1%
tan-sum99.5%
div-inv99.6%
frac-2neg99.6%
metadata-eval99.6%
associate-*r/99.5%
sub-neg99.5%
distribute-neg-in99.5%
metadata-eval99.5%
distribute-lft-neg-in99.5%
add-sqr-sqrt38.2%
Applied egg-rr99.5%
*-commutative99.5%
neg-mul-199.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
frac-2neg99.6%
tan-quot99.6%
frac-sub99.6%
remove-double-neg99.6%
Applied egg-rr99.6%
*-commutative99.6%
fma-neg99.6%
distribute-lft-neg-out99.6%
remove-double-neg99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
if -5.00000000000000024e-5 < eps < 5.39999999999999997e-6Initial program 29.9%
add-sqr-sqrt15.3%
pow215.3%
Applied egg-rr15.3%
unpow215.3%
add-sqr-sqrt29.9%
tan-sum31.0%
div-inv31.0%
frac-2neg31.0%
metadata-eval31.0%
associate-*r/31.0%
sub-neg31.0%
distribute-neg-in31.0%
metadata-eval31.0%
distribute-lft-neg-in31.0%
add-sqr-sqrt16.3%
Applied egg-rr31.0%
*-commutative31.0%
neg-mul-131.0%
+-commutative31.0%
fma-def31.0%
Simplified31.0%
Taylor expanded in eps around 0 99.6%
if 5.39999999999999997e-6 < eps Initial program 46.6%
add-sqr-sqrt21.1%
pow221.1%
Applied egg-rr21.1%
unpow221.1%
add-sqr-sqrt46.6%
tan-sum99.5%
div-inv99.5%
frac-2neg99.5%
metadata-eval99.5%
associate-*r/99.5%
sub-neg99.5%
distribute-neg-in99.5%
metadata-eval99.5%
distribute-lft-neg-in99.5%
add-sqr-sqrt56.2%
Applied egg-rr99.5%
*-commutative99.5%
neg-mul-199.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (fma (tan x) (tan eps) -1.0)))
(if (or (<= eps -1.45e-7) (not (<= eps 3.9e-19)))
(/
(fma (cos x) (+ (tan x) (tan eps)) (* (sin x) t_0))
(* t_0 (- (cos x))))
(+
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
(pow eps 2.0)
(+ (/ (pow (sin x) 3.0) (pow (cos x) 3.0)) (/ (sin x) (cos x))))))))
double code(double x, double eps) {
double t_0 = fma(tan(x), tan(eps), -1.0);
double tmp;
if ((eps <= -1.45e-7) || !(eps <= 3.9e-19)) {
tmp = fma(cos(x), (tan(x) + tan(eps)), (sin(x) * t_0)) / (t_0 * -cos(x));
} else {
tmp = (eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + (pow(eps, 2.0) * ((pow(sin(x), 3.0) / pow(cos(x), 3.0)) + (sin(x) / cos(x))));
}
return tmp;
}
function code(x, eps) t_0 = fma(tan(x), tan(eps), -1.0) tmp = 0.0 if ((eps <= -1.45e-7) || !(eps <= 3.9e-19)) tmp = Float64(fma(cos(x), Float64(tan(x) + tan(eps)), Float64(sin(x) * t_0)) / Float64(t_0 * Float64(-cos(x)))); else tmp = Float64(Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64((eps ^ 2.0) * Float64(Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) + Float64(sin(x) / cos(x))))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, If[Or[LessEqual[eps, -1.45e-7], N[Not[LessEqual[eps, 3.9e-19]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * (-N[Cos[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
\mathbf{if}\;\varepsilon \leq -1.45 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 3.9 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos x, \tan x + \tan \varepsilon, \sin x \cdot t_0\right)}{t_0 \cdot \left(-\cos x\right)}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{2} \cdot \left(\frac{{\sin x}^{3}}{{\cos x}^{3}} + \frac{\sin x}{\cos x}\right)\\
\end{array}
\end{array}
if eps < -1.4499999999999999e-7 or 3.89999999999999995e-19 < eps Initial program 53.9%
add-sqr-sqrt25.3%
pow225.3%
Applied egg-rr25.3%
unpow225.3%
add-sqr-sqrt53.9%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.4%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
frac-2neg99.4%
tan-quot99.4%
frac-sub99.3%
remove-double-neg99.3%
Applied egg-rr99.3%
*-commutative99.3%
fma-neg99.5%
distribute-lft-neg-out99.5%
remove-double-neg99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
if -1.4499999999999999e-7 < eps < 3.89999999999999995e-19Initial program 28.9%
tan-sum29.4%
div-inv29.4%
tan-quot29.3%
div-inv29.1%
prod-diff28.7%
Applied egg-rr28.7%
+-commutative28.7%
fma-udef28.7%
associate-+r+29.1%
unsub-neg29.1%
Simplified29.3%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -1.35e-7) (not (<= eps 2e-6)))
(- (- (tan x)) (/ (+ (tan x) (tan eps)) (fma (tan x) (tan eps) -1.0)))
(+
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
(pow eps 2.0)
(+ (/ (pow (sin x) 3.0) (pow (cos x) 3.0)) (/ (sin x) (cos x)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.35e-7) || !(eps <= 2e-6)) {
tmp = -tan(x) - ((tan(x) + tan(eps)) / fma(tan(x), tan(eps), -1.0));
} else {
tmp = (eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + (pow(eps, 2.0) * ((pow(sin(x), 3.0) / pow(cos(x), 3.0)) + (sin(x) / cos(x))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -1.35e-7) || !(eps <= 2e-6)) tmp = Float64(Float64(-tan(x)) - Float64(Float64(tan(x) + tan(eps)) / fma(tan(x), tan(eps), -1.0))); else tmp = Float64(Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64((eps ^ 2.0) * Float64(Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) + Float64(sin(x) / cos(x))))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -1.35e-7], N[Not[LessEqual[eps, 2e-6]], $MachinePrecision]], N[((-N[Tan[x], $MachinePrecision]) - N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.35 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\left(-\tan x\right) - \frac{\tan x + \tan \varepsilon}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{2} \cdot \left(\frac{{\sin x}^{3}}{{\cos x}^{3}} + \frac{\sin x}{\cos x}\right)\\
\end{array}
\end{array}
if eps < -1.35000000000000004e-7 or 1.99999999999999991e-6 < eps Initial program 53.9%
add-sqr-sqrt24.9%
pow224.9%
Applied egg-rr24.9%
unpow224.9%
add-sqr-sqrt53.9%
tan-sum99.5%
div-inv99.5%
frac-2neg99.5%
metadata-eval99.5%
associate-*r/99.5%
sub-neg99.5%
distribute-neg-in99.5%
metadata-eval99.5%
distribute-lft-neg-in99.5%
add-sqr-sqrt45.9%
Applied egg-rr99.5%
*-commutative99.5%
neg-mul-199.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
if -1.35000000000000004e-7 < eps < 1.99999999999999991e-6Initial program 29.3%
tan-sum30.4%
div-inv30.4%
tan-quot30.3%
div-inv30.1%
prod-diff29.8%
Applied egg-rr29.8%
+-commutative29.8%
fma-udef29.7%
associate-+r+30.1%
unsub-neg30.1%
Simplified30.3%
Taylor expanded in eps around 0 99.4%
+-commutative99.4%
mul-1-neg99.4%
unsub-neg99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps)))
(t_1 (* (tan x) (tan eps)))
(t_2 (- 1.0 t_1)))
(if (<= eps -3.1e-9)
(fma t_0 (/ 1.0 t_2) (- (tan x)))
(if (<= eps 3.9e-19)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(/ (fma t_0 (- (cos x)) (* (sin x) t_2)) (* (cos x) (+ -1.0 t_1)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = tan(x) * tan(eps);
double t_2 = 1.0 - t_1;
double tmp;
if (eps <= -3.1e-9) {
tmp = fma(t_0, (1.0 / t_2), -tan(x));
} else if (eps <= 3.9e-19) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = fma(t_0, -cos(x), (sin(x) * t_2)) / (cos(x) * (-1.0 + t_1));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(tan(x) * tan(eps)) t_2 = Float64(1.0 - t_1) tmp = 0.0 if (eps <= -3.1e-9) tmp = fma(t_0, Float64(1.0 / t_2), Float64(-tan(x))); elseif (eps <= 3.9e-19) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(fma(t_0, Float64(-cos(x)), Float64(sin(x) * t_2)) / Float64(cos(x) * Float64(-1.0 + t_1))); end return 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]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, If[LessEqual[eps, -3.1e-9], N[(t$95$0 * N[(1.0 / t$95$2), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 3.9e-19], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * (-N[Cos[x], $MachinePrecision]) + N[(N[Sin[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \tan x \cdot \tan \varepsilon\\
t_2 := 1 - t_1\\
\mathbf{if}\;\varepsilon \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_2}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 3.9 \cdot 10^{-19}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t_0, -\cos x, \sin x \cdot t_2\right)}{\cos x \cdot \left(-1 + t_1\right)}\\
\end{array}
\end{array}
if eps < -3.10000000000000005e-9Initial program 58.9%
tan-sum99.0%
div-inv99.1%
tan-quot99.1%
div-inv99.0%
prod-diff99.0%
Applied egg-rr99.0%
+-commutative99.0%
fma-udef99.0%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.0%
tan-quot99.0%
expm1-log1p-u86.7%
expm1-udef86.6%
Applied egg-rr86.6%
div-inv86.6%
expm1-def86.7%
expm1-log1p-u99.1%
fma-neg99.1%
Applied egg-rr99.1%
if -3.10000000000000005e-9 < eps < 3.89999999999999995e-19Initial program 29.1%
Taylor expanded in eps around 0 99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 3.89999999999999995e-19 < eps Initial program 46.7%
tan-sum99.1%
div-inv99.0%
tan-quot99.0%
div-inv98.9%
prod-diff99.0%
Applied egg-rr99.0%
+-commutative99.0%
fma-udef98.9%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.1%
expm1-log1p-u85.1%
expm1-udef85.0%
log1p-udef85.0%
add-exp-log99.0%
Applied egg-rr99.0%
frac-2neg99.0%
frac-sub98.9%
add-exp-log84.9%
log1p-udef84.9%
expm1-udef85.0%
expm1-log1p-u98.9%
Applied egg-rr98.9%
fma-neg99.2%
distribute-rgt-neg-out99.2%
remove-double-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
distribute-lft-neg-in99.2%
*-commutative99.2%
Simplified99.2%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.9e-9) (not (<= eps 3.9e-19))) (- (- (tan x)) (/ (+ (tan x) (tan eps)) (fma (tan x) (tan eps) -1.0))) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.9e-9) || !(eps <= 3.9e-19)) {
tmp = -tan(x) - ((tan(x) + tan(eps)) / fma(tan(x), tan(eps), -1.0));
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -2.9e-9) || !(eps <= 3.9e-19)) tmp = Float64(Float64(-tan(x)) - Float64(Float64(tan(x) + tan(eps)) / fma(tan(x), tan(eps), -1.0))); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -2.9e-9], N[Not[LessEqual[eps, 3.9e-19]], $MachinePrecision]], N[((-N[Tan[x], $MachinePrecision]) - N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.9 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.9 \cdot 10^{-19}\right):\\
\;\;\;\;\left(-\tan x\right) - \frac{\tan x + \tan \varepsilon}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -2.89999999999999991e-9 or 3.89999999999999995e-19 < eps Initial program 53.5%
add-sqr-sqrt25.2%
pow225.2%
Applied egg-rr25.2%
unpow225.2%
add-sqr-sqrt53.5%
tan-sum99.1%
div-inv99.1%
frac-2neg99.1%
metadata-eval99.1%
associate-*r/99.1%
sub-neg99.1%
distribute-neg-in99.1%
metadata-eval99.1%
distribute-lft-neg-in99.1%
add-sqr-sqrt46.1%
Applied egg-rr99.1%
*-commutative99.1%
neg-mul-199.1%
+-commutative99.1%
fma-def99.2%
Simplified99.2%
if -2.89999999999999991e-9 < eps < 3.89999999999999995e-19Initial program 29.1%
Taylor expanded in eps around 0 99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- (tan x))))
(if (<= eps -3.2e-9)
(fma t_0 (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_1)
(if (<= eps 3.9e-19)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- t_1 (/ t_0 (fma (tan x) (tan eps) -1.0)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = -tan(x);
double tmp;
if (eps <= -3.2e-9) {
tmp = fma(t_0, (1.0 / (1.0 - (tan(x) * tan(eps)))), t_1);
} else if (eps <= 3.9e-19) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = t_1 - (t_0 / fma(tan(x), tan(eps), -1.0));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(-tan(x)) tmp = 0.0 if (eps <= -3.2e-9) tmp = fma(t_0, Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_1); elseif (eps <= 3.9e-19) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(t_1 - Float64(t_0 / fma(tan(x), tan(eps), -1.0))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[Tan[x], $MachinePrecision])}, If[LessEqual[eps, -3.2e-9], N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[eps, 3.9e-19], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - N[(t$95$0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := -\tan x\\
\mathbf{if}\;\varepsilon \leq -3.2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_1\right)\\
\mathbf{elif}\;\varepsilon \leq 3.9 \cdot 10^{-19}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 - \frac{t_0}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\end{array}
\end{array}
if eps < -3.20000000000000012e-9Initial program 58.9%
tan-sum99.0%
div-inv99.1%
tan-quot99.1%
div-inv99.0%
prod-diff99.0%
Applied egg-rr99.0%
+-commutative99.0%
fma-udef99.0%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.0%
tan-quot99.0%
expm1-log1p-u86.7%
expm1-udef86.6%
Applied egg-rr86.6%
div-inv86.6%
expm1-def86.7%
expm1-log1p-u99.1%
fma-neg99.1%
Applied egg-rr99.1%
if -3.20000000000000012e-9 < eps < 3.89999999999999995e-19Initial program 29.1%
Taylor expanded in eps around 0 99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 3.89999999999999995e-19 < eps Initial program 46.7%
add-sqr-sqrt22.0%
pow222.0%
Applied egg-rr22.0%
unpow222.0%
add-sqr-sqrt46.7%
tan-sum99.1%
div-inv99.0%
frac-2neg99.0%
metadata-eval99.0%
associate-*r/99.1%
sub-neg99.1%
distribute-neg-in99.1%
metadata-eval99.1%
distribute-lft-neg-in99.1%
add-sqr-sqrt57.2%
Applied egg-rr99.1%
*-commutative99.1%
neg-mul-199.1%
+-commutative99.1%
fma-def99.2%
Simplified99.2%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.7e-9) (not (<= eps 3.9e-19))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.7e-9) || !(eps <= 3.9e-19)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(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.7d-9)) .or. (.not. (eps <= 3.9d-19))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.7e-9) || !(eps <= 3.9e-19)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.7e-9) or not (eps <= 3.9e-19): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.7e-9) || !(eps <= 3.9e-19)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.7e-9) || ~((eps <= 3.9e-19))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.7e-9], N[Not[LessEqual[eps, 3.9e-19]], $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[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.7 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.9 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -1.6999999999999999e-9 or 3.89999999999999995e-19 < eps Initial program 53.5%
tan-sum99.1%
div-inv99.1%
*-un-lft-identity99.1%
prod-diff99.1%
*-commutative99.1%
*-un-lft-identity99.1%
*-commutative99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
+-commutative99.1%
fma-udef99.1%
associate-+r+99.1%
unsub-neg99.1%
Simplified99.1%
if -1.6999999999999999e-9 < eps < 3.89999999999999995e-19Initial program 29.1%
Taylor expanded in eps around 0 99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -3e-9)
(- (* t_0 (/ 1.0 t_1)) (tan x))
(if (<= eps 3.9e-19)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 t_1) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -3e-9) {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
} else if (eps <= 3.9e-19) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / t_1) - 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 = 1.0d0 - (tan(x) * tan(eps))
if (eps <= (-3d-9)) then
tmp = (t_0 * (1.0d0 / t_1)) - tan(x)
else if (eps <= 3.9d-19) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / t_1) - 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 = 1.0 - (Math.tan(x) * Math.tan(eps));
double tmp;
if (eps <= -3e-9) {
tmp = (t_0 * (1.0 / t_1)) - Math.tan(x);
} else if (eps <= 3.9e-19) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 / t_1) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = 1.0 - (math.tan(x) * math.tan(eps)) tmp = 0 if eps <= -3e-9: tmp = (t_0 * (1.0 / t_1)) - math.tan(x) elif eps <= 3.9e-19: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 / t_1) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -3e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); elseif (eps <= 3.9e-19) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 / t_1) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = 1.0 - (tan(x) * tan(eps)); tmp = 0.0; if (eps <= -3e-9) tmp = (t_0 * (1.0 / t_1)) - tan(x); elseif (eps <= 3.9e-19) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / t_1) - 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[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3e-9], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.9e-19], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.9 \cdot 10^{-19}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -2.99999999999999998e-9Initial program 58.9%
tan-sum99.0%
div-inv99.1%
Applied egg-rr99.1%
if -2.99999999999999998e-9 < eps < 3.89999999999999995e-19Initial program 29.1%
Taylor expanded in eps around 0 99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 3.89999999999999995e-19 < eps Initial program 46.7%
tan-sum99.1%
div-inv99.0%
*-un-lft-identity99.0%
prod-diff99.0%
*-commutative99.0%
*-un-lft-identity99.0%
*-commutative99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
+-commutative99.0%
fma-udef99.0%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.1%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.45e-7)
(tan eps)
(if (<= eps 4e-6)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (- (tan x)) (/ (+ (tan x) (tan eps)) -1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.45e-7) {
tmp = tan(eps);
} else if (eps <= 4e-6) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = -tan(x) - ((tan(x) + tan(eps)) / -1.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-1.45d-7)) then
tmp = tan(eps)
else if (eps <= 4d-6) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = -tan(x) - ((tan(x) + tan(eps)) / (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -1.45e-7) {
tmp = Math.tan(eps);
} else if (eps <= 4e-6) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = -Math.tan(x) - ((Math.tan(x) + Math.tan(eps)) / -1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.45e-7: tmp = math.tan(eps) elif eps <= 4e-6: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = -math.tan(x) - ((math.tan(x) + math.tan(eps)) / -1.0) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.45e-7) tmp = tan(eps); elseif (eps <= 4e-6) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(-tan(x)) - Float64(Float64(tan(x) + tan(eps)) / -1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.45e-7) tmp = tan(eps); elseif (eps <= 4e-6) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = -tan(x) - ((tan(x) + tan(eps)) / -1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.45e-7], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 4e-6], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Tan[x], $MachinePrecision]) - N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.45 \cdot 10^{-7}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\tan x\right) - \frac{\tan x + \tan \varepsilon}{-1}\\
\end{array}
\end{array}
if eps < -1.4499999999999999e-7Initial program 59.6%
Taylor expanded in x around 0 63.0%
tan-quot63.3%
expm1-log1p-u49.9%
expm1-udef48.9%
Applied egg-rr48.9%
expm1-def49.9%
expm1-log1p63.3%
Simplified63.3%
if -1.4499999999999999e-7 < eps < 3.99999999999999982e-6Initial program 29.3%
Taylor expanded in eps around 0 98.8%
cancel-sign-sub-inv98.8%
metadata-eval98.8%
*-lft-identity98.8%
Simplified98.8%
if 3.99999999999999982e-6 < eps Initial program 46.6%
add-sqr-sqrt21.1%
pow221.1%
Applied egg-rr21.1%
unpow221.1%
add-sqr-sqrt46.6%
tan-sum99.5%
div-inv99.5%
frac-2neg99.5%
metadata-eval99.5%
associate-*r/99.5%
sub-neg99.5%
distribute-neg-in99.5%
metadata-eval99.5%
distribute-lft-neg-in99.5%
add-sqr-sqrt56.2%
Applied egg-rr99.5%
*-commutative99.5%
neg-mul-199.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around 0 49.8%
Final simplification76.0%
(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}
Initial program 42.8%
Taylor expanded in x around 0 59.4%
tan-quot59.5%
expm1-log1p-u51.3%
expm1-udef25.5%
Applied egg-rr25.5%
expm1-def51.3%
expm1-log1p59.5%
Simplified59.5%
Final simplification59.5%
(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}
Initial program 42.8%
Taylor expanded in x around 0 59.4%
Taylor expanded in eps around 0 30.6%
Final simplification30.6%
(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}
herbie shell --seed 2023333
(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)))