
(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 15 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
(/
(tan eps)
(- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x)))))))
(if (<= eps -1.8e-6)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan x) (/ 1.0 (tan eps)))))
(tan x))
(if (<= eps 1e-10)
(+
t_0
(+
(/ eps (/ (pow (cos x) 2.0) (pow (sin x) 2.0)))
(/ (* eps eps) (/ (pow (cos x) 3.0) (pow (sin x) 3.0)))))
(+
t_0
(+
(* (tan x) 0.0)
(* (tan x) (+ (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) -1.0))))))))
double code(double x, double eps) {
double t_0 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))));
double tmp;
if (eps <= -1.8e-6) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 1e-10) {
tmp = t_0 + ((eps / (pow(cos(x), 2.0) / pow(sin(x), 2.0))) + ((eps * eps) / (pow(cos(x), 3.0) / pow(sin(x), 3.0))));
} else {
tmp = t_0 + ((tan(x) * 0.0) + (tan(x) * ((1.0 / (1.0 - (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) :: t_0
real(8) :: tmp
t_0 = tan(eps) / (1.0d0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))))
if (eps <= (-1.8d-6)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 1d-10) then
tmp = t_0 + ((eps / ((cos(x) ** 2.0d0) / (sin(x) ** 2.0d0))) + ((eps * eps) / ((cos(x) ** 3.0d0) / (sin(x) ** 3.0d0))))
else
tmp = t_0 + ((tan(x) * 0.0d0) + (tan(x) * ((1.0d0 / (1.0d0 - (tan(x) * tan(eps)))) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) / (1.0 - ((Math.sin(eps) / Math.cos(eps)) * (Math.sin(x) / Math.cos(x))));
double tmp;
if (eps <= -1.8e-6) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 1e-10) {
tmp = t_0 + ((eps / (Math.pow(Math.cos(x), 2.0) / Math.pow(Math.sin(x), 2.0))) + ((eps * eps) / (Math.pow(Math.cos(x), 3.0) / Math.pow(Math.sin(x), 3.0))));
} else {
tmp = t_0 + ((Math.tan(x) * 0.0) + (Math.tan(x) * ((1.0 / (1.0 - (Math.tan(x) * Math.tan(eps)))) + -1.0)));
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) / (1.0 - ((math.sin(eps) / math.cos(eps)) * (math.sin(x) / math.cos(x)))) tmp = 0 if eps <= -1.8e-6: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 1e-10: tmp = t_0 + ((eps / (math.pow(math.cos(x), 2.0) / math.pow(math.sin(x), 2.0))) + ((eps * eps) / (math.pow(math.cos(x), 3.0) / math.pow(math.sin(x), 3.0)))) else: tmp = t_0 + ((math.tan(x) * 0.0) + (math.tan(x) * ((1.0 / (1.0 - (math.tan(x) * math.tan(eps)))) + -1.0))) return tmp
function code(x, eps) t_0 = Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x))))) tmp = 0.0 if (eps <= -1.8e-6) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 1e-10) tmp = Float64(t_0 + Float64(Float64(eps / Float64((cos(x) ^ 2.0) / (sin(x) ^ 2.0))) + Float64(Float64(eps * eps) / Float64((cos(x) ^ 3.0) / (sin(x) ^ 3.0))))); else tmp = Float64(t_0 + Float64(Float64(tan(x) * 0.0) + Float64(tan(x) * Float64(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) + -1.0)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))); tmp = 0.0; if (eps <= -1.8e-6) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 1e-10) tmp = t_0 + ((eps / ((cos(x) ^ 2.0) / (sin(x) ^ 2.0))) + ((eps * eps) / ((cos(x) ^ 3.0) / (sin(x) ^ 3.0)))); else tmp = t_0 + ((tan(x) * 0.0) + (tan(x) * ((1.0 / (1.0 - (tan(x) * tan(eps)))) + -1.0))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.8e-6], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-10], N[(t$95$0 + N[(N[(eps / N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * eps), $MachinePrecision] / N[(N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(N[Tan[x], $MachinePrecision] * 0.0), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}}\\
\mathbf{if}\;\varepsilon \leq -1.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;t_0 + \left(\frac{\varepsilon}{\frac{{\cos x}^{2}}{{\sin x}^{2}}} + \frac{\varepsilon \cdot \varepsilon}{\frac{{\cos x}^{3}}{{\sin x}^{3}}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(\tan x \cdot 0 + \tan x \cdot \left(\frac{1}{1 - \tan x \cdot \tan \varepsilon} + -1\right)\right)\\
\end{array}
\end{array}
if eps < -1.79999999999999992e-6Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -1.79999999999999992e-6 < eps < 1.00000000000000004e-10Initial program 29.1%
tan-sum29.8%
div-inv29.8%
fma-neg29.8%
Applied egg-rr29.8%
fma-neg29.8%
associate-*r/29.8%
*-rgt-identity29.8%
Simplified29.8%
Taylor expanded in x around inf 29.8%
associate--l+65.0%
associate-/r*65.0%
*-commutative65.0%
times-frac65.0%
Simplified64.9%
tan-quot64.9%
expm1-log1p-u64.9%
expm1-udef6.0%
Applied egg-rr6.0%
expm1-def64.9%
expm1-log1p64.9%
Simplified64.9%
Taylor expanded in eps around 0 99.6%
associate-/l*99.7%
associate-/l*99.7%
unpow299.7%
Simplified99.7%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
fma-neg99.3%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
Taylor expanded in x around inf 99.0%
associate--l+99.1%
associate-/r*99.1%
*-commutative99.1%
times-frac99.1%
Simplified99.1%
tan-quot99.5%
expm1-log1p-u73.8%
expm1-udef71.9%
Applied egg-rr71.9%
expm1-def73.8%
expm1-log1p99.5%
Simplified99.5%
tan-quot99.4%
div-inv99.5%
tan-quot99.6%
*-un-lft-identity99.6%
prod-diff99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
distribute-lft-out99.6%
metadata-eval99.6%
fma-udef99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin x) (cos x))))
(if (<= eps -2.9e-7)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan x) (/ 1.0 (tan eps)))))
(tan x))
(if (<= eps 1e-10)
(+
(+ eps (* eps (* (pow (sin x) 2.0) (pow (cos x) -2.0))))
(* (* eps eps) (+ t_0 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(+
(/ (tan eps) (- 1.0 (* (/ (sin eps) (cos eps)) t_0)))
(+
(* (tan x) 0.0)
(* (tan x) (+ (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) -1.0))))))))
double code(double x, double eps) {
double t_0 = sin(x) / cos(x);
double tmp;
if (eps <= -2.9e-7) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 1e-10) {
tmp = (eps + (eps * (pow(sin(x), 2.0) * pow(cos(x), -2.0)))) + ((eps * eps) * (t_0 + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * t_0))) + ((tan(x) * 0.0) + (tan(x) * ((1.0 / (1.0 - (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) :: t_0
real(8) :: tmp
t_0 = sin(x) / cos(x)
if (eps <= (-2.9d-7)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 1d-10) then
tmp = (eps + (eps * ((sin(x) ** 2.0d0) * (cos(x) ** (-2.0d0))))) + ((eps * eps) * (t_0 + ((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0))))
else
tmp = (tan(eps) / (1.0d0 - ((sin(eps) / cos(eps)) * t_0))) + ((tan(x) * 0.0d0) + (tan(x) * ((1.0d0 / (1.0d0 - (tan(x) * tan(eps)))) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) / Math.cos(x);
double tmp;
if (eps <= -2.9e-7) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 1e-10) {
tmp = (eps + (eps * (Math.pow(Math.sin(x), 2.0) * Math.pow(Math.cos(x), -2.0)))) + ((eps * eps) * (t_0 + (Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = (Math.tan(eps) / (1.0 - ((Math.sin(eps) / Math.cos(eps)) * t_0))) + ((Math.tan(x) * 0.0) + (Math.tan(x) * ((1.0 / (1.0 - (Math.tan(x) * Math.tan(eps)))) + -1.0)));
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) / math.cos(x) tmp = 0 if eps <= -2.9e-7: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 1e-10: tmp = (eps + (eps * (math.pow(math.sin(x), 2.0) * math.pow(math.cos(x), -2.0)))) + ((eps * eps) * (t_0 + (math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)))) else: tmp = (math.tan(eps) / (1.0 - ((math.sin(eps) / math.cos(eps)) * t_0))) + ((math.tan(x) * 0.0) + (math.tan(x) * ((1.0 / (1.0 - (math.tan(x) * math.tan(eps)))) + -1.0))) return tmp
function code(x, eps) t_0 = Float64(sin(x) / cos(x)) tmp = 0.0 if (eps <= -2.9e-7) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 1e-10) tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) * (cos(x) ^ -2.0)))) + Float64(Float64(eps * eps) * Float64(t_0 + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * t_0))) + Float64(Float64(tan(x) * 0.0) + Float64(tan(x) * Float64(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) + -1.0)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) / cos(x); tmp = 0.0; if (eps <= -2.9e-7) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 1e-10) tmp = (eps + (eps * ((sin(x) ^ 2.0) * (cos(x) ^ -2.0)))) + ((eps * eps) * (t_0 + ((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))); else tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * t_0))) + ((tan(x) * 0.0) + (tan(x) * ((1.0 / (1.0 - (tan(x) * tan(eps)))) + -1.0))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.9e-7], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-10], N[(N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[Cos[x], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * eps), $MachinePrecision] * N[(t$95$0 + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] * 0.0), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
\mathbf{if}\;\varepsilon \leq -2.9 \cdot 10^{-7}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \left({\sin x}^{2} \cdot {\cos x}^{-2}\right)\right) + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(t_0 + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot t_0} + \left(\tan x \cdot 0 + \tan x \cdot \left(\frac{1}{1 - \tan x \cdot \tan \varepsilon} + -1\right)\right)\\
\end{array}
\end{array}
if eps < -2.8999999999999998e-7Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -2.8999999999999998e-7 < eps < 1.00000000000000004e-10Initial program 29.1%
tan-sum29.8%
div-inv29.8%
fma-neg29.8%
Applied egg-rr29.8%
fma-neg29.8%
associate-*r/29.8%
*-rgt-identity29.8%
Simplified29.8%
Taylor expanded in eps around 0 99.6%
Simplified99.7%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
fma-neg99.3%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
Taylor expanded in x around inf 99.0%
associate--l+99.1%
associate-/r*99.1%
*-commutative99.1%
times-frac99.1%
Simplified99.1%
tan-quot99.5%
expm1-log1p-u73.8%
expm1-udef71.9%
Applied egg-rr71.9%
expm1-def73.8%
expm1-log1p99.5%
Simplified99.5%
tan-quot99.4%
div-inv99.5%
tan-quot99.6%
*-un-lft-identity99.6%
prod-diff99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
distribute-lft-out99.6%
metadata-eval99.6%
fma-udef99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(/
(tan eps)
(- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x)))))))
(if (<= eps -7e-9)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan x) (/ 1.0 (tan eps)))))
(tan x))
(if (<= eps 1e-10)
(+ t_0 (/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
(+
t_0
(+
(* (tan x) 0.0)
(* (tan x) (+ (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) -1.0))))))))
double code(double x, double eps) {
double t_0 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))));
double tmp;
if (eps <= -7e-9) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 1e-10) {
tmp = t_0 + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
} else {
tmp = t_0 + ((tan(x) * 0.0) + (tan(x) * ((1.0 / (1.0 - (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) :: t_0
real(8) :: tmp
t_0 = tan(eps) / (1.0d0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))))
if (eps <= (-7d-9)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 1d-10) then
tmp = t_0 + ((eps * (sin(x) ** 2.0d0)) / (cos(x) ** 2.0d0))
else
tmp = t_0 + ((tan(x) * 0.0d0) + (tan(x) * ((1.0d0 / (1.0d0 - (tan(x) * tan(eps)))) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) / (1.0 - ((Math.sin(eps) / Math.cos(eps)) * (Math.sin(x) / Math.cos(x))));
double tmp;
if (eps <= -7e-9) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 1e-10) {
tmp = t_0 + ((eps * Math.pow(Math.sin(x), 2.0)) / Math.pow(Math.cos(x), 2.0));
} else {
tmp = t_0 + ((Math.tan(x) * 0.0) + (Math.tan(x) * ((1.0 / (1.0 - (Math.tan(x) * Math.tan(eps)))) + -1.0)));
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) / (1.0 - ((math.sin(eps) / math.cos(eps)) * (math.sin(x) / math.cos(x)))) tmp = 0 if eps <= -7e-9: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 1e-10: tmp = t_0 + ((eps * math.pow(math.sin(x), 2.0)) / math.pow(math.cos(x), 2.0)) else: tmp = t_0 + ((math.tan(x) * 0.0) + (math.tan(x) * ((1.0 / (1.0 - (math.tan(x) * math.tan(eps)))) + -1.0))) return tmp
function code(x, eps) t_0 = Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x))))) tmp = 0.0 if (eps <= -7e-9) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 1e-10) tmp = Float64(t_0 + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0))); else tmp = Float64(t_0 + Float64(Float64(tan(x) * 0.0) + Float64(tan(x) * Float64(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) + -1.0)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))); tmp = 0.0; if (eps <= -7e-9) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 1e-10) tmp = t_0 + ((eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)); else tmp = t_0 + ((tan(x) * 0.0) + (tan(x) * ((1.0 / (1.0 - (tan(x) * tan(eps)))) + -1.0))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7e-9], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-10], N[(t$95$0 + N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(N[Tan[x], $MachinePrecision] * 0.0), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}}\\
\mathbf{if}\;\varepsilon \leq -7 \cdot 10^{-9}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;t_0 + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(\tan x \cdot 0 + \tan x \cdot \left(\frac{1}{1 - \tan x \cdot \tan \varepsilon} + -1\right)\right)\\
\end{array}
\end{array}
if eps < -6.9999999999999998e-9Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -6.9999999999999998e-9 < eps < 1.00000000000000004e-10Initial program 29.1%
tan-sum29.8%
div-inv29.8%
fma-neg29.8%
Applied egg-rr29.8%
fma-neg29.8%
associate-*r/29.8%
*-rgt-identity29.8%
Simplified29.8%
Taylor expanded in x around inf 29.8%
associate--l+65.0%
associate-/r*65.0%
*-commutative65.0%
times-frac65.0%
Simplified64.9%
tan-quot64.9%
expm1-log1p-u64.9%
expm1-udef6.0%
Applied egg-rr6.0%
expm1-def64.9%
expm1-log1p64.9%
Simplified64.9%
Taylor expanded in eps around 0 99.4%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
fma-neg99.3%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
Taylor expanded in x around inf 99.0%
associate--l+99.1%
associate-/r*99.1%
*-commutative99.1%
times-frac99.1%
Simplified99.1%
tan-quot99.5%
expm1-log1p-u73.8%
expm1-udef71.9%
Applied egg-rr71.9%
expm1-def73.8%
expm1-log1p99.5%
Simplified99.5%
tan-quot99.4%
div-inv99.5%
tan-quot99.6%
*-un-lft-identity99.6%
prod-diff99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
distribute-lft-out99.6%
metadata-eval99.6%
fma-udef99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(/
(tan eps)
(- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x)))))))
(if (<= eps -1.6e-8)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan x) (/ 1.0 (tan eps)))))
(tan x))
(if (<= eps 1e-10)
(+ t_0 (/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
(+ t_0 (- (/ (tan x) (- 1.0 (* (tan x) (tan eps)))) (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))));
double tmp;
if (eps <= -1.6e-8) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 1e-10) {
tmp = t_0 + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
} else {
tmp = t_0 + ((tan(x) / (1.0 - (tan(x) * tan(eps)))) - 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) :: tmp
t_0 = tan(eps) / (1.0d0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))))
if (eps <= (-1.6d-8)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 1d-10) then
tmp = t_0 + ((eps * (sin(x) ** 2.0d0)) / (cos(x) ** 2.0d0))
else
tmp = t_0 + ((tan(x) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) / (1.0 - ((Math.sin(eps) / Math.cos(eps)) * (Math.sin(x) / Math.cos(x))));
double tmp;
if (eps <= -1.6e-8) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 1e-10) {
tmp = t_0 + ((eps * Math.pow(Math.sin(x), 2.0)) / Math.pow(Math.cos(x), 2.0));
} else {
tmp = t_0 + ((Math.tan(x) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x));
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) / (1.0 - ((math.sin(eps) / math.cos(eps)) * (math.sin(x) / math.cos(x)))) tmp = 0 if eps <= -1.6e-8: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 1e-10: tmp = t_0 + ((eps * math.pow(math.sin(x), 2.0)) / math.pow(math.cos(x), 2.0)) else: tmp = t_0 + ((math.tan(x) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x)) return tmp
function code(x, eps) t_0 = Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x))))) tmp = 0.0 if (eps <= -1.6e-8) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 1e-10) tmp = Float64(t_0 + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0))); else tmp = Float64(t_0 + Float64(Float64(tan(x) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))); tmp = 0.0; if (eps <= -1.6e-8) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 1e-10) tmp = t_0 + ((eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)); else tmp = t_0 + ((tan(x) / (1.0 - (tan(x) * tan(eps)))) - tan(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.6e-8], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-10], N[(t$95$0 + N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(N[Tan[x], $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}}\\
\mathbf{if}\;\varepsilon \leq -1.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;t_0 + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x\right)\\
\end{array}
\end{array}
if eps < -1.6000000000000001e-8Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -1.6000000000000001e-8 < eps < 1.00000000000000004e-10Initial program 29.1%
tan-sum29.8%
div-inv29.8%
fma-neg29.8%
Applied egg-rr29.8%
fma-neg29.8%
associate-*r/29.8%
*-rgt-identity29.8%
Simplified29.8%
Taylor expanded in x around inf 29.8%
associate--l+65.0%
associate-/r*65.0%
*-commutative65.0%
times-frac65.0%
Simplified64.9%
tan-quot64.9%
expm1-log1p-u64.9%
expm1-udef6.0%
Applied egg-rr6.0%
expm1-def64.9%
expm1-log1p64.9%
Simplified64.9%
Taylor expanded in eps around 0 99.4%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
fma-neg99.3%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
Taylor expanded in x around inf 99.0%
associate--l+99.1%
associate-/r*99.1%
*-commutative99.1%
times-frac99.1%
Simplified99.1%
tan-quot99.5%
expm1-log1p-u73.8%
expm1-udef71.9%
Applied egg-rr71.9%
expm1-def73.8%
expm1-log1p99.5%
Simplified99.5%
tan-quot99.5%
sub-neg99.5%
tan-quot99.5%
tan-quot99.5%
tan-quot99.5%
*-commutative99.5%
Applied egg-rr99.5%
sub-neg99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -1e-8)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 1e-10)
(+
(/ (tan eps) (- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x)))))
(/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
(fma
t_0
(/ 1.0 (- 1.0 (/ (sin x) (/ (cos x) (tan eps)))))
(- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -1e-8) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 1e-10) {
tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))))) + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
} else {
tmp = fma(t_0, (1.0 / (1.0 - (sin(x) / (cos(x) / tan(eps))))), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -1e-8) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 1e-10) tmp = Float64(Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x))))) + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0))); else tmp = fma(t_0, Float64(1.0 / Float64(1.0 - Float64(sin(x) / Float64(cos(x) / tan(eps))))), Float64(-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, -1e-8], 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], If[LessEqual[eps, 1e-10], N[(N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / 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 -1 \cdot 10^{-8}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{1 - \frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -1e-8Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -1e-8 < eps < 1.00000000000000004e-10Initial program 29.1%
tan-sum29.8%
div-inv29.8%
fma-neg29.8%
Applied egg-rr29.8%
fma-neg29.8%
associate-*r/29.8%
*-rgt-identity29.8%
Simplified29.8%
Taylor expanded in x around inf 29.8%
associate--l+65.0%
associate-/r*65.0%
*-commutative65.0%
times-frac65.0%
Simplified64.9%
tan-quot64.9%
expm1-log1p-u64.9%
expm1-udef6.0%
Applied egg-rr6.0%
expm1-def64.9%
expm1-log1p64.9%
Simplified64.9%
Taylor expanded in eps around 0 99.4%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
*-commutative99.3%
tan-quot99.3%
clear-num99.4%
tan-quot99.4%
frac-times99.4%
*-un-lft-identity99.4%
clear-num99.4%
tan-quot99.4%
Applied egg-rr99.4%
*-commutative99.4%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -3.6e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 1e-10)
(fma eps (pow (tan x) 2.0) eps)
(fma
t_0
(/ 1.0 (- 1.0 (/ (sin x) (/ (cos x) (tan eps)))))
(- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.6e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 1e-10) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = fma(t_0, (1.0 / (1.0 - (sin(x) / (cos(x) / tan(eps))))), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.6e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 1e-10) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = fma(t_0, Float64(1.0 / Float64(1.0 - Float64(sin(x) / Float64(cos(x) / tan(eps))))), Float64(-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.6e-9], 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], If[LessEqual[eps, 1e-10], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / 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.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{1 - \frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -3.6e-9Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -3.6e-9 < eps < 1.00000000000000004e-10Initial program 29.1%
Taylor expanded in eps around 0 99.3%
mul-1-neg99.3%
Simplified99.3%
add-cube-cbrt97.2%
pow397.3%
Applied egg-rr97.4%
rem-cube-cbrt99.3%
distribute-rgt-in99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
*-commutative99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
*-commutative99.3%
tan-quot99.3%
clear-num99.4%
tan-quot99.4%
frac-times99.4%
*-un-lft-identity99.4%
clear-num99.4%
tan-quot99.4%
Applied egg-rr99.4%
*-commutative99.4%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps)))
(t_1 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))))
(if (<= eps -3.2e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 1e-10)
(fma eps (pow (tan x) 2.0) eps)
(fma t_0 (/ 1.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) / (1.0 / tan(eps)));
double tmp;
if (eps <= -3.2e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 1e-10) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = fma(t_0, (1.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) / Float64(1.0 / tan(eps)))) tmp = 0.0 if (eps <= -3.2e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 1e-10) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = fma(t_0, Float64(1.0 / t_1), Float64(-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[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.2e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-10], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(t$95$0 * N[(1.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 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}\\
\mathbf{if}\;\varepsilon \leq -3.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -3.20000000000000012e-9Initial program 61.7%
tan-sum99.2%
div-inv99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
tan-quot99.2%
clear-num99.2%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -3.20000000000000012e-9 < eps < 1.00000000000000004e-10Initial program 29.1%
Taylor expanded in eps around 0 99.3%
mul-1-neg99.3%
Simplified99.3%
add-cube-cbrt97.2%
pow397.3%
Applied egg-rr97.4%
rem-cube-cbrt99.3%
distribute-rgt-in99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
*-commutative99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
tan-quot99.3%
clear-num99.3%
un-div-inv99.4%
clear-num99.3%
tan-quot99.4%
Applied egg-rr99.4%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -4.8e-9) (not (<= eps 1e-10))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -4.8e-9) || !(eps <= 1e-10)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) / (1.0 / 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.8e-9) || !(eps <= 1e-10)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) / Float64(1.0 / 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.8e-9], N[Not[LessEqual[eps, 1e-10]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $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.8 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 10^{-10}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -4.8e-9 or 1.00000000000000004e-10 < eps Initial program 57.3%
tan-sum99.3%
div-inv99.1%
fma-neg99.1%
Applied egg-rr99.1%
fma-neg99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
tan-quot99.2%
clear-num99.2%
un-div-inv99.3%
clear-num99.3%
tan-quot99.3%
Applied egg-rr99.3%
if -4.8e-9 < eps < 1.00000000000000004e-10Initial program 29.1%
Taylor expanded in eps around 0 99.3%
mul-1-neg99.3%
Simplified99.3%
add-cube-cbrt97.2%
pow397.3%
Applied egg-rr97.4%
rem-cube-cbrt99.3%
distribute-rgt-in99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
*-commutative99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -4.6e-9) (not (<= eps 1e-10))) (- (/ (+ (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.6e-9) || !(eps <= 1e-10)) {
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.6e-9) || !(eps <= 1e-10)) 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.6e-9], N[Not[LessEqual[eps, 1e-10]], $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.6 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 10^{-10}\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.5999999999999998e-9 or 1.00000000000000004e-10 < eps Initial program 57.3%
tan-sum99.3%
div-inv99.1%
fma-neg99.1%
Applied egg-rr99.1%
fma-neg99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
if -4.5999999999999998e-9 < eps < 1.00000000000000004e-10Initial program 29.1%
Taylor expanded in eps around 0 99.3%
mul-1-neg99.3%
Simplified99.3%
add-cube-cbrt97.2%
pow397.3%
Applied egg-rr97.4%
rem-cube-cbrt99.3%
distribute-rgt-in99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
*-commutative99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.0024)
(tan eps)
(if (<= eps 1e-10)
(fma eps (pow (tan x) 2.0) eps)
(fma (+ (tan x) (tan eps)) 1.0 (- (tan x))))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0024) {
tmp = tan(eps);
} else if (eps <= 1e-10) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = fma((tan(x) + tan(eps)), 1.0, -tan(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -0.0024) tmp = tan(eps); elseif (eps <= 1e-10) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = fma(Float64(tan(x) + tan(eps)), 1.0, Float64(-tan(x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.0024], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1e-10], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * 1.0 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0024:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\tan x + \tan \varepsilon, 1, -\tan x\right)\\
\end{array}
\end{array}
if eps < -0.00239999999999999979Initial program 63.2%
Taylor expanded in x around 0 66.9%
tan-quot99.3%
expm1-log1p-u73.0%
expm1-udef72.3%
Applied egg-rr47.1%
expm1-def73.0%
expm1-log1p99.3%
Simplified67.3%
if -0.00239999999999999979 < eps < 1.00000000000000004e-10Initial program 28.6%
Taylor expanded in eps around 0 98.2%
mul-1-neg98.2%
Simplified98.2%
add-cube-cbrt96.2%
pow396.2%
Applied egg-rr96.3%
rem-cube-cbrt98.2%
distribute-rgt-in98.2%
*-un-lft-identity98.2%
Applied egg-rr98.2%
*-commutative98.2%
+-commutative98.2%
fma-def98.3%
Simplified98.3%
if 1.00000000000000004e-10 < eps Initial program 51.5%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
tan-quot99.3%
clear-num99.3%
un-div-inv99.4%
clear-num99.3%
tan-quot99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 54.2%
Final simplification78.9%
(FPCore (x eps) :precision binary64 (if (<= eps -0.0024) (tan eps) (if (<= eps 1e-10) (fma eps (pow (tan x) 2.0) eps) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0024) {
tmp = tan(eps);
} else if (eps <= 1e-10) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = tan(eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -0.0024) tmp = tan(eps); elseif (eps <= 1e-10) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = tan(eps); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.0024], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1e-10], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0024:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -0.00239999999999999979 or 1.00000000000000004e-10 < eps Initial program 58.1%
Taylor expanded in x around 0 61.3%
tan-quot99.4%
expm1-log1p-u73.4%
expm1-udef72.1%
Applied egg-rr42.1%
expm1-def73.4%
expm1-log1p99.4%
Simplified61.6%
if -0.00239999999999999979 < eps < 1.00000000000000004e-10Initial program 28.6%
Taylor expanded in eps around 0 98.2%
mul-1-neg98.2%
Simplified98.2%
add-cube-cbrt96.2%
pow396.2%
Applied egg-rr96.3%
rem-cube-cbrt98.2%
distribute-rgt-in98.2%
*-un-lft-identity98.2%
Applied egg-rr98.2%
*-commutative98.2%
+-commutative98.2%
fma-def98.3%
Simplified98.3%
Final simplification78.9%
(FPCore (x eps) :precision binary64 (if (<= eps -0.0033) (tan eps) (if (<= eps 1e-10) (* eps (+ (pow (tan x) 2.0) 1.0)) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0033) {
tmp = tan(eps);
} else if (eps <= 1e-10) {
tmp = eps * (pow(tan(x), 2.0) + 1.0);
} else {
tmp = tan(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.0033d0)) then
tmp = tan(eps)
else if (eps <= 1d-10) then
tmp = eps * ((tan(x) ** 2.0d0) + 1.0d0)
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.0033) {
tmp = Math.tan(eps);
} else if (eps <= 1e-10) {
tmp = eps * (Math.pow(Math.tan(x), 2.0) + 1.0);
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.0033: tmp = math.tan(eps) elif eps <= 1e-10: tmp = eps * (math.pow(math.tan(x), 2.0) + 1.0) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.0033) tmp = tan(eps); elseif (eps <= 1e-10) tmp = Float64(eps * Float64((tan(x) ^ 2.0) + 1.0)); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.0033) tmp = tan(eps); elseif (eps <= 1e-10) tmp = eps * ((tan(x) ^ 2.0) + 1.0); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0033], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1e-10], N[(eps * N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0033:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\varepsilon \cdot \left({\tan x}^{2} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -0.0033 or 1.00000000000000004e-10 < eps Initial program 58.1%
Taylor expanded in x around 0 61.3%
tan-quot99.4%
expm1-log1p-u73.4%
expm1-udef72.1%
Applied egg-rr42.1%
expm1-def73.4%
expm1-log1p99.4%
Simplified61.6%
if -0.0033 < eps < 1.00000000000000004e-10Initial program 28.6%
Taylor expanded in eps around 0 98.2%
mul-1-neg98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-udef6.5%
Applied egg-rr6.5%
expm1-def98.2%
expm1-log1p98.2%
Simplified98.2%
Final simplification78.9%
(FPCore (x eps) :precision binary64 (if (<= eps -0.0024) (tan eps) (if (<= eps 1e-10) (+ eps (* eps (pow (tan x) 2.0))) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0024) {
tmp = tan(eps);
} else if (eps <= 1e-10) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = tan(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.0024d0)) then
tmp = tan(eps)
else if (eps <= 1d-10) then
tmp = eps + (eps * (tan(x) ** 2.0d0))
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.0024) {
tmp = Math.tan(eps);
} else if (eps <= 1e-10) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.0024: tmp = math.tan(eps) elif eps <= 1e-10: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.0024) tmp = tan(eps); elseif (eps <= 1e-10) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.0024) tmp = tan(eps); elseif (eps <= 1e-10) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0024], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1e-10], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0024:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -0.00239999999999999979 or 1.00000000000000004e-10 < eps Initial program 58.1%
Taylor expanded in x around 0 61.3%
tan-quot99.4%
expm1-log1p-u73.4%
expm1-udef72.1%
Applied egg-rr42.1%
expm1-def73.4%
expm1-log1p99.4%
Simplified61.6%
if -0.00239999999999999979 < eps < 1.00000000000000004e-10Initial program 28.6%
Taylor expanded in eps around 0 98.2%
mul-1-neg98.2%
Simplified98.2%
expm1-log1p-u98.2%
expm1-udef6.5%
Applied egg-rr6.5%
expm1-def98.2%
expm1-log1p98.2%
distribute-lft-in98.2%
*-rgt-identity98.2%
Simplified98.2%
Final simplification78.9%
(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 62.5%
tan-quot83.3%
expm1-log1p-u69.6%
expm1-udef41.5%
Applied egg-rr25.0%
expm1-def69.6%
expm1-log1p83.3%
Simplified62.6%
Final simplification62.6%
(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 62.5%
Taylor expanded in eps around 0 32.5%
Final simplification32.5%
(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 2023200
(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)))