
(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 13 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) (tan x)))
(t_1 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))))
(if (<= eps -2.6e-7)
(- (* (/ 1.0 (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))) t_0) (tan x))
(if (<= eps 3.2e-29)
(fma eps t_1 (/ (* eps eps) (/ (/ (cos x) (sin x)) t_1)))
(fma
(* (cos x) t_0)
(/ (/ -1.0 (cos x)) (fma (tan x) (tan eps) -1.0))
(- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double t_1 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
double tmp;
if (eps <= -2.6e-7) {
tmp = ((1.0 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) * t_0) - tan(x);
} else if (eps <= 3.2e-29) {
tmp = fma(eps, t_1, ((eps * eps) / ((cos(x) / sin(x)) / t_1)));
} else {
tmp = fma((cos(x) * t_0), ((-1.0 / cos(x)) / fma(tan(x), tan(eps), -1.0)), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) t_1 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))) tmp = 0.0 if (eps <= -2.6e-7) tmp = Float64(Float64(Float64(1.0 / Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))) * t_0) - tan(x)); elseif (eps <= 3.2e-29) tmp = fma(eps, t_1, Float64(Float64(eps * eps) / Float64(Float64(cos(x) / sin(x)) / t_1))); else tmp = fma(Float64(cos(x) * t_0), Float64(Float64(-1.0 / cos(x)) / fma(tan(x), tan(eps), -1.0)), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $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]}, If[LessEqual[eps, -2.6e-7], N[(N[(N[(1.0 / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.2e-29], N[(eps * t$95$1 + N[(N[(eps * eps), $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(-1.0 / N[Cos[x], $MachinePrecision]), $MachinePrecision] / 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 \varepsilon + \tan x\\
t_1 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{if}\;\varepsilon \leq -2.6 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} \cdot t_0 - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, t_1, \frac{\varepsilon \cdot \varepsilon}{\frac{\frac{\cos x}{\sin x}}{t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x \cdot t_0, \frac{\frac{-1}{\cos x}}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -2.59999999999999999e-7Initial program 56.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
if -2.59999999999999999e-7 < eps < 3.2e-29Initial program 27.7%
Taylor expanded in eps around 0 99.7%
fma-def99.7%
sub-neg99.7%
mul-1-neg99.7%
remove-double-neg99.7%
associate-/l*99.7%
unpow299.7%
associate-/r*99.7%
sub-neg99.7%
mul-1-neg99.7%
Simplified99.7%
if 3.2e-29 < eps Initial program 61.2%
tan-sum99.5%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
div-inv99.5%
tan-quot99.4%
frac-sub99.5%
div-sub99.5%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.4%
*-commutative99.4%
associate-/r*99.5%
fma-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))))
(/
(* (sin x) (+ (/ (* (cos x) (sin eps)) (* (sin x) (cos eps))) t_0))
(* (cos x) (- 1.0 t_0)))))
double code(double x, double eps) {
double t_0 = (sin(x) * sin(eps)) / (cos(x) * cos(eps));
return (sin(x) * (((cos(x) * sin(eps)) / (sin(x) * cos(eps))) + t_0)) / (cos(x) * (1.0 - t_0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = (sin(x) * sin(eps)) / (cos(x) * cos(eps))
code = (sin(x) * (((cos(x) * sin(eps)) / (sin(x) * cos(eps))) + t_0)) / (cos(x) * (1.0d0 - t_0))
end function
public static double code(double x, double eps) {
double t_0 = (Math.sin(x) * Math.sin(eps)) / (Math.cos(x) * Math.cos(eps));
return (Math.sin(x) * (((Math.cos(x) * Math.sin(eps)) / (Math.sin(x) * Math.cos(eps))) + t_0)) / (Math.cos(x) * (1.0 - t_0));
}
def code(x, eps): t_0 = (math.sin(x) * math.sin(eps)) / (math.cos(x) * math.cos(eps)) return (math.sin(x) * (((math.cos(x) * math.sin(eps)) / (math.sin(x) * math.cos(eps))) + t_0)) / (math.cos(x) * (1.0 - t_0))
function code(x, eps) t_0 = Float64(Float64(sin(x) * sin(eps)) / Float64(cos(x) * cos(eps))) return Float64(Float64(sin(x) * Float64(Float64(Float64(cos(x) * sin(eps)) / Float64(sin(x) * cos(eps))) + t_0)) / Float64(cos(x) * Float64(1.0 - t_0))) end
function tmp = code(x, eps) t_0 = (sin(x) * sin(eps)) / (cos(x) * cos(eps)); tmp = (sin(x) * (((cos(x) * sin(eps)) / (sin(x) * cos(eps))) + t_0)) / (cos(x) * (1.0 - t_0)); end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon}\\
\frac{\sin x \cdot \left(\frac{\cos x \cdot \sin \varepsilon}{\sin x \cdot \cos \varepsilon} + t_0\right)}{\cos x \cdot \left(1 - t_0\right)}
\end{array}
\end{array}
Initial program 43.6%
tan-sum64.6%
tan-quot64.4%
clear-num64.4%
frac-sub64.3%
clear-num64.3%
tan-quot64.4%
clear-num64.4%
tan-quot64.4%
Applied egg-rr64.4%
associate-*r/64.5%
*-rgt-identity64.5%
associate-/r/64.4%
Simplified68.4%
Taylor expanded in x around inf 99.3%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -3.8e-9)
(- (* (/ 1.0 (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))) t_0) (tan x))
(if (<= eps 3.2e-29)
(fma eps (pow (tan x) 2.0) eps)
(fma
(* (cos x) t_0)
(/ (/ -1.0 (cos x)) (fma (tan x) (tan eps) -1.0))
(- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double tmp;
if (eps <= -3.8e-9) {
tmp = ((1.0 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) * t_0) - tan(x);
} else if (eps <= 3.2e-29) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = fma((cos(x) * t_0), ((-1.0 / cos(x)) / fma(tan(x), tan(eps), -1.0)), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -3.8e-9) tmp = Float64(Float64(Float64(1.0 / Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))) * t_0) - tan(x)); elseif (eps <= 3.2e-29) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = fma(Float64(cos(x) * t_0), Float64(Float64(-1.0 / cos(x)) / fma(tan(x), tan(eps), -1.0)), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.8e-9], N[(N[(N[(1.0 / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.2e-29], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(-1.0 / N[Cos[x], $MachinePrecision]), $MachinePrecision] / 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 \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -3.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} \cdot t_0 - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x \cdot t_0, \frac{\frac{-1}{\cos x}}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -3.80000000000000011e-9Initial program 56.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
if -3.80000000000000011e-9 < eps < 3.2e-29Initial program 27.7%
tan-sum28.1%
tan-quot27.7%
clear-num27.7%
frac-sub27.7%
clear-num27.6%
tan-quot27.9%
clear-num27.9%
tan-quot27.9%
Applied egg-rr27.9%
associate-*r/27.9%
*-rgt-identity27.9%
associate-/r/27.9%
Simplified36.2%
Taylor expanded in eps around 0 99.3%
associate-*r*76.7%
Simplified76.7%
distribute-rgt-in76.6%
clear-num76.6%
associate-*l/76.7%
*-lft-identity76.7%
tan-quot76.6%
tan-quot76.7%
Applied egg-rr76.7%
associate-*l/99.3%
*-rgt-identity99.3%
associate-*r/99.2%
associate-*r*99.1%
*-commutative99.1%
distribute-rgt-out99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
associate-/l*99.1%
associate-/r/99.2%
tan-quot99.3%
distribute-rgt-in99.4%
div-inv99.2%
associate-*l*99.4%
*-commutative99.4%
rgt-mult-inverse99.6%
*-rgt-identity99.6%
associate-*l*99.5%
pow299.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
if 3.2e-29 < eps Initial program 61.2%
tan-sum99.5%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
div-inv99.5%
tan-quot99.4%
frac-sub99.5%
div-sub99.5%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.4%
*-commutative99.4%
associate-/r*99.5%
fma-def99.7%
Simplified99.7%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -1.6e-9)
(- (* (/ 1.0 (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))) t_0) (tan x))
(if (<= eps 3.2e-29)
(fma eps (pow (tan x) 2.0) eps)
(- (- (tan x)) (/ t_0 (fma (tan x) (tan eps) -1.0)))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double tmp;
if (eps <= -1.6e-9) {
tmp = ((1.0 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) * t_0) - tan(x);
} else if (eps <= 3.2e-29) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = -tan(x) - (t_0 / fma(tan(x), tan(eps), -1.0));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -1.6e-9) tmp = Float64(Float64(Float64(1.0 / Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))) * t_0) - tan(x)); elseif (eps <= 3.2e-29) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(-tan(x)) - Float64(t_0 / fma(tan(x), tan(eps), -1.0))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.6e-9], N[(N[(N[(1.0 / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.2e-29], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[((-N[Tan[x], $MachinePrecision]) - N[(t$95$0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -1.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} \cdot t_0 - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\tan x\right) - \frac{t_0}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\end{array}
\end{array}
if eps < -1.60000000000000006e-9Initial program 56.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-commutative99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
if -1.60000000000000006e-9 < eps < 3.2e-29Initial program 27.7%
tan-sum28.1%
tan-quot27.7%
clear-num27.7%
frac-sub27.7%
clear-num27.6%
tan-quot27.9%
clear-num27.9%
tan-quot27.9%
Applied egg-rr27.9%
associate-*r/27.9%
*-rgt-identity27.9%
associate-/r/27.9%
Simplified36.2%
Taylor expanded in eps around 0 99.3%
associate-*r*76.7%
Simplified76.7%
distribute-rgt-in76.6%
clear-num76.6%
associate-*l/76.7%
*-lft-identity76.7%
tan-quot76.6%
tan-quot76.7%
Applied egg-rr76.7%
associate-*l/99.3%
*-rgt-identity99.3%
associate-*r/99.2%
associate-*r*99.1%
*-commutative99.1%
distribute-rgt-out99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
associate-/l*99.1%
associate-/r/99.2%
tan-quot99.3%
distribute-rgt-in99.4%
div-inv99.2%
associate-*l*99.4%
*-commutative99.4%
rgt-mult-inverse99.6%
*-rgt-identity99.6%
associate-*l*99.5%
pow299.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
if 3.2e-29 < eps Initial program 61.2%
tan-sum99.5%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
associate-*l/99.5%
*-lft-identity99.5%
frac-2neg99.5%
distribute-neg-in99.5%
unsub-neg99.5%
sub-neg99.5%
distribute-neg-in99.5%
+-commutative99.5%
remove-double-neg99.5%
metadata-eval99.5%
Applied egg-rr99.5%
fma-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -2.7e-9)
(- (* t_0 (/ 1.0 (- 1.0 (* (tan eps) (tan x))))) (tan x))
(if (<= eps 3.2e-29)
(fma eps (pow (tan x) 2.0) eps)
(- (- (tan x)) (/ t_0 (fma (tan x) (tan eps) -1.0)))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double tmp;
if (eps <= -2.7e-9) {
tmp = (t_0 * (1.0 / (1.0 - (tan(eps) * tan(x))))) - tan(x);
} else if (eps <= 3.2e-29) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = -tan(x) - (t_0 / fma(tan(x), tan(eps), -1.0));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -2.7e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(eps) * tan(x))))) - tan(x)); elseif (eps <= 3.2e-29) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(-tan(x)) - Float64(t_0 / fma(tan(x), tan(eps), -1.0))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.7e-9], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.2e-29], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[((-N[Tan[x], $MachinePrecision]) - N[(t$95$0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -2.7 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\tan x\right) - \frac{t_0}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\end{array}
\end{array}
if eps < -2.7000000000000002e-9Initial program 56.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
if -2.7000000000000002e-9 < eps < 3.2e-29Initial program 27.7%
tan-sum28.1%
tan-quot27.7%
clear-num27.7%
frac-sub27.7%
clear-num27.6%
tan-quot27.9%
clear-num27.9%
tan-quot27.9%
Applied egg-rr27.9%
associate-*r/27.9%
*-rgt-identity27.9%
associate-/r/27.9%
Simplified36.2%
Taylor expanded in eps around 0 99.3%
associate-*r*76.7%
Simplified76.7%
distribute-rgt-in76.6%
clear-num76.6%
associate-*l/76.7%
*-lft-identity76.7%
tan-quot76.6%
tan-quot76.7%
Applied egg-rr76.7%
associate-*l/99.3%
*-rgt-identity99.3%
associate-*r/99.2%
associate-*r*99.1%
*-commutative99.1%
distribute-rgt-out99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
associate-/l*99.1%
associate-/r/99.2%
tan-quot99.3%
distribute-rgt-in99.4%
div-inv99.2%
associate-*l*99.4%
*-commutative99.4%
rgt-mult-inverse99.6%
*-rgt-identity99.6%
associate-*l*99.5%
pow299.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
if 3.2e-29 < eps Initial program 61.2%
tan-sum99.5%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
associate-*l/99.5%
*-lft-identity99.5%
frac-2neg99.5%
distribute-neg-in99.5%
unsub-neg99.5%
sub-neg99.5%
distribute-neg-in99.5%
+-commutative99.5%
remove-double-neg99.5%
metadata-eval99.5%
Applied egg-rr99.5%
fma-def99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))) (t_1 (- 1.0 (* (tan eps) (tan x)))))
(if (<= eps -5.2e-9)
(- (* t_0 (/ 1.0 t_1)) (tan x))
(if (<= eps 4.7e-26)
(fma eps (pow (tan x) 2.0) eps)
(- (/ 1.0 (/ t_1 t_0)) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double t_1 = 1.0 - (tan(eps) * tan(x));
double tmp;
if (eps <= -5.2e-9) {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
} else if (eps <= 4.7e-26) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (1.0 / (t_1 / t_0)) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) t_1 = Float64(1.0 - Float64(tan(eps) * tan(x))) tmp = 0.0 if (eps <= -5.2e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); elseif (eps <= 4.7e-26) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(1.0 / Float64(t_1 / t_0)) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.2e-9], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.7e-26], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(1.0 / N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon + \tan x\\
t_1 := 1 - \tan \varepsilon \cdot \tan x\\
\mathbf{if}\;\varepsilon \leq -5.2 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 4.7 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{t_1}{t_0}} - \tan x\\
\end{array}
\end{array}
if eps < -5.2000000000000002e-9Initial program 56.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
if -5.2000000000000002e-9 < eps < 4.69999999999999989e-26Initial program 28.9%
tan-sum29.2%
tan-quot28.9%
clear-num28.8%
frac-sub28.8%
clear-num28.8%
tan-quot29.1%
clear-num29.1%
tan-quot29.1%
Applied egg-rr29.1%
associate-*r/29.1%
*-rgt-identity29.1%
associate-/r/29.1%
Simplified37.2%
Taylor expanded in eps around 0 99.3%
associate-*r*77.0%
Simplified77.0%
distribute-rgt-in77.0%
clear-num76.9%
associate-*l/77.0%
*-lft-identity77.0%
tan-quot76.9%
tan-quot77.0%
Applied egg-rr77.0%
associate-*l/99.3%
*-rgt-identity99.3%
associate-*r/99.2%
associate-*r*99.2%
*-commutative99.2%
distribute-rgt-out99.2%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
associate-/l*99.1%
associate-/r/99.2%
tan-quot99.3%
distribute-rgt-in99.4%
div-inv99.2%
associate-*l*99.4%
*-commutative99.4%
rgt-mult-inverse99.6%
*-rgt-identity99.6%
associate-*l*99.5%
pow299.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
if 4.69999999999999989e-26 < eps Initial program 59.9%
tan-sum99.4%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
associate-*l/99.4%
associate-/l*99.4%
Applied egg-rr99.4%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.4e-9) (not (<= eps 3.2e-29))) (- (/ (+ (tan eps) (tan x)) (- 1.0 (* (tan eps) (tan x)))) (tan x)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.4e-9) || !(eps <= 3.2e-29)) {
tmp = ((tan(eps) + tan(x)) / (1.0 - (tan(eps) * tan(x)))) - tan(x);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.4e-9) || !(eps <= 3.2e-29)) tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / Float64(1.0 - Float64(tan(eps) * tan(x)))) - tan(x)); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.4e-9], N[Not[LessEqual[eps, 3.2e-29]], $MachinePrecision]], N[(N[(N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $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 -3.4 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.2 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -3.3999999999999998e-9 or 3.2e-29 < eps Initial program 58.8%
tan-sum99.5%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-udef99.4%
*-commutative99.4%
unsub-neg99.4%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
if -3.3999999999999998e-9 < eps < 3.2e-29Initial program 27.7%
tan-sum28.1%
tan-quot27.7%
clear-num27.7%
frac-sub27.7%
clear-num27.6%
tan-quot27.9%
clear-num27.9%
tan-quot27.9%
Applied egg-rr27.9%
associate-*r/27.9%
*-rgt-identity27.9%
associate-/r/27.9%
Simplified36.2%
Taylor expanded in eps around 0 99.3%
associate-*r*76.7%
Simplified76.7%
distribute-rgt-in76.6%
clear-num76.6%
associate-*l/76.7%
*-lft-identity76.7%
tan-quot76.6%
tan-quot76.7%
Applied egg-rr76.7%
associate-*l/99.3%
*-rgt-identity99.3%
associate-*r/99.2%
associate-*r*99.1%
*-commutative99.1%
distribute-rgt-out99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
associate-/l*99.1%
associate-/r/99.2%
tan-quot99.3%
distribute-rgt-in99.4%
div-inv99.2%
associate-*l*99.4%
*-commutative99.4%
rgt-mult-inverse99.6%
*-rgt-identity99.6%
associate-*l*99.5%
pow299.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))) (t_1 (- 1.0 (* (tan eps) (tan x)))))
(if (<= eps -3.1e-9)
(- (* t_0 (/ 1.0 t_1)) (tan x))
(if (<= eps 3.2e-29)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_0 t_1) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double t_1 = 1.0 - (tan(eps) * tan(x));
double tmp;
if (eps <= -3.1e-9) {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
} else if (eps <= 3.2e-29) {
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(eps) + tan(x)) t_1 = Float64(1.0 - Float64(tan(eps) * tan(x))) tmp = 0.0 if (eps <= -3.1e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); elseif (eps <= 3.2e-29) 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[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.1e-9], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.2e-29], 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 \varepsilon + \tan x\\
t_1 := 1 - \tan \varepsilon \cdot \tan x\\
\mathbf{if}\;\varepsilon \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\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.10000000000000005e-9Initial program 56.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
if -3.10000000000000005e-9 < eps < 3.2e-29Initial program 27.7%
tan-sum28.1%
tan-quot27.7%
clear-num27.7%
frac-sub27.7%
clear-num27.6%
tan-quot27.9%
clear-num27.9%
tan-quot27.9%
Applied egg-rr27.9%
associate-*r/27.9%
*-rgt-identity27.9%
associate-/r/27.9%
Simplified36.2%
Taylor expanded in eps around 0 99.3%
associate-*r*76.7%
Simplified76.7%
distribute-rgt-in76.6%
clear-num76.6%
associate-*l/76.7%
*-lft-identity76.7%
tan-quot76.6%
tan-quot76.7%
Applied egg-rr76.7%
associate-*l/99.3%
*-rgt-identity99.3%
associate-*r/99.2%
associate-*r*99.1%
*-commutative99.1%
distribute-rgt-out99.1%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
associate-/l*99.1%
associate-/r/99.2%
tan-quot99.3%
distribute-rgt-in99.4%
div-inv99.2%
associate-*l*99.4%
*-commutative99.4%
rgt-mult-inverse99.6%
*-rgt-identity99.6%
associate-*l*99.5%
pow299.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-def99.6%
Simplified99.6%
if 3.2e-29 < eps Initial program 61.2%
tan-sum99.5%
div-inv99.3%
fma-neg99.4%
Applied egg-rr99.4%
fma-udef99.3%
*-commutative99.3%
unsub-neg99.3%
associate-*l/99.5%
*-lft-identity99.5%
Simplified99.5%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (<= eps -0.00068) (tan eps) (if (<= eps 3.2e-29) (fma eps (pow (tan x) 2.0) eps) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00068) {
tmp = tan(eps);
} else if (eps <= 3.2e-29) {
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.00068) tmp = tan(eps); elseif (eps <= 3.2e-29) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = tan(eps); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.00068], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 3.2e-29], 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.00068:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -6.8e-4 or 3.2e-29 < eps Initial program 59.2%
Taylor expanded in x around 0 62.0%
frac-2neg62.0%
distribute-frac-neg62.0%
neg-sub062.0%
remove-double-neg62.0%
distribute-frac-neg62.0%
frac-2neg62.0%
tan-quot62.3%
Applied egg-rr62.3%
neg-sub062.3%
remove-double-neg62.3%
Simplified62.3%
if -6.8e-4 < eps < 3.2e-29Initial program 27.5%
tan-sum28.6%
tan-quot28.2%
clear-num28.2%
frac-sub28.2%
clear-num28.1%
tan-quot28.4%
clear-num28.4%
tan-quot28.4%
Applied egg-rr28.4%
associate-*r/28.4%
*-rgt-identity28.4%
associate-/r/28.4%
Simplified36.6%
Taylor expanded in eps around 0 98.7%
associate-*r*76.3%
Simplified76.3%
distribute-rgt-in76.3%
clear-num76.2%
associate-*l/76.3%
*-lft-identity76.3%
tan-quot76.2%
tan-quot76.3%
Applied egg-rr76.3%
associate-*l/98.7%
*-rgt-identity98.7%
associate-*r/98.6%
associate-*r*98.6%
*-commutative98.6%
distribute-rgt-out98.6%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
associate-/l*98.6%
associate-/r/98.7%
tan-quot98.8%
distribute-rgt-in98.9%
div-inv98.7%
associate-*l*98.9%
*-commutative98.9%
rgt-mult-inverse99.0%
*-rgt-identity99.0%
associate-*l*99.0%
pow299.0%
Applied egg-rr99.0%
+-commutative99.0%
fma-def99.1%
Simplified99.1%
Final simplification80.4%
(FPCore (x eps) :precision binary64 (if (<= eps -0.00068) (tan eps) (if (<= eps 3.2e-29) (+ eps (* eps (pow (tan x) 2.0))) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00068) {
tmp = tan(eps);
} else if (eps <= 3.2e-29) {
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.00068d0)) then
tmp = tan(eps)
else if (eps <= 3.2d-29) 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.00068) {
tmp = Math.tan(eps);
} else if (eps <= 3.2e-29) {
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.00068: tmp = math.tan(eps) elif eps <= 3.2e-29: 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.00068) tmp = tan(eps); elseif (eps <= 3.2e-29) 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.00068) tmp = tan(eps); elseif (eps <= 3.2e-29) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.00068], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 3.2e-29], 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.00068:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -6.8e-4 or 3.2e-29 < eps Initial program 59.2%
Taylor expanded in x around 0 62.0%
frac-2neg62.0%
distribute-frac-neg62.0%
neg-sub062.0%
remove-double-neg62.0%
distribute-frac-neg62.0%
frac-2neg62.0%
tan-quot62.3%
Applied egg-rr62.3%
neg-sub062.3%
remove-double-neg62.3%
Simplified62.3%
if -6.8e-4 < eps < 3.2e-29Initial program 27.5%
tan-sum28.6%
tan-quot28.2%
clear-num28.2%
frac-sub28.2%
clear-num28.1%
tan-quot28.4%
clear-num28.4%
tan-quot28.4%
Applied egg-rr28.4%
associate-*r/28.4%
*-rgt-identity28.4%
associate-/r/28.4%
Simplified36.6%
Taylor expanded in eps around 0 98.7%
associate-*r*76.3%
Simplified76.3%
distribute-rgt-in76.3%
clear-num76.2%
associate-*l/76.3%
*-lft-identity76.3%
tan-quot76.2%
tan-quot76.3%
Applied egg-rr76.3%
associate-*l/98.7%
*-rgt-identity98.7%
associate-*r/98.6%
associate-*r*98.6%
*-commutative98.6%
distribute-rgt-out98.6%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
associate-/l*98.6%
associate-/r/98.7%
tan-quot98.8%
+-commutative98.8%
distribute-rgt-in98.9%
associate-*l*98.8%
pow298.8%
div-inv98.6%
associate-*l*98.8%
*-commutative98.8%
rgt-mult-inverse99.0%
*-rgt-identity99.0%
Applied egg-rr99.0%
Final simplification80.3%
(FPCore (x eps) :precision binary64 (if (<= eps -0.00068) (tan eps) (if (<= eps 3.2e-29) (/ (/ eps (cos x)) (cos x)) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00068) {
tmp = tan(eps);
} else if (eps <= 3.2e-29) {
tmp = (eps / cos(x)) / cos(x);
} 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.00068d0)) then
tmp = tan(eps)
else if (eps <= 3.2d-29) then
tmp = (eps / cos(x)) / cos(x)
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.00068) {
tmp = Math.tan(eps);
} else if (eps <= 3.2e-29) {
tmp = (eps / Math.cos(x)) / Math.cos(x);
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.00068: tmp = math.tan(eps) elif eps <= 3.2e-29: tmp = (eps / math.cos(x)) / math.cos(x) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.00068) tmp = tan(eps); elseif (eps <= 3.2e-29) tmp = Float64(Float64(eps / cos(x)) / cos(x)); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.00068) tmp = tan(eps); elseif (eps <= 3.2e-29) tmp = (eps / cos(x)) / cos(x); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.00068], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 3.2e-29], N[(N[(eps / N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00068:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{\varepsilon}{\cos x}}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -6.8e-4 or 3.2e-29 < eps Initial program 59.2%
Taylor expanded in x around 0 62.0%
frac-2neg62.0%
distribute-frac-neg62.0%
neg-sub062.0%
remove-double-neg62.0%
distribute-frac-neg62.0%
frac-2neg62.0%
tan-quot62.3%
Applied egg-rr62.3%
neg-sub062.3%
remove-double-neg62.3%
Simplified62.3%
if -6.8e-4 < eps < 3.2e-29Initial program 27.5%
tan-sum28.6%
tan-quot28.2%
clear-num28.2%
frac-sub28.2%
clear-num28.1%
tan-quot28.4%
clear-num28.4%
tan-quot28.4%
Applied egg-rr28.4%
associate-*r/28.4%
*-rgt-identity28.4%
associate-/r/28.4%
Simplified36.6%
Taylor expanded in eps around 0 98.7%
associate-*r*76.3%
Simplified76.3%
remove-double-neg76.3%
neg-sub076.3%
associate-*l*98.7%
distribute-rgt-neg-in98.7%
frac-add98.6%
cos-sin-sum98.6%
associate-*r/98.8%
*-rgt-identity98.8%
Applied egg-rr98.8%
neg-sub098.8%
distribute-rgt-neg-in98.8%
remove-double-neg98.8%
associate-/r*98.8%
*-inverses98.8%
associate-*r/98.9%
*-rgt-identity98.9%
Simplified98.9%
Final simplification80.3%
(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 43.6%
Taylor expanded in x around 0 59.5%
frac-2neg59.5%
distribute-frac-neg59.5%
neg-sub059.5%
remove-double-neg59.5%
distribute-frac-neg59.5%
frac-2neg59.5%
tan-quot59.7%
Applied egg-rr59.7%
neg-sub059.7%
remove-double-neg59.7%
Simplified59.7%
Final simplification59.7%
(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 43.6%
Taylor expanded in x around 0 59.5%
Taylor expanded in eps around 0 31.4%
Final simplification31.4%
(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 2023297
(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)))