
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (sin x) 2.0))
(t_1 (- 1.0 (* (tan eps) (tan x))))
(t_2 (/ (tan eps) t_1)))
(if (or (<= eps -3650000000.0) (not (<= eps 7e-14)))
(+ t_2 (fma (/ (tan x) (cos x)) (/ (cos x) t_1) (- (tan x))))
(+
t_2
(/
(+
(* 0.13333333333333333 (/ (* (pow eps 5.0) t_0) (cos x)))
(+
(* 0.3333333333333333 (/ (* t_0 (pow eps 3.0)) (cos x)))
(/ (* eps t_0) (cos x))))
(* t_1 (cos x)))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0);
double t_1 = 1.0 - (tan(eps) * tan(x));
double t_2 = tan(eps) / t_1;
double tmp;
if ((eps <= -3650000000.0) || !(eps <= 7e-14)) {
tmp = t_2 + fma((tan(x) / cos(x)), (cos(x) / t_1), -tan(x));
} else {
tmp = t_2 + (((0.13333333333333333 * ((pow(eps, 5.0) * t_0) / cos(x))) + ((0.3333333333333333 * ((t_0 * pow(eps, 3.0)) / cos(x))) + ((eps * t_0) / cos(x)))) / (t_1 * cos(x)));
}
return tmp;
}
function code(x, eps) t_0 = sin(x) ^ 2.0 t_1 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_2 = Float64(tan(eps) / t_1) tmp = 0.0 if ((eps <= -3650000000.0) || !(eps <= 7e-14)) tmp = Float64(t_2 + fma(Float64(tan(x) / cos(x)), Float64(cos(x) / t_1), Float64(-tan(x)))); else tmp = Float64(t_2 + Float64(Float64(Float64(0.13333333333333333 * Float64(Float64((eps ^ 5.0) * t_0) / cos(x))) + Float64(Float64(0.3333333333333333 * Float64(Float64(t_0 * (eps ^ 3.0)) / cos(x))) + Float64(Float64(eps * t_0) / cos(x)))) / Float64(t_1 * cos(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[eps], $MachinePrecision] / t$95$1), $MachinePrecision]}, If[Or[LessEqual[eps, -3650000000.0], N[Not[LessEqual[eps, 7e-14]], $MachinePrecision]], N[(t$95$2 + N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(t$95$2 + N[(N[(N[(0.13333333333333333 * N[(N[(N[Power[eps, 5.0], $MachinePrecision] * t$95$0), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(N[(t$95$0 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * t$95$0), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := 1 - \tan \varepsilon \cdot \tan x\\
t_2 := \frac{\tan \varepsilon}{t_1}\\
\mathbf{if}\;\varepsilon \leq -3650000000 \lor \neg \left(\varepsilon \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;t_2 + \mathsf{fma}\left(\frac{\tan x}{\cos x}, \frac{\cos x}{t_1}, -\tan x\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 + \frac{0.13333333333333333 \cdot \frac{{\varepsilon}^{5} \cdot t_0}{\cos x} + \left(0.3333333333333333 \cdot \frac{t_0 \cdot {\varepsilon}^{3}}{\cos x} + \frac{\varepsilon \cdot t_0}{\cos x}\right)}{t_1 \cdot \cos x}\\
\end{array}
\end{array}
if eps < -3.65e9 or 7.0000000000000005e-14 < eps Initial program 48.7%
tan-sum99.4%
flip--99.4%
associate-/r/99.4%
metadata-eval99.4%
Applied egg-rr99.4%
associate-*l/99.4%
+-commutative99.4%
fma-def99.4%
swap-sqr99.4%
unpow299.4%
Simplified99.4%
sub-neg99.4%
associate-/l*99.4%
*-un-lft-identity99.4%
unpow299.4%
swap-sqr99.4%
metadata-eval99.4%
fma-udef99.4%
+-commutative99.4%
flip--99.4%
associate-*l/99.4%
Applied egg-rr99.4%
sub-neg99.4%
associate-+r-99.4%
+-commutative99.4%
associate--l+99.5%
Simplified99.5%
tan-quot99.4%
frac-sub99.3%
Applied egg-rr99.3%
div-sub99.3%
sub-neg99.3%
*-commutative99.3%
times-frac99.4%
*-commutative99.4%
*-commutative99.4%
times-frac99.4%
tan-quot99.5%
Applied egg-rr99.5%
fma-def99.5%
distribute-lft-neg-in99.5%
*-inverses99.5%
*-rgt-identity99.5%
Simplified99.5%
if -3.65e9 < eps < 7.0000000000000005e-14Initial program 25.2%
tan-sum27.2%
flip--27.2%
associate-/r/27.2%
metadata-eval27.2%
Applied egg-rr27.2%
associate-*l/27.2%
+-commutative27.2%
fma-def27.2%
swap-sqr27.2%
unpow227.2%
Simplified27.2%
sub-neg27.2%
associate-/l*27.2%
*-un-lft-identity27.2%
unpow227.2%
swap-sqr27.2%
metadata-eval27.2%
fma-udef27.2%
+-commutative27.2%
flip--27.2%
associate-*l/27.2%
Applied egg-rr27.2%
sub-neg27.2%
associate-+r-27.2%
+-commutative27.2%
associate--l+64.7%
Simplified64.7%
tan-quot63.3%
frac-sub63.1%
Applied egg-rr63.1%
Taylor expanded in eps around 0 99.7%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (/ (tan eps) t_0)))
(if (<= eps -2.1e-6)
(- (/ 1.0 (/ t_0 (+ (tan eps) (tan x)))) (tan x))
(if (<= eps 7e-14)
(+
t_1
(+
(/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0))
(/ (pow eps 2.0) (/ (pow (cos x) 3.0) (pow (sin x) 3.0)))))
(+ t_1 (fma (/ (tan x) (cos x)) (/ (cos x) t_0) (- (tan x))))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = tan(eps) / t_0;
double tmp;
if (eps <= -2.1e-6) {
tmp = (1.0 / (t_0 / (tan(eps) + tan(x)))) - tan(x);
} else if (eps <= 7e-14) {
tmp = t_1 + (((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0)) + (pow(eps, 2.0) / (pow(cos(x), 3.0) / pow(sin(x), 3.0))));
} else {
tmp = t_1 + fma((tan(x) / cos(x)), (cos(x) / t_0), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(tan(eps) / t_0) tmp = 0.0 if (eps <= -2.1e-6) tmp = Float64(Float64(1.0 / Float64(t_0 / Float64(tan(eps) + tan(x)))) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(t_1 + Float64(Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)) + Float64((eps ^ 2.0) / Float64((cos(x) ^ 3.0) / (sin(x) ^ 3.0))))); else tmp = Float64(t_1 + fma(Float64(tan(x) / cos(x)), Float64(cos(x) / t_0), Float64(-tan(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[eps, -2.1e-6], N[(N[(1.0 / N[(t$95$0 / N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(t$95$1 + N[(N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $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$1 + N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] / t$95$0), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \frac{\tan \varepsilon}{t_0}\\
\mathbf{if}\;\varepsilon \leq -2.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{t_0}{\tan \varepsilon + \tan x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;t_1 + \left(\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}} + \frac{{\varepsilon}^{2}}{\frac{{\cos x}^{3}}{{\sin x}^{3}}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \mathsf{fma}\left(\frac{\tan x}{\cos x}, \frac{\cos x}{t_0}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -2.0999999999999998e-6Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -2.0999999999999998e-6 < eps < 7.0000000000000005e-14Initial program 23.1%
tan-sum23.7%
flip--23.7%
associate-/r/23.7%
metadata-eval23.7%
Applied egg-rr23.7%
associate-*l/23.7%
+-commutative23.7%
fma-def23.7%
swap-sqr23.7%
unpow223.7%
Simplified23.7%
sub-neg23.7%
associate-/l*23.7%
*-un-lft-identity23.7%
unpow223.7%
swap-sqr23.7%
metadata-eval23.7%
fma-udef23.7%
+-commutative23.7%
flip--23.7%
associate-*l/23.7%
Applied egg-rr23.7%
sub-neg23.7%
associate-+r-23.7%
+-commutative23.7%
associate--l+63.1%
Simplified63.1%
Taylor expanded in eps around 0 99.8%
associate-/l*99.8%
Simplified99.8%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
flip--99.3%
associate-/r/99.3%
metadata-eval99.3%
Applied egg-rr99.3%
associate-*l/99.3%
+-commutative99.3%
fma-def99.3%
swap-sqr99.3%
unpow299.3%
Simplified99.3%
sub-neg99.3%
associate-/l*99.3%
*-un-lft-identity99.3%
unpow299.3%
swap-sqr99.3%
metadata-eval99.3%
fma-udef99.3%
+-commutative99.3%
flip--99.3%
associate-*l/99.3%
Applied egg-rr99.3%
sub-neg99.3%
associate-+r-99.3%
+-commutative99.3%
associate--l+99.4%
Simplified99.4%
tan-quot99.3%
frac-sub99.1%
Applied egg-rr99.1%
div-sub99.2%
sub-neg99.2%
*-commutative99.2%
times-frac99.2%
*-commutative99.2%
*-commutative99.2%
times-frac99.3%
tan-quot99.4%
Applied egg-rr99.4%
fma-def99.4%
distribute-lft-neg-in99.4%
*-inverses99.4%
*-rgt-identity99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (/ (tan eps) t_0)))
(if (<= eps -7.1e-6)
(- (/ 1.0 (/ t_0 (+ (tan eps) (tan x)))) (tan x))
(if (<= eps 7e-14)
(+ t_1 (/ (/ (* eps (pow (sin x) 2.0)) (cos x)) (* t_0 (cos x))))
(+ t_1 (fma (/ (tan x) (cos x)) (/ (cos x) t_0) (- (tan x))))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = tan(eps) / t_0;
double tmp;
if (eps <= -7.1e-6) {
tmp = (1.0 / (t_0 / (tan(eps) + tan(x)))) - tan(x);
} else if (eps <= 7e-14) {
tmp = t_1 + (((eps * pow(sin(x), 2.0)) / cos(x)) / (t_0 * cos(x)));
} else {
tmp = t_1 + fma((tan(x) / cos(x)), (cos(x) / t_0), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(tan(eps) / t_0) tmp = 0.0 if (eps <= -7.1e-6) tmp = Float64(Float64(1.0 / Float64(t_0 / Float64(tan(eps) + tan(x)))) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(t_1 + Float64(Float64(Float64(eps * (sin(x) ^ 2.0)) / cos(x)) / Float64(t_0 * cos(x)))); else tmp = Float64(t_1 + fma(Float64(tan(x) / cos(x)), Float64(cos(x) / t_0), Float64(-tan(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[eps, -7.1e-6], N[(N[(1.0 / N[(t$95$0 / N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(t$95$1 + N[(N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] / t$95$0), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \frac{\tan \varepsilon}{t_0}\\
\mathbf{if}\;\varepsilon \leq -7.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{t_0}{\tan \varepsilon + \tan x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;t_1 + \frac{\frac{\varepsilon \cdot {\sin x}^{2}}{\cos x}}{t_0 \cdot \cos x}\\
\mathbf{else}:\\
\;\;\;\;t_1 + \mathsf{fma}\left(\frac{\tan x}{\cos x}, \frac{\cos x}{t_0}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -7.0999999999999998e-6Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -7.0999999999999998e-6 < eps < 7.0000000000000005e-14Initial program 23.1%
tan-sum23.7%
flip--23.7%
associate-/r/23.7%
metadata-eval23.7%
Applied egg-rr23.7%
associate-*l/23.7%
+-commutative23.7%
fma-def23.7%
swap-sqr23.7%
unpow223.7%
Simplified23.7%
sub-neg23.7%
associate-/l*23.7%
*-un-lft-identity23.7%
unpow223.7%
swap-sqr23.7%
metadata-eval23.7%
fma-udef23.7%
+-commutative23.7%
flip--23.7%
associate-*l/23.7%
Applied egg-rr23.7%
sub-neg23.7%
associate-+r-23.7%
+-commutative23.7%
associate--l+63.1%
Simplified63.1%
tan-quot61.7%
frac-sub61.4%
Applied egg-rr61.4%
Taylor expanded in eps around 0 99.7%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
flip--99.3%
associate-/r/99.3%
metadata-eval99.3%
Applied egg-rr99.3%
associate-*l/99.3%
+-commutative99.3%
fma-def99.3%
swap-sqr99.3%
unpow299.3%
Simplified99.3%
sub-neg99.3%
associate-/l*99.3%
*-un-lft-identity99.3%
unpow299.3%
swap-sqr99.3%
metadata-eval99.3%
fma-udef99.3%
+-commutative99.3%
flip--99.3%
associate-*l/99.3%
Applied egg-rr99.3%
sub-neg99.3%
associate-+r-99.3%
+-commutative99.3%
associate--l+99.4%
Simplified99.4%
tan-quot99.3%
frac-sub99.1%
Applied egg-rr99.1%
div-sub99.2%
sub-neg99.2%
*-commutative99.2%
times-frac99.2%
*-commutative99.2%
*-commutative99.2%
times-frac99.3%
tan-quot99.4%
Applied egg-rr99.4%
fma-def99.4%
distribute-lft-neg-in99.4%
*-inverses99.4%
*-rgt-identity99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (+ (tan eps) (tan x))))
(if (<= eps -5.5e-6)
(- (/ 1.0 (/ t_0 t_1)) (tan x))
(if (<= eps 7e-14)
(+
(/ (tan eps) t_0)
(/ (* (pow (sin x) 2.0) (/ eps (cos x))) (* t_0 (cos x))))
(-
(* t_1 (/ 1.0 (- 1.0 (* (/ (tan x) (cos eps)) (sin eps)))))
(tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = tan(eps) + tan(x);
double tmp;
if (eps <= -5.5e-6) {
tmp = (1.0 / (t_0 / t_1)) - tan(x);
} else if (eps <= 7e-14) {
tmp = (tan(eps) / t_0) + ((pow(sin(x), 2.0) * (eps / cos(x))) / (t_0 * cos(x)));
} else {
tmp = (t_1 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (tan(eps) * tan(x))
t_1 = tan(eps) + tan(x)
if (eps <= (-5.5d-6)) then
tmp = (1.0d0 / (t_0 / t_1)) - tan(x)
else if (eps <= 7d-14) then
tmp = (tan(eps) / t_0) + (((sin(x) ** 2.0d0) * (eps / cos(x))) / (t_0 * cos(x)))
else
tmp = (t_1 * (1.0d0 / (1.0d0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(eps) * Math.tan(x));
double t_1 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -5.5e-6) {
tmp = (1.0 / (t_0 / t_1)) - Math.tan(x);
} else if (eps <= 7e-14) {
tmp = (Math.tan(eps) / t_0) + ((Math.pow(Math.sin(x), 2.0) * (eps / Math.cos(x))) / (t_0 * Math.cos(x)));
} else {
tmp = (t_1 * (1.0 / (1.0 - ((Math.tan(x) / Math.cos(eps)) * Math.sin(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(eps) * math.tan(x)) t_1 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -5.5e-6: tmp = (1.0 / (t_0 / t_1)) - math.tan(x) elif eps <= 7e-14: tmp = (math.tan(eps) / t_0) + ((math.pow(math.sin(x), 2.0) * (eps / math.cos(x))) / (t_0 * math.cos(x))) else: tmp = (t_1 * (1.0 / (1.0 - ((math.tan(x) / math.cos(eps)) * math.sin(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -5.5e-6) tmp = Float64(Float64(1.0 / Float64(t_0 / t_1)) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(Float64(tan(eps) / t_0) + Float64(Float64((sin(x) ^ 2.0) * Float64(eps / cos(x))) / Float64(t_0 * cos(x)))); else tmp = Float64(Float64(t_1 * Float64(1.0 / Float64(1.0 - Float64(Float64(tan(x) / cos(eps)) * sin(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(eps) * tan(x)); t_1 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -5.5e-6) tmp = (1.0 / (t_0 / t_1)) - tan(x); elseif (eps <= 7e-14) tmp = (tan(eps) / t_0) + (((sin(x) ^ 2.0) * (eps / cos(x))) / (t_0 * cos(x))); else tmp = (t_1 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.5e-6], N[(N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(eps / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -5.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{t_0}{t_1}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_0} + \frac{{\sin x}^{2} \cdot \frac{\varepsilon}{\cos x}}{t_0 \cdot \cos x}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{1}{1 - \frac{\tan x}{\cos \varepsilon} \cdot \sin \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -5.4999999999999999e-6Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -5.4999999999999999e-6 < eps < 7.0000000000000005e-14Initial program 23.1%
tan-sum23.7%
flip--23.7%
associate-/r/23.7%
metadata-eval23.7%
Applied egg-rr23.7%
associate-*l/23.7%
+-commutative23.7%
fma-def23.7%
swap-sqr23.7%
unpow223.7%
Simplified23.7%
sub-neg23.7%
associate-/l*23.7%
*-un-lft-identity23.7%
unpow223.7%
swap-sqr23.7%
metadata-eval23.7%
fma-udef23.7%
+-commutative23.7%
flip--23.7%
associate-*l/23.7%
Applied egg-rr23.7%
sub-neg23.7%
associate-+r-23.7%
+-commutative23.7%
associate--l+63.1%
Simplified63.1%
tan-quot61.7%
frac-sub61.4%
Applied egg-rr61.4%
Taylor expanded in eps around 0 99.7%
associate-/l*99.7%
associate-/r/99.7%
Simplified99.7%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
tan-quot99.3%
associate-*r/99.2%
Applied egg-rr99.2%
associate-/l*99.3%
associate-/r/99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (+ (tan eps) (tan x))))
(if (<= eps -4.8e-6)
(- (/ 1.0 (/ t_0 t_1)) (tan x))
(if (<= eps 7e-14)
(+
(/ (tan eps) t_0)
(/ (/ (* eps (pow (sin x) 2.0)) (cos x)) (* t_0 (cos x))))
(-
(* t_1 (/ 1.0 (- 1.0 (* (/ (tan x) (cos eps)) (sin eps)))))
(tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = tan(eps) + tan(x);
double tmp;
if (eps <= -4.8e-6) {
tmp = (1.0 / (t_0 / t_1)) - tan(x);
} else if (eps <= 7e-14) {
tmp = (tan(eps) / t_0) + (((eps * pow(sin(x), 2.0)) / cos(x)) / (t_0 * cos(x)));
} else {
tmp = (t_1 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (tan(eps) * tan(x))
t_1 = tan(eps) + tan(x)
if (eps <= (-4.8d-6)) then
tmp = (1.0d0 / (t_0 / t_1)) - tan(x)
else if (eps <= 7d-14) then
tmp = (tan(eps) / t_0) + (((eps * (sin(x) ** 2.0d0)) / cos(x)) / (t_0 * cos(x)))
else
tmp = (t_1 * (1.0d0 / (1.0d0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(eps) * Math.tan(x));
double t_1 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -4.8e-6) {
tmp = (1.0 / (t_0 / t_1)) - Math.tan(x);
} else if (eps <= 7e-14) {
tmp = (Math.tan(eps) / t_0) + (((eps * Math.pow(Math.sin(x), 2.0)) / Math.cos(x)) / (t_0 * Math.cos(x)));
} else {
tmp = (t_1 * (1.0 / (1.0 - ((Math.tan(x) / Math.cos(eps)) * Math.sin(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(eps) * math.tan(x)) t_1 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -4.8e-6: tmp = (1.0 / (t_0 / t_1)) - math.tan(x) elif eps <= 7e-14: tmp = (math.tan(eps) / t_0) + (((eps * math.pow(math.sin(x), 2.0)) / math.cos(x)) / (t_0 * math.cos(x))) else: tmp = (t_1 * (1.0 / (1.0 - ((math.tan(x) / math.cos(eps)) * math.sin(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -4.8e-6) tmp = Float64(Float64(1.0 / Float64(t_0 / t_1)) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(Float64(tan(eps) / t_0) + Float64(Float64(Float64(eps * (sin(x) ^ 2.0)) / cos(x)) / Float64(t_0 * cos(x)))); else tmp = Float64(Float64(t_1 * Float64(1.0 / Float64(1.0 - Float64(Float64(tan(x) / cos(eps)) * sin(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(eps) * tan(x)); t_1 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -4.8e-6) tmp = (1.0 / (t_0 / t_1)) - tan(x); elseif (eps <= 7e-14) tmp = (tan(eps) / t_0) + (((eps * (sin(x) ^ 2.0)) / cos(x)) / (t_0 * cos(x))); else tmp = (t_1 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.8e-6], N[(N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\frac{t_0}{t_1}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_0} + \frac{\frac{\varepsilon \cdot {\sin x}^{2}}{\cos x}}{t_0 \cdot \cos x}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{1}{1 - \frac{\tan x}{\cos \varepsilon} \cdot \sin \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -4.7999999999999998e-6Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -4.7999999999999998e-6 < eps < 7.0000000000000005e-14Initial program 23.1%
tan-sum23.7%
flip--23.7%
associate-/r/23.7%
metadata-eval23.7%
Applied egg-rr23.7%
associate-*l/23.7%
+-commutative23.7%
fma-def23.7%
swap-sqr23.7%
unpow223.7%
Simplified23.7%
sub-neg23.7%
associate-/l*23.7%
*-un-lft-identity23.7%
unpow223.7%
swap-sqr23.7%
metadata-eval23.7%
fma-udef23.7%
+-commutative23.7%
flip--23.7%
associate-*l/23.7%
Applied egg-rr23.7%
sub-neg23.7%
associate-+r-23.7%
+-commutative23.7%
associate--l+63.1%
Simplified63.1%
tan-quot61.7%
frac-sub61.4%
Applied egg-rr61.4%
Taylor expanded in eps around 0 99.7%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
tan-quot99.3%
associate-*r/99.2%
Applied egg-rr99.2%
associate-/l*99.3%
associate-/r/99.4%
Simplified99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (+ (tan eps) (tan x))))
(if (<= eps -7.1e-9)
(- (/ 1.0 (/ t_0 t_1)) (tan x))
(if (<= eps 7e-14)
(+ (/ (tan eps) t_0) (* (pow (sin x) 2.0) (/ eps (pow (cos x) 2.0))))
(-
(* t_1 (/ 1.0 (- 1.0 (* (/ (tan x) (cos eps)) (sin eps)))))
(tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = tan(eps) + tan(x);
double tmp;
if (eps <= -7.1e-9) {
tmp = (1.0 / (t_0 / t_1)) - tan(x);
} else if (eps <= 7e-14) {
tmp = (tan(eps) / t_0) + (pow(sin(x), 2.0) * (eps / pow(cos(x), 2.0)));
} else {
tmp = (t_1 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (tan(eps) * tan(x))
t_1 = tan(eps) + tan(x)
if (eps <= (-7.1d-9)) then
tmp = (1.0d0 / (t_0 / t_1)) - tan(x)
else if (eps <= 7d-14) then
tmp = (tan(eps) / t_0) + ((sin(x) ** 2.0d0) * (eps / (cos(x) ** 2.0d0)))
else
tmp = (t_1 * (1.0d0 / (1.0d0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(eps) * Math.tan(x));
double t_1 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -7.1e-9) {
tmp = (1.0 / (t_0 / t_1)) - Math.tan(x);
} else if (eps <= 7e-14) {
tmp = (Math.tan(eps) / t_0) + (Math.pow(Math.sin(x), 2.0) * (eps / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_1 * (1.0 / (1.0 - ((Math.tan(x) / Math.cos(eps)) * Math.sin(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(eps) * math.tan(x)) t_1 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -7.1e-9: tmp = (1.0 / (t_0 / t_1)) - math.tan(x) elif eps <= 7e-14: tmp = (math.tan(eps) / t_0) + (math.pow(math.sin(x), 2.0) * (eps / math.pow(math.cos(x), 2.0))) else: tmp = (t_1 * (1.0 / (1.0 - ((math.tan(x) / math.cos(eps)) * math.sin(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -7.1e-9) tmp = Float64(Float64(1.0 / Float64(t_0 / t_1)) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(Float64(tan(eps) / t_0) + Float64((sin(x) ^ 2.0) * Float64(eps / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_1 * Float64(1.0 / Float64(1.0 - Float64(Float64(tan(x) / cos(eps)) * sin(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(eps) * tan(x)); t_1 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -7.1e-9) tmp = (1.0 / (t_0 / t_1)) - tan(x); elseif (eps <= 7e-14) tmp = (tan(eps) / t_0) + ((sin(x) ^ 2.0) * (eps / (cos(x) ^ 2.0))); else tmp = (t_1 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7.1e-9], N[(N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(eps / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -7.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\frac{t_0}{t_1}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_0} + {\sin x}^{2} \cdot \frac{\varepsilon}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{1}{1 - \frac{\tan x}{\cos \varepsilon} \cdot \sin \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -7.09999999999999988e-9Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -7.09999999999999988e-9 < eps < 7.0000000000000005e-14Initial program 23.1%
tan-sum23.7%
flip--23.7%
associate-/r/23.7%
metadata-eval23.7%
Applied egg-rr23.7%
associate-*l/23.7%
+-commutative23.7%
fma-def23.7%
swap-sqr23.7%
unpow223.7%
Simplified23.7%
sub-neg23.7%
associate-/l*23.7%
*-un-lft-identity23.7%
unpow223.7%
swap-sqr23.7%
metadata-eval23.7%
fma-udef23.7%
+-commutative23.7%
flip--23.7%
associate-*l/23.7%
Applied egg-rr23.7%
sub-neg23.7%
associate-+r-23.7%
+-commutative23.7%
associate--l+63.1%
Simplified63.1%
Taylor expanded in eps around 0 99.5%
associate-/l*99.4%
associate-/r/99.5%
Simplified99.5%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
tan-quot99.3%
associate-*r/99.2%
Applied egg-rr99.2%
associate-/l*99.3%
associate-/r/99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -6.1e-9)
(- (/ 1.0 (/ (- 1.0 (* (tan eps) (tan x))) t_0)) (tan x))
(if (<= eps 7e-14)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(-
(* t_0 (/ 1.0 (- 1.0 (* (/ (tan x) (cos eps)) (sin eps)))))
(tan x))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double tmp;
if (eps <= -6.1e-9) {
tmp = (1.0 / ((1.0 - (tan(eps) * tan(x))) / t_0)) - tan(x);
} else if (eps <= 7e-14) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(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) + tan(x)
if (eps <= (-6.1d-9)) then
tmp = (1.0d0 / ((1.0d0 - (tan(eps) * tan(x))) / t_0)) - tan(x)
else if (eps <= 7d-14) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 * (1.0d0 / (1.0d0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -6.1e-9) {
tmp = (1.0 / ((1.0 - (Math.tan(eps) * Math.tan(x))) / t_0)) - Math.tan(x);
} else if (eps <= 7e-14) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 * (1.0 / (1.0 - ((Math.tan(x) / Math.cos(eps)) * Math.sin(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -6.1e-9: tmp = (1.0 / ((1.0 - (math.tan(eps) * math.tan(x))) / t_0)) - math.tan(x) elif eps <= 7e-14: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 * (1.0 / (1.0 - ((math.tan(x) / math.cos(eps)) * math.sin(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -6.1e-9) tmp = Float64(Float64(1.0 / Float64(Float64(1.0 - Float64(tan(eps) * tan(x))) / t_0)) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(Float64(tan(x) / cos(eps)) * sin(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -6.1e-9) tmp = (1.0 / ((1.0 - (tan(eps) * tan(x))) / t_0)) - tan(x); elseif (eps <= 7e-14) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 * (1.0 / (1.0 - ((tan(x) / cos(eps)) * sin(eps))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6.1e-9], N[(N[(1.0 / N[(N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\frac{1 - \tan \varepsilon \cdot \tan x}{t_0}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \frac{\tan x}{\cos \varepsilon} \cdot \sin \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -6.1e-9Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -6.1e-9 < eps < 7.0000000000000005e-14Initial program 23.1%
Taylor expanded in eps around 0 99.4%
sub-neg99.4%
mul-1-neg99.4%
remove-double-neg99.4%
Simplified99.4%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
div-inv99.3%
*-commutative99.3%
Applied egg-rr99.3%
tan-quot99.3%
associate-*r/99.2%
Applied egg-rr99.2%
associate-/l*99.3%
associate-/r/99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -6.2e-9) (not (<= eps 7e-14))) (- (/ (+ (tan eps) (tan x)) (- 1.0 (* (tan eps) (tan x)))) (tan x)) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -6.2e-9) || !(eps <= 7e-14)) {
tmp = ((tan(eps) + tan(x)) / (1.0 - (tan(eps) * tan(x)))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-6.2d-9)) .or. (.not. (eps <= 7d-14))) then
tmp = ((tan(eps) + tan(x)) / (1.0d0 - (tan(eps) * tan(x)))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -6.2e-9) || !(eps <= 7e-14)) {
tmp = ((Math.tan(eps) + Math.tan(x)) / (1.0 - (Math.tan(eps) * Math.tan(x)))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -6.2e-9) or not (eps <= 7e-14): tmp = ((math.tan(eps) + math.tan(x)) / (1.0 - (math.tan(eps) * math.tan(x)))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -6.2e-9) || !(eps <= 7e-14)) tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / Float64(1.0 - Float64(tan(eps) * tan(x)))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -6.2e-9) || ~((eps <= 7e-14))) tmp = ((tan(eps) + tan(x)) / (1.0 - (tan(eps) * tan(x)))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -6.2e-9], N[Not[LessEqual[eps, 7e-14]], $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[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -6.2 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -6.2000000000000001e-9 or 7.0000000000000005e-14 < eps Initial program 49.5%
tan-sum99.3%
div-inv99.3%
Applied egg-rr99.3%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
if -6.2000000000000001e-9 < eps < 7.0000000000000005e-14Initial program 23.1%
Taylor expanded in eps around 0 99.4%
sub-neg99.4%
mul-1-neg99.4%
remove-double-neg99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (+ (tan eps) (tan x))))
(if (<= eps -6.4e-9)
(- (/ 1.0 (/ t_0 t_1)) (tan x))
(if (<= eps 7e-14)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_1 t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = tan(eps) + tan(x);
double tmp;
if (eps <= -6.4e-9) {
tmp = (1.0 / (t_0 / t_1)) - tan(x);
} else if (eps <= 7e-14) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_1 / t_0) - 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 = 1.0d0 - (tan(eps) * tan(x))
t_1 = tan(eps) + tan(x)
if (eps <= (-6.4d-9)) then
tmp = (1.0d0 / (t_0 / t_1)) - tan(x)
else if (eps <= 7d-14) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_1 / t_0) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(eps) * Math.tan(x));
double t_1 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -6.4e-9) {
tmp = (1.0 / (t_0 / t_1)) - Math.tan(x);
} else if (eps <= 7e-14) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_1 / t_0) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(eps) * math.tan(x)) t_1 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -6.4e-9: tmp = (1.0 / (t_0 / t_1)) - math.tan(x) elif eps <= 7e-14: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_1 / t_0) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -6.4e-9) tmp = Float64(Float64(1.0 / Float64(t_0 / t_1)) - tan(x)); elseif (eps <= 7e-14) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_1 / t_0) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(eps) * tan(x)); t_1 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -6.4e-9) tmp = (1.0 / (t_0 / t_1)) - tan(x); elseif (eps <= 7e-14) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_1 / t_0) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6.4e-9], N[(N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-14], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -6.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\frac{t_0}{t_1}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -6.40000000000000023e-9Initial program 49.3%
tan-sum99.3%
div-inv99.2%
*-commutative99.2%
Applied egg-rr99.2%
+-commutative99.2%
tan-quot98.9%
div-inv98.9%
fma-def98.9%
Applied egg-rr98.9%
associate-*l/99.0%
associate-/l*99.2%
fma-udef99.2%
+-commutative99.2%
div-inv99.2%
tan-quot99.4%
Applied egg-rr99.4%
if -6.40000000000000023e-9 < eps < 7.0000000000000005e-14Initial program 23.1%
Taylor expanded in eps around 0 99.4%
sub-neg99.4%
mul-1-neg99.4%
remove-double-neg99.4%
Simplified99.4%
if 7.0000000000000005e-14 < eps Initial program 49.7%
tan-sum99.3%
div-inv99.3%
Applied egg-rr99.3%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.0037) (not (<= eps 7e-14))) (tan eps) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0037) || !(eps <= 7e-14)) {
tmp = tan(eps);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.0037d0)) .or. (.not. (eps <= 7d-14))) then
tmp = tan(eps)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0037) || !(eps <= 7e-14)) {
tmp = Math.tan(eps);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0037) or not (eps <= 7e-14): tmp = math.tan(eps) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0037) || !(eps <= 7e-14)) tmp = tan(eps); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0037) || ~((eps <= 7e-14))) tmp = tan(eps); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0037], N[Not[LessEqual[eps, 7e-14]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0037 \lor \neg \left(\varepsilon \leq 7 \cdot 10^{-14}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -0.0037000000000000002 or 7.0000000000000005e-14 < eps Initial program 50.2%
Taylor expanded in x around 0 53.1%
expm1-log1p-u41.3%
expm1-udef40.3%
tan-quot40.5%
Applied egg-rr40.5%
expm1-def41.5%
expm1-log1p53.4%
Simplified53.4%
if -0.0037000000000000002 < eps < 7.0000000000000005e-14Initial program 22.7%
Taylor expanded in eps around 0 98.2%
sub-neg98.2%
mul-1-neg98.2%
remove-double-neg98.2%
Simplified98.2%
Final simplification74.7%
(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 37.1%
Taylor expanded in x around 0 57.3%
expm1-log1p-u51.1%
expm1-udef24.5%
tan-quot24.6%
Applied egg-rr24.6%
expm1-def51.2%
expm1-log1p57.4%
Simplified57.4%
Final simplification57.4%
(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 37.1%
Taylor expanded in x around 0 57.3%
Taylor expanded in eps around 0 32.0%
Final simplification32.0%
(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 2023305
(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)))