
(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 (* (tan x) (tan eps)))
(t_1 (pow (sin x) 2.0))
(t_2 (pow (cos x) 2.0))
(t_3 (/ t_1 t_2))
(t_4 (+ t_3 1.0))
(t_5 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))
(t_6 (+ (tan x) (tan eps)))
(t_7 (/ (sin x) (cos x)))
(t_8 (+ t_7 t_5)))
(if (<= eps -0.00019)
(- (* (/ t_6 (- 1.0 (pow t_0 2.0))) (+ t_0 1.0)) (tan x))
(if (<= eps 0.0002)
(+
(* t_8 (pow eps 2.0))
(+
(* eps t_4)
(-
(*
(pow eps 3.0)
(+
(+ 0.3333333333333333 (* t_3 0.3333333333333333))
(/ (* t_1 t_4) t_2)))
(*
(pow eps 4.0)
(-
(- (* t_5 -0.6666666666666666) (/ (* t_8 t_1) t_2))
(* t_7 0.6666666666666666))))))
(fma t_6 (/ 1.0 (- 1.0 t_0)) (- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = pow(sin(x), 2.0);
double t_2 = pow(cos(x), 2.0);
double t_3 = t_1 / t_2;
double t_4 = t_3 + 1.0;
double t_5 = pow(sin(x), 3.0) / pow(cos(x), 3.0);
double t_6 = tan(x) + tan(eps);
double t_7 = sin(x) / cos(x);
double t_8 = t_7 + t_5;
double tmp;
if (eps <= -0.00019) {
tmp = ((t_6 / (1.0 - pow(t_0, 2.0))) * (t_0 + 1.0)) - tan(x);
} else if (eps <= 0.0002) {
tmp = (t_8 * pow(eps, 2.0)) + ((eps * t_4) + ((pow(eps, 3.0) * ((0.3333333333333333 + (t_3 * 0.3333333333333333)) + ((t_1 * t_4) / t_2))) - (pow(eps, 4.0) * (((t_5 * -0.6666666666666666) - ((t_8 * t_1) / t_2)) - (t_7 * 0.6666666666666666)))));
} else {
tmp = fma(t_6, (1.0 / (1.0 - t_0)), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = sin(x) ^ 2.0 t_2 = cos(x) ^ 2.0 t_3 = Float64(t_1 / t_2) t_4 = Float64(t_3 + 1.0) t_5 = Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) t_6 = Float64(tan(x) + tan(eps)) t_7 = Float64(sin(x) / cos(x)) t_8 = Float64(t_7 + t_5) tmp = 0.0 if (eps <= -0.00019) tmp = Float64(Float64(Float64(t_6 / Float64(1.0 - (t_0 ^ 2.0))) * Float64(t_0 + 1.0)) - tan(x)); elseif (eps <= 0.0002) tmp = Float64(Float64(t_8 * (eps ^ 2.0)) + Float64(Float64(eps * t_4) + Float64(Float64((eps ^ 3.0) * Float64(Float64(0.3333333333333333 + Float64(t_3 * 0.3333333333333333)) + Float64(Float64(t_1 * t_4) / t_2))) - Float64((eps ^ 4.0) * Float64(Float64(Float64(t_5 * -0.6666666666666666) - Float64(Float64(t_8 * t_1) / t_2)) - Float64(t_7 * 0.6666666666666666)))))); else tmp = fma(t_6, Float64(1.0 / Float64(1.0 - t_0)), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + 1.0), $MachinePrecision]}, Block[{t$95$5 = N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$8 = N[(t$95$7 + t$95$5), $MachinePrecision]}, If[LessEqual[eps, -0.00019], N[(N[(N[(t$95$6 / N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0002], N[(N[(t$95$8 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(eps * t$95$4), $MachinePrecision] + N[(N[(N[Power[eps, 3.0], $MachinePrecision] * N[(N[(0.3333333333333333 + N[(t$95$3 * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$1 * t$95$4), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(N[(t$95$5 * -0.6666666666666666), $MachinePrecision] - N[(N[(t$95$8 * t$95$1), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] - N[(t$95$7 * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$6 * N[(1.0 / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := {\sin x}^{2}\\
t_2 := {\cos x}^{2}\\
t_3 := \frac{t_1}{t_2}\\
t_4 := t_3 + 1\\
t_5 := \frac{{\sin x}^{3}}{{\cos x}^{3}}\\
t_6 := \tan x + \tan \varepsilon\\
t_7 := \frac{\sin x}{\cos x}\\
t_8 := t_7 + t_5\\
\mathbf{if}\;\varepsilon \leq -0.00019:\\
\;\;\;\;\frac{t_6}{1 - {t_0}^{2}} \cdot \left(t_0 + 1\right) - \tan x\\
\mathbf{elif}\;\varepsilon \leq 0.0002:\\
\;\;\;\;t_8 \cdot {\varepsilon}^{2} + \left(\varepsilon \cdot t_4 + \left({\varepsilon}^{3} \cdot \left(\left(0.3333333333333333 + t_3 \cdot 0.3333333333333333\right) + \frac{t_1 \cdot t_4}{t_2}\right) - {\varepsilon}^{4} \cdot \left(\left(t_5 \cdot -0.6666666666666666 - \frac{t_8 \cdot t_1}{t_2}\right) - t_7 \cdot 0.6666666666666666\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_6, \frac{1}{1 - t_0}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -1.9000000000000001e-4Initial program 60.3%
tan-sum99.7%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
fma-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
flip--99.6%
associate-/r/99.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
if -1.9000000000000001e-4 < eps < 2.0000000000000001e-4Initial program 35.2%
tan-sum36.8%
div-inv36.8%
fma-neg36.8%
Applied egg-rr36.8%
fma-neg36.8%
associate-*r/36.8%
*-rgt-identity36.8%
Simplified36.8%
flip--36.8%
associate-/r/36.9%
metadata-eval36.9%
pow236.9%
Applied egg-rr36.9%
Taylor expanded in eps around 0 99.6%
if 2.0000000000000001e-4 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps)))
(t_1 (- 1.0 t_0))
(t_2 (+ (tan x) (tan eps)))
(t_3 (/ (pow (sin x) 2.0) (cos x))))
(if (<= eps -0.00041)
(- (* (/ t_2 (- 1.0 (pow t_0 2.0))) (+ t_0 1.0)) (tan x))
(if (<= eps 0.00027)
(/
(+
(* eps (+ (cos x) t_3))
(*
(pow eps 3.0)
(- (* (cos x) 0.3333333333333333) (* t_3 -0.3333333333333333))))
(* (cos x) t_1))
(fma t_2 (/ 1.0 t_1) (- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = 1.0 - t_0;
double t_2 = tan(x) + tan(eps);
double t_3 = pow(sin(x), 2.0) / cos(x);
double tmp;
if (eps <= -0.00041) {
tmp = ((t_2 / (1.0 - pow(t_0, 2.0))) * (t_0 + 1.0)) - tan(x);
} else if (eps <= 0.00027) {
tmp = ((eps * (cos(x) + t_3)) + (pow(eps, 3.0) * ((cos(x) * 0.3333333333333333) - (t_3 * -0.3333333333333333)))) / (cos(x) * t_1);
} else {
tmp = fma(t_2, (1.0 / t_1), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = Float64(1.0 - t_0) t_2 = Float64(tan(x) + tan(eps)) t_3 = Float64((sin(x) ^ 2.0) / cos(x)) tmp = 0.0 if (eps <= -0.00041) tmp = Float64(Float64(Float64(t_2 / Float64(1.0 - (t_0 ^ 2.0))) * Float64(t_0 + 1.0)) - tan(x)); elseif (eps <= 0.00027) tmp = Float64(Float64(Float64(eps * Float64(cos(x) + t_3)) + Float64((eps ^ 3.0) * Float64(Float64(cos(x) * 0.3333333333333333) - Float64(t_3 * -0.3333333333333333)))) / Float64(cos(x) * t_1)); else tmp = fma(t_2, Float64(1.0 / t_1), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00041], N[(N[(N[(t$95$2 / N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00027], N[(N[(N[(eps * N[(N[Cos[x], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - N[(t$95$3 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := 1 - t_0\\
t_2 := \tan x + \tan \varepsilon\\
t_3 := \frac{{\sin x}^{2}}{\cos x}\\
\mathbf{if}\;\varepsilon \leq -0.00041:\\
\;\;\;\;\frac{t_2}{1 - {t_0}^{2}} \cdot \left(t_0 + 1\right) - \tan x\\
\mathbf{elif}\;\varepsilon \leq 0.00027:\\
\;\;\;\;\frac{\varepsilon \cdot \left(\cos x + t_3\right) + {\varepsilon}^{3} \cdot \left(\cos x \cdot 0.3333333333333333 - t_3 \cdot -0.3333333333333333\right)}{\cos x \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_2, \frac{1}{t_1}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -4.0999999999999999e-4Initial program 60.3%
tan-sum99.7%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
fma-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
flip--99.6%
associate-/r/99.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
if -4.0999999999999999e-4 < eps < 2.70000000000000003e-4Initial program 35.2%
tan-sum36.8%
tan-quot36.5%
frac-sub36.5%
Applied egg-rr36.5%
Taylor expanded in eps around 0 99.6%
if 2.70000000000000003e-4 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -6.2e-7)
(- (* (/ t_1 (- 1.0 (pow t_0 2.0))) (+ t_0 1.0)) (tan x))
(if (<= eps 2.4e-7)
(+
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
eps
(*
eps
(+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0))))))
(fma t_1 (/ 1.0 (- 1.0 t_0)) (- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -6.2e-7) {
tmp = ((t_1 / (1.0 - pow(t_0, 2.0))) * (t_0 + 1.0)) - tan(x);
} else if (eps <= 2.4e-7) {
tmp = (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + (eps * (eps * ((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0)))));
} else {
tmp = fma(t_1, (1.0 / (1.0 - t_0)), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -6.2e-7) tmp = Float64(Float64(Float64(t_1 / Float64(1.0 - (t_0 ^ 2.0))) * Float64(t_0 + 1.0)) - tan(x)); elseif (eps <= 2.4e-7) tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64(eps * Float64(eps * Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))))); else tmp = fma(t_1, Float64(1.0 / Float64(1.0 - t_0)), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6.2e-7], N[(N[(N[(t$95$1 / N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.4e-7], N[(N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(eps * 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]), $MachinePrecision], N[(t$95$1 * N[(1.0 / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -6.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_1}{1 - {t_0}^{2}} \cdot \left(t_0 + 1\right) - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-7}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \varepsilon \cdot \left(\varepsilon \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{1 - t_0}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -6.1999999999999999e-7Initial program 59.4%
tan-sum99.5%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
flip--99.3%
associate-/r/99.5%
metadata-eval99.5%
pow299.5%
Applied egg-rr99.5%
if -6.1999999999999999e-7 < eps < 2.39999999999999979e-7Initial program 35.4%
tan-sum36.5%
div-inv36.5%
fma-neg36.5%
Applied egg-rr36.5%
fma-neg36.5%
associate-*r/36.5%
*-rgt-identity36.5%
Simplified36.5%
Taylor expanded in eps around 0 99.5%
mul-1-neg99.5%
unsub-neg99.5%
Simplified99.6%
if 2.39999999999999979e-7 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps)))
(t_1 (+ (tan x) (tan eps)))
(t_2 (- 1.0 t_0)))
(if (<= eps -6.2e-7)
(- (* (/ t_1 (- 1.0 (pow t_0 2.0))) (+ t_0 1.0)) (tan x))
(if (<= eps 2.15e-7)
(/ (* eps (+ (cos x) (/ (pow (sin x) 2.0) (cos x)))) (* (cos x) t_2))
(fma t_1 (/ 1.0 t_2) (- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = tan(x) + tan(eps);
double t_2 = 1.0 - t_0;
double tmp;
if (eps <= -6.2e-7) {
tmp = ((t_1 / (1.0 - pow(t_0, 2.0))) * (t_0 + 1.0)) - tan(x);
} else if (eps <= 2.15e-7) {
tmp = (eps * (cos(x) + (pow(sin(x), 2.0) / cos(x)))) / (cos(x) * t_2);
} else {
tmp = fma(t_1, (1.0 / t_2), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(1.0 - t_0) tmp = 0.0 if (eps <= -6.2e-7) tmp = Float64(Float64(Float64(t_1 / Float64(1.0 - (t_0 ^ 2.0))) * Float64(t_0 + 1.0)) - tan(x)); elseif (eps <= 2.15e-7) tmp = Float64(Float64(eps * Float64(cos(x) + Float64((sin(x) ^ 2.0) / cos(x)))) / Float64(cos(x) * t_2)); else tmp = fma(t_1, Float64(1.0 / t_2), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[eps, -6.2e-7], N[(N[(N[(t$95$1 / N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.15e-7], N[(N[(eps * N[(N[Cos[x], $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 / t$95$2), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
t_2 := 1 - t_0\\
\mathbf{if}\;\varepsilon \leq -6.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_1}{1 - {t_0}^{2}} \cdot \left(t_0 + 1\right) - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.15 \cdot 10^{-7}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(\cos x + \frac{{\sin x}^{2}}{\cos x}\right)}{\cos x \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{t_2}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -6.1999999999999999e-7Initial program 59.4%
tan-sum99.5%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
flip--99.3%
associate-/r/99.5%
metadata-eval99.5%
pow299.5%
Applied egg-rr99.5%
if -6.1999999999999999e-7 < eps < 2.1500000000000001e-7Initial program 35.4%
tan-sum36.5%
tan-quot36.1%
frac-sub36.2%
Applied egg-rr36.2%
Taylor expanded in eps around 0 99.5%
*-commutative99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
if 2.1500000000000001e-7 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -7.7e-7)
(- (/ t_0 t_1) (tan x))
(if (<= eps 2.15e-7)
(/ (* eps (+ (cos x) (/ (pow (sin x) 2.0) (cos x)))) (* (cos x) t_1))
(fma t_0 (/ 1.0 t_1) (- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -7.7e-7) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 2.15e-7) {
tmp = (eps * (cos(x) + (pow(sin(x), 2.0) / cos(x)))) / (cos(x) * t_1);
} else {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -7.7e-7) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 2.15e-7) tmp = Float64(Float64(eps * Float64(cos(x) + Float64((sin(x) ^ 2.0) / cos(x)))) / Float64(cos(x) * t_1)); else tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7.7e-7], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.15e-7], N[(N[(eps * N[(N[Cos[x], $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -7.7 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.15 \cdot 10^{-7}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(\cos x + \frac{{\sin x}^{2}}{\cos x}\right)}{\cos x \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -7.7000000000000004e-7Initial program 59.4%
tan-sum99.5%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
if -7.7000000000000004e-7 < eps < 2.1500000000000001e-7Initial program 35.4%
tan-sum36.5%
tan-quot36.1%
frac-sub36.2%
Applied egg-rr36.2%
Taylor expanded in eps around 0 99.5%
*-commutative99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
if 2.1500000000000001e-7 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -3.4e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 2.9e-9)
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(fma t_0 (/ 1.0 t_1) (- (tan x)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -3.4e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 2.9e-9) {
tmp = eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -3.4e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 2.9e-9) tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.4e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.9e-9], N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.9 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\end{array}
\end{array}
if eps < -3.3999999999999998e-9Initial program 58.6%
tan-sum99.2%
div-inv99.1%
fma-neg99.1%
Applied egg-rr99.1%
fma-neg99.1%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
if -3.3999999999999998e-9 < eps < 2.89999999999999991e-9Initial program 35.7%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
distribute-lft-in99.6%
*-rgt-identity99.6%
Simplified99.6%
if 2.89999999999999991e-9 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
fma-neg99.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -2.7e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 5.1e-9)
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* t_0 (/ 1.0 t_1)) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -2.7e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 5.1e-9) {
tmp = eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (1.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 <= (-2.7d-9)) then
tmp = (t_0 / t_1) - tan(x)
else if (eps <= 5.1d-9) then
tmp = eps + (eps * ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 * (1.0d0 / 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 <= -2.7e-9) {
tmp = (t_0 / t_1) - Math.tan(x);
} else if (eps <= 5.1e-9) {
tmp = eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 * (1.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 <= -2.7e-9: tmp = (t_0 / t_1) - math.tan(x) elif eps <= 5.1e-9: tmp = eps + (eps * (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 * (1.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 <= -2.7e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 5.1e-9) tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 * Float64(1.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 <= -2.7e-9) tmp = (t_0 / t_1) - tan(x); elseif (eps <= 5.1e-9) tmp = eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 * (1.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, -2.7e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.1e-9], N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $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 -2.7 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 5.1 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -2.7000000000000002e-9Initial program 58.6%
tan-sum99.2%
div-inv99.1%
fma-neg99.1%
Applied egg-rr99.1%
fma-neg99.1%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
if -2.7000000000000002e-9 < eps < 5.10000000000000017e-9Initial program 35.7%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
distribute-lft-in99.6%
*-rgt-identity99.6%
Simplified99.6%
if 5.10000000000000017e-9 < eps Initial program 52.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.7e-9) (not (<= eps 3.9e-9))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.7e-9) || !(eps <= 3.9e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = eps + (eps * (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 <= (-2.7d-9)) .or. (.not. (eps <= 3.9d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = eps + (eps * ((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 <= -2.7e-9) || !(eps <= 3.9e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.7e-9) or not (eps <= 3.9e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = eps + (eps * (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 <= -2.7e-9) || !(eps <= 3.9e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.7e-9) || ~((eps <= 3.9e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.7e-9], N[Not[LessEqual[eps, 3.9e-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[(eps * 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 -2.7 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.9 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\end{array}
\end{array}
if eps < -2.7000000000000002e-9 or 3.9000000000000002e-9 < eps Initial program 56.1%
tan-sum99.3%
div-inv99.3%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.3%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
if -2.7000000000000002e-9 < eps < 3.9000000000000002e-9Initial program 35.7%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
distribute-lft-in99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.25e-5)
(tan eps)
(if (<= eps 8.9e-7)
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.25e-5) {
tmp = tan(eps);
} else if (eps <= 8.9e-7) {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
} else {
tmp = tan(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-1.25d-5)) then
tmp = tan(eps)
else if (eps <= 8.9d-7) then
tmp = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -1.25e-5) {
tmp = Math.tan(eps);
} else if (eps <= 8.9e-7) {
tmp = eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.25e-5: tmp = math.tan(eps) elif eps <= 8.9e-7: tmp = eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.25e-5) tmp = tan(eps); elseif (eps <= 8.9e-7) tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.25e-5) tmp = tan(eps); elseif (eps <= 8.9e-7) tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.25e-5], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 8.9e-7], 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[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.25 \cdot 10^{-5}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 8.9 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -1.25000000000000006e-5 or 8.899999999999999e-7 < eps Initial program 56.9%
Taylor expanded in x around 0 59.1%
tan-quot59.4%
expm1-log1p-u42.3%
expm1-udef41.9%
Applied egg-rr41.9%
expm1-def42.3%
expm1-log1p59.4%
Simplified59.4%
if -1.25000000000000006e-5 < eps < 8.899999999999999e-7Initial program 35.2%
tan-sum36.8%
div-inv36.8%
fma-neg36.8%
Applied egg-rr36.8%
Taylor expanded in eps around 0 98.6%
Final simplification79.2%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.25e-5)
(tan eps)
(if (<= eps 5.6e-6)
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.25e-5) {
tmp = tan(eps);
} else if (eps <= 5.6e-6) {
tmp = eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = tan(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-1.25d-5)) then
tmp = tan(eps)
else if (eps <= 5.6d-6) then
tmp = eps + (eps * ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -1.25e-5) {
tmp = Math.tan(eps);
} else if (eps <= 5.6e-6) {
tmp = eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.25e-5: tmp = math.tan(eps) elif eps <= 5.6e-6: tmp = eps + (eps * (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.25e-5) tmp = tan(eps); elseif (eps <= 5.6e-6) tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.25e-5) tmp = tan(eps); elseif (eps <= 5.6e-6) tmp = eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.25e-5], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 5.6e-6], N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.25 \cdot 10^{-5}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 5.6 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -1.25000000000000006e-5 or 5.59999999999999975e-6 < eps Initial program 56.9%
Taylor expanded in x around 0 59.1%
tan-quot59.4%
expm1-log1p-u42.3%
expm1-udef41.9%
Applied egg-rr41.9%
expm1-def42.3%
expm1-log1p59.4%
Simplified59.4%
if -1.25000000000000006e-5 < eps < 5.59999999999999975e-6Initial program 35.2%
Taylor expanded in eps around 0 98.6%
cancel-sign-sub-inv98.6%
metadata-eval98.6%
*-lft-identity98.6%
distribute-lft-in98.8%
*-rgt-identity98.8%
Simplified98.8%
Final simplification79.2%
(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 45.9%
Taylor expanded in x around 0 62.6%
tan-quot62.7%
expm1-log1p-u54.3%
expm1-udef24.1%
Applied egg-rr24.1%
expm1-def54.3%
expm1-log1p62.7%
Simplified62.7%
Final simplification62.7%
(FPCore (x eps) :precision binary64 eps)
double code(double x, double eps) {
return eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps
end function
public static double code(double x, double eps) {
return eps;
}
def code(x, eps): return eps
function code(x, eps) return eps end
function tmp = code(x, eps) tmp = eps; end
code[x_, eps_] := eps
\begin{array}{l}
\\
\varepsilon
\end{array}
Initial program 45.9%
Taylor expanded in x around 0 62.6%
Taylor expanded in eps around 0 35.1%
Final simplification35.1%
(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 2023229
(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)))