
(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 (pow (sin x) 2.0))
(t_1 (pow (cos x) 2.0))
(t_2 (/ (sin eps) (cos eps)))
(t_3 (/ (sin x) (cos x)))
(t_4 (* t_3 -0.3333333333333333))
(t_5 (/ (pow (sin x) 3.0) (pow (cos x) 3.0))))
(if (or (<= eps -0.00037) (not (<= eps 8.2e-9)))
(- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x))
(+
(/ t_2 (- 1.0 (* t_2 t_3)))
(*
(tan x)
(+
(* t_0 (/ (* eps eps) t_1))
(+
(- (/ (* eps (sin x)) (cos x)) (* (pow eps 3.0) (- t_4 t_5)))
(*
(pow eps 4.0)
(-
(* (sin x) (/ (- t_5 t_4) (cos x)))
(* -0.3333333333333333 (/ t_0 t_1)))))))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0);
double t_1 = pow(cos(x), 2.0);
double t_2 = sin(eps) / cos(eps);
double t_3 = sin(x) / cos(x);
double t_4 = t_3 * -0.3333333333333333;
double t_5 = pow(sin(x), 3.0) / pow(cos(x), 3.0);
double tmp;
if ((eps <= -0.00037) || !(eps <= 8.2e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = (t_2 / (1.0 - (t_2 * t_3))) + (tan(x) * ((t_0 * ((eps * eps) / t_1)) + ((((eps * sin(x)) / cos(x)) - (pow(eps, 3.0) * (t_4 - t_5))) + (pow(eps, 4.0) * ((sin(x) * ((t_5 - t_4) / cos(x))) - (-0.3333333333333333 * (t_0 / t_1)))))));
}
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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(x) ** 2.0d0
t_1 = cos(x) ** 2.0d0
t_2 = sin(eps) / cos(eps)
t_3 = sin(x) / cos(x)
t_4 = t_3 * (-0.3333333333333333d0)
t_5 = (sin(x) ** 3.0d0) / (cos(x) ** 3.0d0)
if ((eps <= (-0.00037d0)) .or. (.not. (eps <= 8.2d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = (t_2 / (1.0d0 - (t_2 * t_3))) + (tan(x) * ((t_0 * ((eps * eps) / t_1)) + ((((eps * sin(x)) / cos(x)) - ((eps ** 3.0d0) * (t_4 - t_5))) + ((eps ** 4.0d0) * ((sin(x) * ((t_5 - t_4) / cos(x))) - ((-0.3333333333333333d0) * (t_0 / t_1)))))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.sin(x), 2.0);
double t_1 = Math.pow(Math.cos(x), 2.0);
double t_2 = Math.sin(eps) / Math.cos(eps);
double t_3 = Math.sin(x) / Math.cos(x);
double t_4 = t_3 * -0.3333333333333333;
double t_5 = Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0);
double tmp;
if ((eps <= -0.00037) || !(eps <= 8.2e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = (t_2 / (1.0 - (t_2 * t_3))) + (Math.tan(x) * ((t_0 * ((eps * eps) / t_1)) + ((((eps * Math.sin(x)) / Math.cos(x)) - (Math.pow(eps, 3.0) * (t_4 - t_5))) + (Math.pow(eps, 4.0) * ((Math.sin(x) * ((t_5 - t_4) / Math.cos(x))) - (-0.3333333333333333 * (t_0 / t_1)))))));
}
return tmp;
}
def code(x, eps): t_0 = math.pow(math.sin(x), 2.0) t_1 = math.pow(math.cos(x), 2.0) t_2 = math.sin(eps) / math.cos(eps) t_3 = math.sin(x) / math.cos(x) t_4 = t_3 * -0.3333333333333333 t_5 = math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0) tmp = 0 if (eps <= -0.00037) or not (eps <= 8.2e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = (t_2 / (1.0 - (t_2 * t_3))) + (math.tan(x) * ((t_0 * ((eps * eps) / t_1)) + ((((eps * math.sin(x)) / math.cos(x)) - (math.pow(eps, 3.0) * (t_4 - t_5))) + (math.pow(eps, 4.0) * ((math.sin(x) * ((t_5 - t_4) / math.cos(x))) - (-0.3333333333333333 * (t_0 / t_1))))))) return tmp
function code(x, eps) t_0 = sin(x) ^ 2.0 t_1 = cos(x) ^ 2.0 t_2 = Float64(sin(eps) / cos(eps)) t_3 = Float64(sin(x) / cos(x)) t_4 = Float64(t_3 * -0.3333333333333333) t_5 = Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) tmp = 0.0 if ((eps <= -0.00037) || !(eps <= 8.2e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(Float64(t_2 / Float64(1.0 - Float64(t_2 * t_3))) + Float64(tan(x) * Float64(Float64(t_0 * Float64(Float64(eps * eps) / t_1)) + Float64(Float64(Float64(Float64(eps * sin(x)) / cos(x)) - Float64((eps ^ 3.0) * Float64(t_4 - t_5))) + Float64((eps ^ 4.0) * Float64(Float64(sin(x) * Float64(Float64(t_5 - t_4) / cos(x))) - Float64(-0.3333333333333333 * Float64(t_0 / t_1)))))))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) ^ 2.0; t_1 = cos(x) ^ 2.0; t_2 = sin(eps) / cos(eps); t_3 = sin(x) / cos(x); t_4 = t_3 * -0.3333333333333333; t_5 = (sin(x) ^ 3.0) / (cos(x) ^ 3.0); tmp = 0.0; if ((eps <= -0.00037) || ~((eps <= 8.2e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = (t_2 / (1.0 - (t_2 * t_3))) + (tan(x) * ((t_0 * ((eps * eps) / t_1)) + ((((eps * sin(x)) / cos(x)) - ((eps ^ 3.0) * (t_4 - t_5))) + ((eps ^ 4.0) * ((sin(x) * ((t_5 - t_4) / cos(x))) - (-0.3333333333333333 * (t_0 / t_1))))))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * -0.3333333333333333), $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]}, If[Or[LessEqual[eps, -0.00037], N[Not[LessEqual[eps, 8.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[(N[(t$95$2 / N[(1.0 - N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(t$95$0 * N[(N[(eps * eps), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, 3.0], $MachinePrecision] * N[(t$95$4 - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 4.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] * N[(N[(t$95$5 - t$95$4), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-0.3333333333333333 * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := {\cos x}^{2}\\
t_2 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_3 := \frac{\sin x}{\cos x}\\
t_4 := t_3 \cdot -0.3333333333333333\\
t_5 := \frac{{\sin x}^{3}}{{\cos x}^{3}}\\
\mathbf{if}\;\varepsilon \leq -0.00037 \lor \neg \left(\varepsilon \leq 8.2 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2}{1 - t_2 \cdot t_3} + \tan x \cdot \left(t_0 \cdot \frac{\varepsilon \cdot \varepsilon}{t_1} + \left(\left(\frac{\varepsilon \cdot \sin x}{\cos x} - {\varepsilon}^{3} \cdot \left(t_4 - t_5\right)\right) + {\varepsilon}^{4} \cdot \left(\sin x \cdot \frac{t_5 - t_4}{\cos x} - -0.3333333333333333 \cdot \frac{t_0}{t_1}\right)\right)\right)\\
\end{array}
\end{array}
if eps < -3.6999999999999999e-4 or 8.2000000000000006e-9 < eps Initial program 49.8%
tan-sum99.4%
div-inv99.3%
fma-neg99.3%
Applied egg-rr99.3%
fma-neg99.3%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
if -3.6999999999999999e-4 < eps < 8.2000000000000006e-9Initial program 26.5%
tan-sum27.5%
div-inv27.5%
fma-neg27.6%
Applied egg-rr27.6%
Taylor expanded in x around inf 27.5%
associate--l+55.2%
Simplified55.3%
tan-quot53.2%
tan-quot55.3%
div-inv55.3%
tan-quot55.3%
tan-quot55.3%
*-commutative55.3%
Applied egg-rr55.2%
fma-udef55.3%
*-rgt-identity55.3%
distribute-rgt-neg-in55.3%
metadata-eval55.3%
distribute-lft-out55.2%
Simplified55.2%
Taylor expanded in eps around 0 99.8%
*-commutative99.8%
*-lft-identity99.8%
times-frac99.8%
/-rgt-identity99.8%
unpow299.8%
Simplified99.8%
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 -1.9e-7)
(fma t_0 (/ 1.0 t_1) (- (tan x)))
(if (<= eps 8.2e-9)
(fma
(+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))
(* eps eps)
(* 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 <= -1.9e-7) {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
} else if (eps <= 8.2e-9) {
tmp = fma(((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))), (eps * eps), (eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0)));
} else {
tmp = (t_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 <= -1.9e-7) tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); elseif (eps <= 8.2e-9) tmp = fma(Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))), Float64(eps * eps), 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
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, -1.9e-7], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 8.2e-9], N[(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] * N[(eps * eps), $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]), $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 -1.9 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 8.2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}, \varepsilon \cdot \varepsilon, \varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -1.90000000000000007e-7Initial program 50.9%
tan-sum98.9%
div-inv98.9%
fma-neg98.9%
Applied egg-rr98.9%
if -1.90000000000000007e-7 < eps < 8.2000000000000006e-9Initial program 26.1%
tan-sum26.5%
div-inv26.5%
fma-neg26.5%
Applied egg-rr26.5%
Taylor expanded in eps around 0 99.6%
fma-def99.6%
unpow299.6%
Simplified99.6%
if 8.2000000000000006e-9 < eps Initial program 48.6%
tan-sum99.6%
div-inv99.6%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin eps) (cos eps)))
(t_1 (+ (tan x) (tan eps)))
(t_2 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -2.05e-7)
(fma t_1 (/ 1.0 t_2) (- (tan x)))
(if (<= eps 2.75e-9)
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(* (tan x) (/ eps (/ (cos x) (sin x)))))
(- (/ t_1 t_2) (tan x))))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
double t_1 = tan(x) + tan(eps);
double t_2 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -2.05e-7) {
tmp = fma(t_1, (1.0 / t_2), -tan(x));
} else if (eps <= 2.75e-9) {
tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + (tan(x) * (eps / (cos(x) / sin(x))));
} else {
tmp = (t_1 / t_2) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -2.05e-7) tmp = fma(t_1, Float64(1.0 / t_2), Float64(-tan(x))); elseif (eps <= 2.75e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(tan(x) * Float64(eps / Float64(cos(x) / sin(x))))); else tmp = Float64(Float64(t_1 / t_2) - 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]}, Block[{t$95$2 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.05e-7], N[(t$95$1 * N[(1.0 / t$95$2), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.75e-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[(eps / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$2), $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\\
t_2 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.05 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{t_2}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.75 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \tan x \cdot \frac{\varepsilon}{\frac{\cos x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_2} - \tan x\\
\end{array}
\end{array}
if eps < -2.05e-7Initial program 50.2%
tan-sum98.9%
div-inv98.9%
fma-neg98.9%
Applied egg-rr98.9%
if -2.05e-7 < eps < 2.7499999999999998e-9Initial program 26.7%
tan-sum27.1%
div-inv27.1%
fma-neg27.1%
Applied egg-rr27.1%
Taylor expanded in x around inf 27.1%
associate--l+55.0%
Simplified55.0%
tan-quot53.0%
tan-quot55.0%
div-inv55.0%
tan-quot55.0%
tan-quot55.0%
*-commutative55.0%
Applied egg-rr54.9%
fma-udef55.0%
*-rgt-identity55.0%
distribute-rgt-neg-in55.0%
metadata-eval55.0%
distribute-lft-out54.9%
Simplified54.9%
Taylor expanded in eps around 0 99.5%
associate-/l*99.5%
Simplified99.5%
if 2.7499999999999998e-9 < eps Initial program 48.6%
tan-sum99.6%
div-inv99.6%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin eps) (cos eps)))
(t_1 (+ (tan x) (tan eps)))
(t_2 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -2.05e-7)
(fma t_1 (/ 1.0 t_2) (- (tan x)))
(if (<= eps 7.3e-9)
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(* (tan x) (/ (* eps (sin x)) (cos x))))
(- (/ t_1 t_2) (tan x))))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
double t_1 = tan(x) + tan(eps);
double t_2 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -2.05e-7) {
tmp = fma(t_1, (1.0 / t_2), -tan(x));
} else if (eps <= 7.3e-9) {
tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + (tan(x) * ((eps * sin(x)) / cos(x)));
} else {
tmp = (t_1 / t_2) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -2.05e-7) tmp = fma(t_1, Float64(1.0 / t_2), Float64(-tan(x))); elseif (eps <= 7.3e-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 / t_2) - 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]}, Block[{t$95$2 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.05e-7], N[(t$95$1 * N[(1.0 / t$95$2), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 7.3e-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 / t$95$2), $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\\
t_2 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.05 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{t_2}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 7.3 \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}{t_2} - \tan x\\
\end{array}
\end{array}
if eps < -2.05e-7Initial program 50.2%
tan-sum98.9%
div-inv98.9%
fma-neg98.9%
Applied egg-rr98.9%
if -2.05e-7 < eps < 7.30000000000000002e-9Initial program 26.7%
tan-sum27.1%
div-inv27.1%
fma-neg27.1%
Applied egg-rr27.1%
Taylor expanded in x around inf 27.1%
associate--l+55.0%
Simplified55.0%
tan-quot53.0%
tan-quot55.0%
div-inv55.0%
tan-quot55.0%
tan-quot55.0%
*-commutative55.0%
Applied egg-rr54.9%
fma-udef55.0%
*-rgt-identity55.0%
distribute-rgt-neg-in55.0%
metadata-eval55.0%
distribute-lft-out54.9%
Simplified54.9%
Taylor expanded in eps around 0 99.5%
if 7.30000000000000002e-9 < eps Initial program 48.6%
tan-sum99.6%
div-inv99.6%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -2.3e-9)
(fma t_0 (/ 1.0 t_1) (- (tan x)))
(if (<= eps 3.25e-9)
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.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 <= -2.3e-9) {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
} else if (eps <= 3.25e-9) {
tmp = eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_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 <= -2.3e-9) tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); elseif (eps <= 3.25e-9) tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 / t_1) - 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, -2.3e-9], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 3.25e-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 / 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 -2.3 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 3.25 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -2.2999999999999999e-9Initial program 50.9%
tan-sum98.9%
div-inv98.9%
fma-neg98.9%
Applied egg-rr98.9%
if -2.2999999999999999e-9 < eps < 3.2500000000000002e-9Initial program 26.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
distribute-lft-in99.4%
*-rgt-identity99.4%
Simplified99.4%
if 3.2500000000000002e-9 < eps Initial program 48.6%
tan-sum99.6%
div-inv99.6%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.1e-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 <= -3.1e-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 <= (-3.1d-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 <= -3.1e-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 <= -3.1e-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 <= -3.1e-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 <= -3.1e-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, -3.1e-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 -3.1 \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 < -3.10000000000000005e-9 or 3.9000000000000002e-9 < eps Initial program 49.8%
tan-sum99.2%
div-inv99.2%
fma-neg99.2%
Applied egg-rr99.2%
fma-neg99.2%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
if -3.10000000000000005e-9 < eps < 3.9000000000000002e-9Initial program 26.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
distribute-lft-in99.4%
*-rgt-identity99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00075) (not (<= eps 8.2e-9))) (- (* (sin (+ eps x)) (/ 1.0 (- (cos eps) (* x (sin 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 <= -0.00075) || !(eps <= 8.2e-9)) {
tmp = (sin((eps + x)) * (1.0 / (cos(eps) - (x * sin(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 <= (-0.00075d0)) .or. (.not. (eps <= 8.2d-9))) then
tmp = (sin((eps + x)) * (1.0d0 / (cos(eps) - (x * sin(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 <= -0.00075) || !(eps <= 8.2e-9)) {
tmp = (Math.sin((eps + x)) * (1.0 / (Math.cos(eps) - (x * Math.sin(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 <= -0.00075) or not (eps <= 8.2e-9): tmp = (math.sin((eps + x)) * (1.0 / (math.cos(eps) - (x * math.sin(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 <= -0.00075) || !(eps <= 8.2e-9)) tmp = Float64(Float64(sin(Float64(eps + x)) * Float64(1.0 / Float64(cos(eps) - Float64(x * sin(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 <= -0.00075) || ~((eps <= 8.2e-9))) tmp = (sin((eps + x)) * (1.0 / (cos(eps) - (x * sin(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, -0.00075], N[Not[LessEqual[eps, 8.2e-9]], $MachinePrecision]], N[(N[(N[Sin[N[(eps + x), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(N[Cos[eps], $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $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 -0.00075 \lor \neg \left(\varepsilon \leq 8.2 \cdot 10^{-9}\right):\\
\;\;\;\;\sin \left(\varepsilon + x\right) \cdot \frac{1}{\cos \varepsilon - x \cdot \sin \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\end{array}
\end{array}
if eps < -7.5000000000000002e-4 or 8.2000000000000006e-9 < eps Initial program 49.8%
tan-quot49.9%
div-inv49.7%
Applied egg-rr49.7%
Taylor expanded in x around 0 53.4%
mul-1-neg53.4%
unsub-neg53.4%
*-commutative53.4%
Simplified53.4%
if -7.5000000000000002e-4 < eps < 8.2000000000000006e-9Initial program 26.5%
Taylor expanded in eps around 0 98.8%
cancel-sign-sub-inv98.8%
metadata-eval98.8%
*-lft-identity98.8%
distribute-lft-in98.8%
*-rgt-identity98.8%
Simplified98.8%
Final simplification74.9%
(FPCore (x eps)
:precision binary64
(if (<= eps -4.9e-5)
(fma (+ (tan x) (tan eps)) 1.0 (- (tan x)))
(if (<= eps 8.2e-9)
(* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))
(- (* (sin (+ eps x)) (/ 1.0 (cos eps))) (tan x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -4.9e-5) {
tmp = fma((tan(x) + tan(eps)), 1.0, -tan(x));
} else if (eps <= 8.2e-9) {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
} else {
tmp = (sin((eps + x)) * (1.0 / cos(eps))) - tan(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -4.9e-5) tmp = fma(Float64(tan(x) + tan(eps)), 1.0, Float64(-tan(x))); elseif (eps <= 8.2e-9) tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); else tmp = Float64(Float64(sin(Float64(eps + x)) * Float64(1.0 / cos(eps))) - tan(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -4.9e-5], N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * 1.0 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 8.2e-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[(N[Sin[N[(eps + x), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -4.9 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\tan x + \tan \varepsilon, 1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 8.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\varepsilon + x\right) \cdot \frac{1}{\cos \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -4.9e-5Initial program 50.8%
tan-sum99.2%
div-inv99.1%
fma-neg99.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 53.3%
if -4.9e-5 < eps < 8.2000000000000006e-9Initial program 26.5%
tan-sum27.5%
div-inv27.5%
fma-neg27.6%
Applied egg-rr27.6%
Taylor expanded in eps around 0 98.8%
if 8.2000000000000006e-9 < eps Initial program 48.6%
tan-quot48.6%
div-inv48.4%
Applied egg-rr48.4%
Taylor expanded in x around 0 51.8%
Final simplification74.4%
(FPCore (x eps)
:precision binary64
(if (<= eps -2.6e-5)
(fma (+ (tan x) (tan eps)) 1.0 (- (tan x)))
(if (<= eps 8.2e-9)
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* (sin (+ eps x)) (/ 1.0 (cos eps))) (tan x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -2.6e-5) {
tmp = fma((tan(x) + tan(eps)), 1.0, -tan(x));
} else if (eps <= 8.2e-9) {
tmp = eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (sin((eps + x)) * (1.0 / cos(eps))) - tan(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -2.6e-5) tmp = fma(Float64(tan(x) + tan(eps)), 1.0, Float64(-tan(x))); elseif (eps <= 8.2e-9) tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(sin(Float64(eps + x)) * Float64(1.0 / cos(eps))) - tan(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -2.6e-5], N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * 1.0 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 8.2e-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[(N[Sin[N[(eps + x), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.6 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\tan x + \tan \varepsilon, 1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 8.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\varepsilon + x\right) \cdot \frac{1}{\cos \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -2.59999999999999984e-5Initial program 50.8%
tan-sum99.2%
div-inv99.1%
fma-neg99.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 53.3%
if -2.59999999999999984e-5 < eps < 8.2000000000000006e-9Initial program 26.5%
Taylor expanded in eps around 0 98.8%
cancel-sign-sub-inv98.8%
metadata-eval98.8%
*-lft-identity98.8%
distribute-lft-in98.8%
*-rgt-identity98.8%
Simplified98.8%
if 8.2000000000000006e-9 < eps Initial program 48.6%
tan-quot48.6%
div-inv48.4%
Applied egg-rr48.4%
Taylor expanded in x around 0 51.8%
Final simplification74.4%
(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 38.8%
Taylor expanded in x around 0 53.1%
Final simplification53.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -160.0) (not (<= eps 8.2e-9))) (- (tan (+ eps x)) x) (sin eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -160.0) || !(eps <= 8.2e-9)) {
tmp = tan((eps + x)) - x;
} else {
tmp = sin(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-160.0d0)) .or. (.not. (eps <= 8.2d-9))) then
tmp = tan((eps + x)) - x
else
tmp = sin(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -160.0) || !(eps <= 8.2e-9)) {
tmp = Math.tan((eps + x)) - x;
} else {
tmp = Math.sin(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -160.0) or not (eps <= 8.2e-9): tmp = math.tan((eps + x)) - x else: tmp = math.sin(eps) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -160.0) || !(eps <= 8.2e-9)) tmp = Float64(tan(Float64(eps + x)) - x); else tmp = sin(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -160.0) || ~((eps <= 8.2e-9))) tmp = tan((eps + x)) - x; else tmp = sin(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -160.0], N[Not[LessEqual[eps, 8.2e-9]], $MachinePrecision]], N[(N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision], N[Sin[eps], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -160 \lor \neg \left(\varepsilon \leq 8.2 \cdot 10^{-9}\right):\\
\;\;\;\;\tan \left(\varepsilon + x\right) - x\\
\mathbf{else}:\\
\;\;\;\;\sin \varepsilon\\
\end{array}
\end{array}
if eps < -160 or 8.2000000000000006e-9 < eps Initial program 50.1%
Taylor expanded in x around 0 46.9%
if -160 < eps < 8.2000000000000006e-9Initial program 26.3%
tan-quot26.2%
div-inv25.9%
Applied egg-rr25.9%
Taylor expanded in eps around 0 26.3%
associate-*r*26.3%
mul-1-neg26.3%
Simplified26.3%
Taylor expanded in x around 0 54.0%
Final simplification50.3%
(FPCore (x eps) :precision binary64 (sin eps))
double code(double x, double eps) {
return sin(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps)
end function
public static double code(double x, double eps) {
return Math.sin(eps);
}
def code(x, eps): return math.sin(eps)
function code(x, eps) return sin(eps) end
function tmp = code(x, eps) tmp = sin(eps); end
code[x_, eps_] := N[Sin[eps], $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon
\end{array}
Initial program 38.8%
tan-quot38.8%
div-inv38.6%
Applied egg-rr38.6%
Taylor expanded in eps around 0 19.9%
associate-*r*19.9%
mul-1-neg19.9%
Simplified19.9%
Taylor expanded in x around 0 32.1%
Final simplification32.1%
(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 38.8%
Taylor expanded in x around 0 36.3%
Taylor expanded in x around inf 3.7%
neg-mul-13.7%
Simplified3.7%
Final simplification3.7%
(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 2023187
(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)))