
(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 x) (tan eps))) (t_1 (/ (sin eps) (cos eps))))
(if (<= eps -3.8e-6)
(fma
(* t_0 (fma (tan x) (tan eps) 1.0))
(/ 1.0 (- 1.0 (pow (* (tan x) (tan eps)) 2.0)))
(- (tan x)))
(if (<= eps 2.2e-6)
(+
(/ t_1 (- 1.0 (* t_1 (/ (sin x) (cos x)))))
(*
(tan x)
(+
(/ (* eps (sin x)) (cos x))
(/ (pow eps 2.0) (/ (pow (cos x) 2.0) (pow (sin x) 2.0))))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ (cos eps) (sin eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = sin(eps) / cos(eps);
double tmp;
if (eps <= -3.8e-6) {
tmp = fma((t_0 * fma(tan(x), tan(eps), 1.0)), (1.0 / (1.0 - pow((tan(x) * tan(eps)), 2.0))), -tan(x));
} else if (eps <= 2.2e-6) {
tmp = (t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) + (tan(x) * (((eps * sin(x)) / cos(x)) + (pow(eps, 2.0) / (pow(cos(x), 2.0) / pow(sin(x), 2.0)))));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (cos(eps) / sin(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(sin(eps) / cos(eps)) tmp = 0.0 if (eps <= -3.8e-6) tmp = fma(Float64(t_0 * fma(tan(x), tan(eps), 1.0)), Float64(1.0 / Float64(1.0 - (Float64(tan(x) * tan(eps)) ^ 2.0))), Float64(-tan(x))); elseif (eps <= 2.2e-6) tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(t_1 * Float64(sin(x) / cos(x))))) + Float64(tan(x) * Float64(Float64(Float64(eps * sin(x)) / cos(x)) + Float64((eps ^ 2.0) / Float64((cos(x) ^ 2.0) / (sin(x) ^ 2.0)))))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(cos(eps) / sin(eps))))) - 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[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.8e-6], N[(N[(t$95$0 * N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[Power[N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.2e-6], N[(N[(t$95$1 / N[(1.0 - N[(t$95$1 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] / N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] / N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{if}\;\varepsilon \leq -3.8 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(t_0 \cdot \mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{1}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} + \tan x \cdot \left(\frac{\varepsilon \cdot \sin x}{\cos x} + \frac{{\varepsilon}^{2}}{\frac{{\cos x}^{2}}{{\sin x}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{\cos \varepsilon}{\sin \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -3.8e-6Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
flip--99.4%
associate-/r/99.4%
metadata-eval99.4%
pow299.4%
Applied egg-rr99.4%
associate-*l/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
div-inv99.3%
fma-neg99.5%
Applied egg-rr99.5%
if -3.8e-6 < eps < 2.2000000000000001e-6Initial program 30.3%
tan-sum31.2%
div-inv31.2%
*-un-lft-identity31.2%
prod-diff31.1%
*-commutative31.1%
*-un-lft-identity31.1%
*-commutative31.1%
*-un-lft-identity31.1%
Applied egg-rr31.1%
Simplified31.2%
Taylor expanded in x around inf 31.1%
associate--l+58.2%
associate-/r*58.2%
times-frac58.2%
Simplified58.2%
tan-quot55.5%
tan-quot58.2%
div-inv58.2%
fma-neg58.2%
tan-quot58.2%
tan-quot58.2%
*-commutative58.2%
Applied egg-rr58.2%
fma-udef58.2%
*-rgt-identity58.2%
distribute-rgt-neg-in58.2%
metadata-eval58.2%
distribute-lft-out58.2%
Simplified58.2%
Taylor expanded in eps around 0 99.8%
associate-/l*99.8%
Simplified99.8%
if 2.2000000000000001e-6 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
associate-/l*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -5.8e-7)
(fma
(* t_0 (fma (tan x) (tan eps) 1.0))
(/ 1.0 (- 1.0 (pow (* (tan x) (tan eps)) 2.0)))
(- (tan x)))
(if (<= eps 1.8e-7)
(+
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(*
(pow eps 2.0)
(+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ (cos eps) (sin eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -5.8e-7) {
tmp = fma((t_0 * fma(tan(x), tan(eps), 1.0)), (1.0 / (1.0 - pow((tan(x) * tan(eps)), 2.0))), -tan(x));
} else if (eps <= 1.8e-7) {
tmp = (eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0)) + (pow(eps, 2.0) * ((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (cos(eps) / sin(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -5.8e-7) tmp = fma(Float64(t_0 * fma(tan(x), tan(eps), 1.0)), Float64(1.0 / Float64(1.0 - (Float64(tan(x) * tan(eps)) ^ 2.0))), Float64(-tan(x))); elseif (eps <= 1.8e-7) tmp = Float64(Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)) + Float64((eps ^ 2.0) * Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(cos(eps) / sin(eps))))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.8e-7], N[(N[(t$95$0 * N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[Power[N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 1.8e-7], N[(N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] / N[Sin[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 -5.8 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_0 \cdot \mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{1}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.8 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{\cos \varepsilon}{\sin \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -5.7999999999999995e-7Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
flip--99.4%
associate-/r/99.4%
metadata-eval99.4%
pow299.4%
Applied egg-rr99.4%
associate-*l/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
div-inv99.3%
fma-neg99.5%
Applied egg-rr99.5%
if -5.7999999999999995e-7 < eps < 1.79999999999999997e-7Initial program 30.3%
tan-sum31.2%
div-inv31.2%
*-un-lft-identity31.2%
prod-diff31.1%
*-commutative31.1%
*-un-lft-identity31.1%
*-commutative31.1%
*-un-lft-identity31.1%
Applied egg-rr31.1%
Simplified31.2%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 1.79999999999999997e-7 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
associate-/l*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (/ (sin eps) (cos eps))))
(if (<= eps -6.4e-9)
(fma
(* t_0 (fma (tan x) (tan eps) 1.0))
(/ 1.0 (- 1.0 (pow (* (tan x) (tan eps)) 2.0)))
(- (tan x)))
(if (<= eps 7.2e-9)
(+
(/ t_1 (- 1.0 (* t_1 (/ (sin x) (cos x)))))
(/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
(- (/ t_0 (- 1.0 (/ (tan x) (/ (cos eps) (sin eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = sin(eps) / cos(eps);
double tmp;
if (eps <= -6.4e-9) {
tmp = fma((t_0 * fma(tan(x), tan(eps), 1.0)), (1.0 / (1.0 - pow((tan(x) * tan(eps)), 2.0))), -tan(x));
} else if (eps <= 7.2e-9) {
tmp = (t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (cos(eps) / sin(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(sin(eps) / cos(eps)) tmp = 0.0 if (eps <= -6.4e-9) tmp = fma(Float64(t_0 * fma(tan(x), tan(eps), 1.0)), Float64(1.0 / Float64(1.0 - (Float64(tan(x) * tan(eps)) ^ 2.0))), Float64(-tan(x))); elseif (eps <= 7.2e-9) tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(t_1 * Float64(sin(x) / cos(x))))) + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(cos(eps) / sin(eps))))) - 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[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6.4e-9], N[(N[(t$95$0 * N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[Power[N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 7.2e-9], N[(N[(t$95$1 / N[(1.0 - N[(t$95$1 * 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[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] / N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{if}\;\varepsilon \leq -6.4 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0 \cdot \mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{1}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 7.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{\cos \varepsilon}{\sin \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -6.40000000000000023e-9Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
flip--99.4%
associate-/r/99.4%
metadata-eval99.4%
pow299.4%
Applied egg-rr99.4%
associate-*l/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
div-inv99.3%
fma-neg99.5%
Applied egg-rr99.5%
if -6.40000000000000023e-9 < eps < 7.2e-9Initial program 30.3%
tan-sum31.2%
div-inv31.2%
*-un-lft-identity31.2%
prod-diff31.1%
*-commutative31.1%
*-un-lft-identity31.1%
*-commutative31.1%
*-un-lft-identity31.1%
Applied egg-rr31.1%
Simplified31.2%
Taylor expanded in x around inf 31.1%
associate--l+58.2%
associate-/r*58.2%
times-frac58.2%
Simplified58.2%
Taylor expanded in eps around 0 99.3%
if 7.2e-9 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
associate-/l*99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (/ (sin eps) (cos eps))))
(if (<= eps -2.3e-8)
(fma
(* t_0 (fma (tan x) (tan eps) 1.0))
(/ 1.0 (- 1.0 (pow (* (tan x) (tan eps)) 2.0)))
(- (tan x)))
(if (<= eps 6e-9)
(+
(/ t_1 (- 1.0 (* t_1 (/ (sin x) (cos x)))))
(* (tan x) (/ (* eps (sin x)) (cos x))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ (cos eps) (sin eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = sin(eps) / cos(eps);
double tmp;
if (eps <= -2.3e-8) {
tmp = fma((t_0 * fma(tan(x), tan(eps), 1.0)), (1.0 / (1.0 - pow((tan(x) * tan(eps)), 2.0))), -tan(x));
} else if (eps <= 6e-9) {
tmp = (t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) + (tan(x) * ((eps * sin(x)) / cos(x)));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (cos(eps) / sin(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(sin(eps) / cos(eps)) tmp = 0.0 if (eps <= -2.3e-8) tmp = fma(Float64(t_0 * fma(tan(x), tan(eps), 1.0)), Float64(1.0 / Float64(1.0 - (Float64(tan(x) * tan(eps)) ^ 2.0))), Float64(-tan(x))); elseif (eps <= 6e-9) tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(t_1 * Float64(sin(x) / cos(x))))) + Float64(tan(x) * Float64(Float64(eps * sin(x)) / cos(x)))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(cos(eps) / sin(eps))))) - 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[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.3e-8], N[(N[(t$95$0 * N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[Power[N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 6e-9], N[(N[(t$95$1 / N[(1.0 - N[(t$95$1 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] / N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{if}\;\varepsilon \leq -2.3 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(t_0 \cdot \mathsf{fma}\left(\tan x, \tan \varepsilon, 1\right), \frac{1}{1 - {\left(\tan x \cdot \tan \varepsilon\right)}^{2}}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 6 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} + \tan x \cdot \frac{\varepsilon \cdot \sin x}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{\cos \varepsilon}{\sin \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -2.3000000000000001e-8Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
flip--99.4%
associate-/r/99.4%
metadata-eval99.4%
pow299.4%
Applied egg-rr99.4%
associate-*l/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
div-inv99.3%
fma-neg99.5%
Applied egg-rr99.5%
if -2.3000000000000001e-8 < eps < 5.99999999999999996e-9Initial program 30.3%
tan-sum31.2%
div-inv31.2%
*-un-lft-identity31.2%
prod-diff31.1%
*-commutative31.1%
*-un-lft-identity31.1%
*-commutative31.1%
*-un-lft-identity31.1%
Applied egg-rr31.1%
Simplified31.2%
Taylor expanded in x around inf 31.1%
associate--l+58.2%
associate-/r*58.2%
times-frac58.2%
Simplified58.2%
tan-quot55.5%
tan-quot58.2%
div-inv58.2%
fma-neg58.2%
tan-quot58.2%
tan-quot58.2%
*-commutative58.2%
Applied egg-rr58.2%
fma-udef58.2%
*-rgt-identity58.2%
distribute-rgt-neg-in58.2%
metadata-eval58.2%
distribute-lft-out58.2%
Simplified58.2%
Taylor expanded in eps around 0 99.3%
if 5.99999999999999996e-9 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
associate-/l*99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin eps) (cos eps))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -4.8e-9)
(fma (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_1 (- (tan x)))
(if (<= eps 5.8e-9)
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(* (tan x) (/ (* eps (sin x)) (cos x))))
(- (/ t_1 (- 1.0 (/ (tan x) (/ (cos eps) (sin eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -4.8e-9) {
tmp = fma((1.0 / (1.0 - (tan(x) * tan(eps)))), t_1, -tan(x));
} else if (eps <= 5.8e-9) {
tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + (tan(x) * ((eps * sin(x)) / cos(x)));
} else {
tmp = (t_1 / (1.0 - (tan(x) / (cos(eps) / sin(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4.8e-9) tmp = fma(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_1, Float64(-tan(x))); elseif (eps <= 5.8e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(tan(x) * Float64(Float64(eps * sin(x)) / cos(x)))); else tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(tan(x) / Float64(cos(eps) / sin(eps))))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.8e-9], N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 5.8e-9], N[(N[(t$95$0 / N[(1.0 - N[(t$95$0 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] / N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 5.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \tan x \cdot \frac{\varepsilon \cdot \sin x}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 - \frac{\tan x}{\frac{\cos \varepsilon}{\sin \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -4.8e-9Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
div-inv99.4%
*-commutative99.4%
fma-neg99.5%
Applied egg-rr99.5%
if -4.8e-9 < eps < 5.79999999999999982e-9Initial program 30.3%
tan-sum31.2%
div-inv31.2%
*-un-lft-identity31.2%
prod-diff31.1%
*-commutative31.1%
*-un-lft-identity31.1%
*-commutative31.1%
*-un-lft-identity31.1%
Applied egg-rr31.1%
Simplified31.2%
Taylor expanded in x around inf 31.1%
associate--l+58.2%
associate-/r*58.2%
times-frac58.2%
Simplified58.2%
tan-quot55.5%
tan-quot58.2%
div-inv58.2%
fma-neg58.2%
tan-quot58.2%
tan-quot58.2%
*-commutative58.2%
Applied egg-rr58.2%
fma-udef58.2%
*-rgt-identity58.2%
distribute-rgt-neg-in58.2%
metadata-eval58.2%
distribute-lft-out58.2%
Simplified58.2%
Taylor expanded in eps around 0 99.3%
if 5.79999999999999982e-9 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
associate-/l*99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -2.9e-9)
(fma (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_0 (- (tan x)))
(if (<= eps 5e-9)
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(- (/ t_0 (- 1.0 (/ (tan x) (/ (cos eps) (sin eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.9e-9) {
tmp = fma((1.0 / (1.0 - (tan(x) * tan(eps)))), t_0, -tan(x));
} else if (eps <= 5e-9) {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
} else {
tmp = (t_0 / (1.0 - (tan(x) / (cos(eps) / sin(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -2.9e-9) tmp = fma(Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_0, Float64(-tan(x))); elseif (eps <= 5e-9) tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(cos(eps) / sin(eps))))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.9e-9], N[(N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 5e-9], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] / N[Sin[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 -2.9 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_0, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{\cos \varepsilon}{\sin \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -2.89999999999999991e-9Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
div-inv99.4%
*-commutative99.4%
fma-neg99.5%
Applied egg-rr99.5%
if -2.89999999999999991e-9 < eps < 5.0000000000000001e-9Initial program 30.3%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
if 5.0000000000000001e-9 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
associate-/l*99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps)))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -3.4e-9)
(fma (/ 1.0 t_0) t_1 (- (tan x)))
(if (<= eps 2.6e-9)
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(- (/ t_1 t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.4e-9) {
tmp = fma((1.0 / t_0), t_1, -tan(x));
} else if (eps <= 2.6e-9) {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
} else {
tmp = (t_1 / t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.4e-9) tmp = fma(Float64(1.0 / t_0), t_1, Float64(-tan(x))); elseif (eps <= 2.6e-9) tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); else tmp = Float64(Float64(t_1 / t_0) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.4e-9], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.6e-9], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{t_0}, t_1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -3.3999999999999998e-9Initial program 61.3%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
div-inv99.4%
*-commutative99.4%
fma-neg99.5%
Applied egg-rr99.5%
if -3.3999999999999998e-9 < eps < 2.6000000000000001e-9Initial program 30.3%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
if 2.6000000000000001e-9 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3e-9) (not (<= eps 2e-9))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3e-9) || !(eps <= 2e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3d-9)) .or. (.not. (eps <= 2d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3e-9) || !(eps <= 2e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3e-9) or not (eps <= 2e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3e-9) || !(eps <= 2e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3e-9) || ~((eps <= 2e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3e-9], N[Not[LessEqual[eps, 2e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\end{array}
\end{array}
if eps < -2.99999999999999998e-9 or 2.00000000000000012e-9 < eps Initial program 58.1%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
if -2.99999999999999998e-9 < eps < 2.00000000000000012e-9Initial program 30.3%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -3.8e-9)
(- (* t_0 (/ 1.0 t_1)) (tan x))
(if (<= eps 3.5e-9)
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(- (/ t_0 t_1) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -3.8e-9) {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
} else if (eps <= 3.5e-9) {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
} else {
tmp = (t_0 / t_1) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = 1.0d0 - (tan(x) * tan(eps))
if (eps <= (-3.8d-9)) then
tmp = (t_0 * (1.0d0 / t_1)) - tan(x)
else if (eps <= 3.5d-9) then
tmp = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
else
tmp = (t_0 / t_1) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double t_1 = 1.0 - (Math.tan(x) * Math.tan(eps));
double tmp;
if (eps <= -3.8e-9) {
tmp = (t_0 * (1.0 / t_1)) - Math.tan(x);
} else if (eps <= 3.5e-9) {
tmp = eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
} else {
tmp = (t_0 / t_1) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = 1.0 - (math.tan(x) * math.tan(eps)) tmp = 0 if eps <= -3.8e-9: tmp = (t_0 * (1.0 / t_1)) - math.tan(x) elif eps <= 3.5e-9: tmp = eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0) else: tmp = (t_0 / t_1) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -3.8e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); elseif (eps <= 3.5e-9) tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); else tmp = Float64(Float64(t_0 / t_1) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = 1.0 - (tan(x) * tan(eps)); tmp = 0.0; if (eps <= -3.8e-9) tmp = (t_0 * (1.0 / t_1)) - tan(x); elseif (eps <= 3.5e-9) tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0); else tmp = (t_0 / t_1) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.8e-9], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.5e-9], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.8 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -3.80000000000000011e-9Initial program 61.3%
tan-sum99.4%
div-inv99.4%
Applied egg-rr99.4%
if -3.80000000000000011e-9 < eps < 3.4999999999999999e-9Initial program 30.3%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
if 3.4999999999999999e-9 < eps Initial program 54.3%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.5%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.25e-6)
(/ (sin eps) (cos eps))
(if (<= eps 2.3e-5)
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(- (/ 1.0 (- (/ (cos eps) (sin eps)) x)) (tan x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.25e-6) {
tmp = sin(eps) / cos(eps);
} else if (eps <= 2.3e-5) {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
} else {
tmp = (1.0 / ((cos(eps) / sin(eps)) - x)) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-1.25d-6)) then
tmp = sin(eps) / cos(eps)
else if (eps <= 2.3d-5) then
tmp = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
else
tmp = (1.0d0 / ((cos(eps) / sin(eps)) - x)) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -1.25e-6) {
tmp = Math.sin(eps) / Math.cos(eps);
} else if (eps <= 2.3e-5) {
tmp = eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
} else {
tmp = (1.0 / ((Math.cos(eps) / Math.sin(eps)) - x)) - Math.tan(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.25e-6: tmp = math.sin(eps) / math.cos(eps) elif eps <= 2.3e-5: tmp = eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0) else: tmp = (1.0 / ((math.cos(eps) / math.sin(eps)) - x)) - math.tan(x) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.25e-6) tmp = Float64(sin(eps) / cos(eps)); elseif (eps <= 2.3e-5) tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(cos(eps) / sin(eps)) - x)) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.25e-6) tmp = sin(eps) / cos(eps); elseif (eps <= 2.3e-5) tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0); else tmp = (1.0 / ((cos(eps) / sin(eps)) - x)) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.25e-6], N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.3e-5], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[Cos[eps], $MachinePrecision] / N[Sin[eps], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.25 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{elif}\;\varepsilon \leq 2.3 \cdot 10^{-5}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\cos \varepsilon}{\sin \varepsilon} - x} - \tan x\\
\end{array}
\end{array}
if eps < -1.2500000000000001e-6Initial program 61.3%
Taylor expanded in x around 0 64.3%
if -1.2500000000000001e-6 < eps < 2.3e-5Initial program 30.3%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
if 2.3e-5 < eps Initial program 54.3%
tan-quot54.2%
clear-num54.1%
Applied egg-rr54.1%
Taylor expanded in x around 0 55.7%
Taylor expanded in x around 0 56.4%
+-commutative56.4%
neg-mul-156.4%
unsub-neg56.4%
Simplified56.4%
Final simplification78.1%
(FPCore (x eps) :precision binary64 (/ (sin eps) (cos eps)))
double code(double x, double eps) {
return sin(eps) / cos(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / cos(eps)
end function
public static double code(double x, double eps) {
return Math.sin(eps) / Math.cos(eps);
}
def code(x, eps): return math.sin(eps) / math.cos(eps)
function code(x, eps) return Float64(sin(eps) / cos(eps)) end
function tmp = code(x, eps) tmp = sin(eps) / cos(eps); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos \varepsilon}
\end{array}
Initial program 45.5%
Taylor expanded in x around 0 59.2%
Final simplification59.2%
(FPCore (x eps) :precision binary64 (- (tan (+ eps x)) x))
double code(double x, double eps) {
return tan((eps + x)) - x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((eps + x)) - x
end function
public static double code(double x, double eps) {
return Math.tan((eps + x)) - x;
}
def code(x, eps): return math.tan((eps + x)) - x
function code(x, eps) return Float64(tan(Float64(eps + x)) - x) end
function tmp = code(x, eps) tmp = tan((eps + x)) - x; end
code[x_, eps_] := N[(N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(\varepsilon + x\right) - x
\end{array}
Initial program 45.5%
Taylor expanded in x around 0 42.9%
Final simplification42.9%
(FPCore (x eps) :precision binary64 (- x))
double code(double x, double eps) {
return -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = -x
end function
public static double code(double x, double eps) {
return -x;
}
def code(x, eps): return -x
function code(x, eps) return Float64(-x) end
function tmp = code(x, eps) tmp = -x; end
code[x_, eps_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 45.5%
Taylor expanded in x around 0 42.9%
Taylor expanded in x around inf 3.8%
neg-mul-13.8%
Simplified3.8%
Final simplification3.8%
(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 2024011
(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)))