
(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 14 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 (fma (tan x) (tan eps) -1.0))
(t_1 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(t_2 (+ (tan x) (tan eps))))
(if (<= eps -2.85e-7)
(- (/ t_2 (+ 1.0 (- -1.0 t_0))) (tan x))
(if (<= eps 9.6e-8)
(fma eps t_1 (/ (pow eps 2.0) (/ (/ (cos x) t_1) (sin x))))
(- (/ t_2 (- t_0)) (tan x))))))
double code(double x, double eps) {
double t_0 = fma(tan(x), tan(eps), -1.0);
double t_1 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
double t_2 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.85e-7) {
tmp = (t_2 / (1.0 + (-1.0 - t_0))) - tan(x);
} else if (eps <= 9.6e-8) {
tmp = fma(eps, t_1, (pow(eps, 2.0) / ((cos(x) / t_1) / sin(x))));
} else {
tmp = (t_2 / -t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = fma(tan(x), tan(eps), -1.0) t_1 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))) t_2 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -2.85e-7) tmp = Float64(Float64(t_2 / Float64(1.0 + Float64(-1.0 - t_0))) - tan(x)); elseif (eps <= 9.6e-8) tmp = fma(eps, t_1, Float64((eps ^ 2.0) / Float64(Float64(cos(x) / t_1) / sin(x)))); else tmp = Float64(Float64(t_2 / Float64(-t_0)) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.85e-7], N[(N[(t$95$2 / N[(1.0 + N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9.6e-8], N[(eps * t$95$1 + N[(N[Power[eps, 2.0], $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] / t$95$1), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 / (-t$95$0)), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
t_1 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_2 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.85 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_2}{1 + \left(-1 - t_0\right)} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 9.6 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, t_1, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{t_1}}{\sin x}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2}{-t_0} - \tan x\\
\end{array}
\end{array}
if eps < -2.8500000000000002e-7Initial program 60.8%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
expm1-log1p-u91.6%
expm1-udef91.6%
log1p-udef91.6%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
if -2.8500000000000002e-7 < eps < 9.59999999999999994e-8Initial program 32.1%
Taylor expanded in eps around 0 99.6%
fma-def99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
associate-/l*99.6%
*-commutative99.6%
associate-/r*99.6%
Simplified99.6%
if 9.59999999999999994e-8 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
expm1-log1p-u86.6%
expm1-udef86.5%
log1p-udef86.5%
add-exp-log99.5%
Applied egg-rr99.5%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
sub-neg99.7%
associate--r+99.7%
metadata-eval99.7%
sub0-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (fma (tan x) (tan eps) -1.0))
(t_1 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(t_2 (+ (tan x) (tan eps))))
(if (<= eps -2.15e-7)
(- (/ t_2 (+ 1.0 (- -1.0 t_0))) (tan x))
(if (<= eps 1e-7)
(+ (* eps t_1) (/ (* (pow eps 2.0) (* (sin x) t_1)) (cos x)))
(- (/ t_2 (- t_0)) (tan x))))))
double code(double x, double eps) {
double t_0 = fma(tan(x), tan(eps), -1.0);
double t_1 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
double t_2 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.15e-7) {
tmp = (t_2 / (1.0 + (-1.0 - t_0))) - tan(x);
} else if (eps <= 1e-7) {
tmp = (eps * t_1) + ((pow(eps, 2.0) * (sin(x) * t_1)) / cos(x));
} else {
tmp = (t_2 / -t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = fma(tan(x), tan(eps), -1.0) t_1 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))) t_2 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -2.15e-7) tmp = Float64(Float64(t_2 / Float64(1.0 + Float64(-1.0 - t_0))) - tan(x)); elseif (eps <= 1e-7) tmp = Float64(Float64(eps * t_1) + Float64(Float64((eps ^ 2.0) * Float64(sin(x) * t_1)) / cos(x))); else tmp = Float64(Float64(t_2 / Float64(-t_0)) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.15e-7], N[(N[(t$95$2 / N[(1.0 + N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-7], N[(N[(eps * t$95$1), $MachinePrecision] + N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 / (-t$95$0)), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
t_1 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_2 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.15 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_2}{1 + \left(-1 - t_0\right)} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-7}:\\
\;\;\;\;\varepsilon \cdot t_1 + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot t_1\right)}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2}{-t_0} - \tan x\\
\end{array}
\end{array}
if eps < -2.1500000000000001e-7Initial program 60.8%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
expm1-log1p-u91.6%
expm1-udef91.6%
log1p-udef91.6%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
if -2.1500000000000001e-7 < eps < 9.9999999999999995e-8Initial program 32.1%
Taylor expanded in eps around 0 99.6%
if 9.9999999999999995e-8 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
expm1-log1p-u86.6%
expm1-udef86.5%
log1p-udef86.5%
add-exp-log99.5%
Applied egg-rr99.5%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
sub-neg99.7%
associate--r+99.7%
metadata-eval99.7%
sub0-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (fma (tan x) (tan eps) -1.0)) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -7.2e-7)
(- (/ t_1 (+ 1.0 (- -1.0 t_0))) (tan x))
(if (<= eps 1e-7)
(/
(* eps (+ (cos x) (/ (pow (sin x) 2.0) (cos x))))
(* (cos x) (- 1.0 (* (tan x) (tan eps)))))
(- (/ t_1 (- t_0)) (tan x))))))
double code(double x, double eps) {
double t_0 = fma(tan(x), tan(eps), -1.0);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -7.2e-7) {
tmp = (t_1 / (1.0 + (-1.0 - t_0))) - tan(x);
} else if (eps <= 1e-7) {
tmp = (eps * (cos(x) + (pow(sin(x), 2.0) / cos(x)))) / (cos(x) * (1.0 - (tan(x) * tan(eps))));
} else {
tmp = (t_1 / -t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = fma(tan(x), tan(eps), -1.0) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -7.2e-7) tmp = Float64(Float64(t_1 / Float64(1.0 + Float64(-1.0 - t_0))) - tan(x)); elseif (eps <= 1e-7) tmp = Float64(Float64(eps * Float64(cos(x) + Float64((sin(x) ^ 2.0) / cos(x)))) / Float64(cos(x) * Float64(1.0 - Float64(tan(x) * tan(eps))))); else tmp = Float64(Float64(t_1 / Float64(-t_0)) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7.2e-7], N[(N[(t$95$1 / N[(1.0 + N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-7], N[(N[(eps * N[(N[Cos[x], $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / (-t$95$0)), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -7.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_1}{1 + \left(-1 - t_0\right)} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-7}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(\cos x + \frac{{\sin x}^{2}}{\cos x}\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{-t_0} - \tan x\\
\end{array}
\end{array}
if eps < -7.19999999999999989e-7Initial program 60.8%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
expm1-log1p-u91.6%
expm1-udef91.6%
log1p-udef91.6%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
if -7.19999999999999989e-7 < eps < 9.9999999999999995e-8Initial program 32.1%
tan-sum32.9%
tan-quot32.4%
frac-sub32.4%
Applied egg-rr32.4%
Taylor expanded in eps around 0 99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 9.9999999999999995e-8 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
expm1-log1p-u86.6%
expm1-udef86.5%
log1p-udef86.5%
add-exp-log99.5%
Applied egg-rr99.5%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
sub-neg99.7%
associate--r+99.7%
metadata-eval99.7%
sub0-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (fma (tan x) (tan eps) -1.0)) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -3.8e-9)
(- (/ t_1 (+ 1.0 (- -1.0 t_0))) (tan x))
(if (<= eps 2.8e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_1 (- t_0)) (tan x))))))
double code(double x, double eps) {
double t_0 = fma(tan(x), tan(eps), -1.0);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.8e-9) {
tmp = (t_1 / (1.0 + (-1.0 - t_0))) - tan(x);
} else if (eps <= 2.8e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_1 / -t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = fma(tan(x), tan(eps), -1.0) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.8e-9) tmp = Float64(Float64(t_1 / Float64(1.0 + Float64(-1.0 - t_0))) - tan(x)); elseif (eps <= 2.8e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_1 / Float64(-t_0)) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.8e-9], N[(N[(t$95$1 / N[(1.0 + N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.8e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$1 / (-t$95$0)), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_1}{1 + \left(-1 - t_0\right)} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{-t_0} - \tan x\\
\end{array}
\end{array}
if eps < -3.80000000000000011e-9Initial program 60.8%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
expm1-log1p-u91.6%
expm1-udef91.6%
log1p-udef91.6%
add-exp-log99.6%
Applied egg-rr99.6%
associate--l+99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
if -3.80000000000000011e-9 < eps < 2.79999999999999984e-9Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
if 2.79999999999999984e-9 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
expm1-log1p-u86.6%
expm1-udef86.5%
log1p-udef86.5%
add-exp-log99.5%
Applied egg-rr99.5%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
sub-neg99.7%
associate--r+99.7%
metadata-eval99.7%
sub0-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -1.9e-9)
(- (* t_0 (/ 1.0 (- 1.0 (* (tan x) (tan eps))))) (tan x))
(if (<= eps 5.5e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_0 (- (fma (tan x) (tan eps) -1.0))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -1.9e-9) {
tmp = (t_0 * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
} else if (eps <= 5.5e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_0 / -fma(tan(x), tan(eps), -1.0)) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -1.9e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - tan(x)); elseif (eps <= 5.5e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_0 / Float64(-fma(tan(x), tan(eps), -1.0))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.9e-9], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.5e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$0 / (-N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision])), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.9 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 5.5 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{-\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)} - \tan x\\
\end{array}
\end{array}
if eps < -1.90000000000000006e-9Initial program 60.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -1.90000000000000006e-9 < eps < 5.4999999999999996e-9Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
if 5.4999999999999996e-9 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
expm1-log1p-u86.6%
expm1-udef86.5%
log1p-udef86.5%
add-exp-log99.5%
Applied egg-rr99.5%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
sub-neg99.7%
associate--r+99.7%
metadata-eval99.7%
sub0-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -3.65e-9)
(- (* t_0 (/ 1.0 (- 1.0 (* (tan x) (tan eps))))) (tan x))
(if (<= eps 3.8e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.65e-9) {
tmp = (t_0 * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
} else if (eps <= 3.8e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.65e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - tan(x)); elseif (eps <= 3.8e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.65e-9], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.8e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / 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 -3.65 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -3.65000000000000001e-9Initial program 60.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -3.65000000000000001e-9 < eps < 3.80000000000000011e-9Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
if 3.80000000000000011e-9 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
tan-quot99.6%
clear-num99.6%
un-div-inv99.6%
clear-num99.6%
tan-quot99.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -4.2e-9) (not (<= eps 2.8e-9))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -4.2e-9) || !(eps <= 2.8e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -4.2e-9) || !(eps <= 2.8e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -4.2e-9], N[Not[LessEqual[eps, 2.8e-9]], $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[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -4.2 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2.8 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -4.20000000000000039e-9 or 2.79999999999999984e-9 < eps Initial program 55.5%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
if -4.20000000000000039e-9 < eps < 2.79999999999999984e-9Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -3.35e-9)
(- (* t_0 (/ 1.0 t_1)) (tan x))
(if (<= eps 2.8e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ 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 <= -3.35e-9) {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
} else if (eps <= 2.8e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_0 / t_1) - 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 <= -3.35e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); elseif (eps <= 2.8e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_0 / t_1) - tan(x)); 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[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.35e-9], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.8e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $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.35 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -3.34999999999999981e-9Initial program 60.8%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -3.34999999999999981e-9 < eps < 2.79999999999999984e-9Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
if 2.79999999999999984e-9 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.1e-6)
(tan eps)
(if (<= eps 1e-7)
(fma eps (pow (tan x) 2.0) eps)
(- (+ (tan x) (tan eps)) (tan x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.1e-6) {
tmp = tan(eps);
} else if (eps <= 1e-7) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (tan(x) + tan(eps)) - tan(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -1.1e-6) tmp = tan(eps); elseif (eps <= 1e-7) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(tan(x) + tan(eps)) - tan(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -1.1e-6], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1e-7], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-6}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan x + \tan \varepsilon\right) - \tan x\\
\end{array}
\end{array}
if eps < -1.1000000000000001e-6Initial program 60.8%
Taylor expanded in x around 0 62.7%
tan-quot62.9%
expm1-log1p-u49.4%
expm1-udef49.0%
Applied egg-rr49.0%
expm1-def49.4%
expm1-log1p62.9%
Simplified62.9%
if -1.1000000000000001e-6 < eps < 9.9999999999999995e-8Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
if 9.9999999999999995e-8 < eps Initial program 50.8%
tan-sum99.7%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.7%
expm1-log1p-u86.6%
expm1-udef86.5%
log1p-udef86.5%
add-exp-log99.5%
Applied egg-rr99.5%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
sub-neg99.7%
associate--r+99.7%
metadata-eval99.7%
sub0-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in x around 0 53.6%
Final simplification78.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -5.5e-6) (not (<= eps 1e-7))) (tan eps) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -5.5e-6) || !(eps <= 1e-7)) {
tmp = tan(eps);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -5.5e-6) || !(eps <= 1e-7)) tmp = tan(eps); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -5.5e-6], N[Not[LessEqual[eps, 1e-7]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -5.5 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 10^{-7}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -5.4999999999999999e-6 or 9.9999999999999995e-8 < eps Initial program 55.5%
Taylor expanded in x around 0 57.8%
tan-quot58.0%
expm1-log1p-u42.4%
expm1-udef41.8%
Applied egg-rr41.8%
expm1-def42.4%
expm1-log1p58.0%
Simplified58.0%
if -5.4999999999999999e-6 < eps < 9.9999999999999995e-8Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-def99.3%
Simplified99.3%
Final simplification78.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -6e-6) (not (<= eps 1e-7))) (tan eps) (* eps (+ 1.0 (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -6e-6) || !(eps <= 1e-7)) {
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 <= (-6d-6)) .or. (.not. (eps <= 1d-7))) 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 <= -6e-6) || !(eps <= 1e-7)) {
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 <= -6e-6) or not (eps <= 1e-7): 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 <= -6e-6) || !(eps <= 1e-7)) 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 <= -6e-6) || ~((eps <= 1e-7))) tmp = tan(eps); else tmp = eps * (1.0 + (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -6e-6], N[Not[LessEqual[eps, 1e-7]], $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 -6 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 10^{-7}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + {\tan x}^{2}\right)\\
\end{array}
\end{array}
if eps < -6.0000000000000002e-6 or 9.9999999999999995e-8 < eps Initial program 55.5%
Taylor expanded in x around 0 57.8%
tan-quot58.0%
expm1-log1p-u42.4%
expm1-udef41.8%
Applied egg-rr41.8%
expm1-def42.4%
expm1-log1p58.0%
Simplified58.0%
if -6.0000000000000002e-6 < eps < 9.9999999999999995e-8Initial program 32.1%
add-cube-cbrt31.6%
pow331.6%
Applied egg-rr31.6%
Taylor expanded in eps around 0 97.3%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified97.3%
rem-cube-cbrt99.2%
*-commutative99.2%
*-un-lft-identity99.2%
*-un-lft-identity99.2%
+-commutative99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.2%
tan-quot99.1%
pow299.1%
Applied egg-rr99.1%
Final simplification77.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -6e-6) (not (<= eps 1e-7))) (tan eps) (+ eps (* eps (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -6e-6) || !(eps <= 1e-7)) {
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 <= (-6d-6)) .or. (.not. (eps <= 1d-7))) 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 <= -6e-6) || !(eps <= 1e-7)) {
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 <= -6e-6) or not (eps <= 1e-7): 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 <= -6e-6) || !(eps <= 1e-7)) 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 <= -6e-6) || ~((eps <= 1e-7))) tmp = tan(eps); else tmp = eps + (eps * (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -6e-6], N[Not[LessEqual[eps, 1e-7]], $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 -6 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 10^{-7}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\end{array}
if eps < -6.0000000000000002e-6 or 9.9999999999999995e-8 < eps Initial program 55.5%
Taylor expanded in x around 0 57.8%
tan-quot58.0%
expm1-log1p-u42.4%
expm1-udef41.8%
Applied egg-rr41.8%
expm1-def42.4%
expm1-log1p58.0%
Simplified58.0%
if -6.0000000000000002e-6 < eps < 9.9999999999999995e-8Initial program 32.1%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv97.3%
metadata-eval97.3%
*-lft-identity97.3%
Simplified99.2%
+-commutative99.2%
distribute-lft-in99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.3%
tan-quot99.2%
pow299.2%
*-rgt-identity99.2%
Applied egg-rr99.2%
Final simplification78.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 44.2%
Taylor expanded in x around 0 58.0%
tan-quot58.1%
expm1-log1p-u50.1%
expm1-udef24.2%
Applied egg-rr24.2%
expm1-def50.1%
expm1-log1p58.1%
Simplified58.1%
Final simplification58.1%
(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 44.2%
Taylor expanded in x around 0 58.0%
Taylor expanded in eps around 0 30.2%
Final simplification30.2%
(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 2023312
(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)))