
(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 9 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
(if (or (<= eps -1.9e-7) (not (<= eps 7.5e-12)))
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (* (tan eps) (sin x)) (cos x))))
(tan x))
(+
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
(* eps eps)
(+ (/ (pow (sin x) 3.0) (pow (cos x) 3.0)) (/ (sin x) (cos x)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.9e-7) || !(eps <= 7.5e-12)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x);
} else {
tmp = (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + ((eps * eps) * ((pow(sin(x), 3.0) / pow(cos(x), 3.0)) + (sin(x) / cos(x))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.9d-7)) .or. (.not. (eps <= 7.5d-12))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x)
else
tmp = (eps + (eps * ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))) + ((eps * eps) * (((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0)) + (sin(x) / cos(x))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.9e-7) || !(eps <= 7.5e-12)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - ((Math.tan(eps) * Math.sin(x)) / Math.cos(x)))) - Math.tan(x);
} else {
tmp = (eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)))) + ((eps * eps) * ((Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0)) + (Math.sin(x) / Math.cos(x))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.9e-7) or not (eps <= 7.5e-12): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - ((math.tan(eps) * math.sin(x)) / math.cos(x)))) - math.tan(x) else: tmp = (eps + (eps * (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)))) + ((eps * eps) * ((math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)) + (math.sin(x) / math.cos(x)))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.9e-7) || !(eps <= 7.5e-12)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - tan(x)); else tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64(Float64(eps * eps) * Float64(Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) + Float64(sin(x) / cos(x))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.9e-7) || ~((eps <= 7.5e-12))) tmp = ((tan(x) + tan(eps)) / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - tan(x); else tmp = (eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + ((eps * eps) * (((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) + (sin(x) / cos(x)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.9e-7], N[Not[LessEqual[eps, 7.5e-12]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], 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[(N[(eps * eps), $MachinePrecision] * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.9 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 7.5 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(\frac{{\sin x}^{3}}{{\cos x}^{3}} + \frac{\sin x}{\cos x}\right)\\
\end{array}
\end{array}
if eps < -1.90000000000000007e-7 or 7.5e-12 < eps Initial program 52.2%
tan-sum99.5%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
*-commutative99.5%
tan-quot99.5%
associate-*r/99.6%
Applied egg-rr99.6%
if -1.90000000000000007e-7 < eps < 7.5e-12Initial program 31.6%
tan-sum32.2%
div-inv32.2%
fma-neg32.2%
Applied egg-rr32.2%
fma-neg32.2%
associate-*r/32.2%
*-rgt-identity32.2%
Simplified32.2%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -3.8e-9) (not (<= eps 7.5e-12)))
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (* (tan eps) (sin x)) (cos x))))
(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.8e-9) || !(eps <= 7.5e-12)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - 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.8d-9)) .or. (.not. (eps <= 7.5d-12))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - ((tan(eps) * sin(x)) / cos(x)))) - 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.8e-9) || !(eps <= 7.5e-12)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - ((Math.tan(eps) * Math.sin(x)) / Math.cos(x)))) - 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.8e-9) or not (eps <= 7.5e-12): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - ((math.tan(eps) * math.sin(x)) / math.cos(x)))) - 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.8e-9) || !(eps <= 7.5e-12)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(Float64(tan(eps) * sin(x)) / cos(x)))) - 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.8e-9) || ~((eps <= 7.5e-12))) tmp = ((tan(x) + tan(eps)) / (1.0 - ((tan(eps) * sin(x)) / cos(x)))) - 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.8e-9], N[Not[LessEqual[eps, 7.5e-12]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[(N[Tan[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $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.8 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 7.5 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\end{array}
\end{array}
if eps < -3.80000000000000011e-9 or 7.5e-12 < eps Initial program 52.2%
tan-sum99.5%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
*-commutative99.5%
tan-quot99.5%
associate-*r/99.6%
Applied egg-rr99.6%
if -3.80000000000000011e-9 < eps < 7.5e-12Initial program 31.6%
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.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -2.8e-9)
(- (/ t_0 (- 1.0 (* (tan x) (tan eps)))) (tan x))
(if (<= eps 7.5e-12)
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.8e-9) {
tmp = (t_0 / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else if (eps <= 7.5e-12) {
tmp = eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(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(x) + tan(eps)
if (eps <= (-2.8d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else if (eps <= 7.5d-12) then
tmp = eps + (eps * ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - 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 tmp;
if (eps <= -2.8e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else if (eps <= 7.5e-12) {
tmp = eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -2.8e-9: tmp = (t_0 / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) elif eps <= 7.5e-12: tmp = eps + (eps * (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -2.8e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); elseif (eps <= 7.5e-12) tmp = Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); tmp = 0.0; if (eps <= -2.8e-9) tmp = (t_0 / (1.0 - (tan(x) * tan(eps)))) - tan(x); elseif (eps <= 7.5e-12) tmp = eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.8e-9], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7.5e-12], 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 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -2.79999999999999984e-9Initial program 58.0%
tan-sum99.5%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
if -2.79999999999999984e-9 < eps < 7.5e-12Initial program 31.6%
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 7.5e-12 < eps Initial program 47.9%
tan-sum99.6%
div-inv99.5%
fma-neg99.6%
Applied egg-rr99.6%
fma-neg99.5%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
tan-quot99.5%
clear-num99.5%
un-div-inv99.5%
clear-num99.5%
tan-quot99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.9e-9) (not (<= eps 7.5e-12))) (- (/ (+ (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.9e-9) || !(eps <= 7.5e-12)) {
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.9d-9)) .or. (.not. (eps <= 7.5d-12))) 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.9e-9) || !(eps <= 7.5e-12)) {
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.9e-9) or not (eps <= 7.5e-12): 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.9e-9) || !(eps <= 7.5e-12)) 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.9e-9) || ~((eps <= 7.5e-12))) 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.9e-9], N[Not[LessEqual[eps, 7.5e-12]], $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.9 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 7.5 \cdot 10^{-12}\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.89999999999999991e-9 or 7.5e-12 < eps Initial program 52.2%
tan-sum99.5%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
if -2.89999999999999991e-9 < eps < 7.5e-12Initial program 31.6%
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.6%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.6e-5)
(tan eps)
(if (<= eps 7.5e-12)
(* 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.6e-5) {
tmp = tan(eps);
} else if (eps <= 7.5e-12) {
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.6d-5)) then
tmp = tan(eps)
else if (eps <= 7.5d-12) 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.6e-5) {
tmp = Math.tan(eps);
} else if (eps <= 7.5e-12) {
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.6e-5: tmp = math.tan(eps) elif eps <= 7.5e-12: 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.6e-5) tmp = tan(eps); elseif (eps <= 7.5e-12) 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.6e-5) tmp = tan(eps); elseif (eps <= 7.5e-12) 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.6e-5], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 7.5e-12], 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.6 \cdot 10^{-5}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -1.59999999999999993e-5 or 7.5e-12 < eps Initial program 52.2%
Taylor expanded in x around 0 54.9%
tan-quot55.1%
expm1-log1p-u38.5%
expm1-udef37.7%
Applied egg-rr37.7%
expm1-def38.5%
expm1-log1p55.1%
Simplified55.1%
if -1.59999999999999993e-5 < eps < 7.5e-12Initial program 31.6%
tan-sum32.2%
div-inv32.2%
fma-neg32.2%
Applied egg-rr32.2%
fma-neg32.2%
associate-*r/32.2%
*-rgt-identity32.2%
Simplified32.2%
*-commutative32.2%
tan-quot32.2%
associate-*r/32.2%
Applied egg-rr32.2%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
Final simplification78.5%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.85e-6)
(tan eps)
(if (<= eps 7.5e-12)
(+ 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.85e-6) {
tmp = tan(eps);
} else if (eps <= 7.5e-12) {
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.85d-6)) then
tmp = tan(eps)
else if (eps <= 7.5d-12) 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.85e-6) {
tmp = Math.tan(eps);
} else if (eps <= 7.5e-12) {
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.85e-6: tmp = math.tan(eps) elif eps <= 7.5e-12: 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.85e-6) tmp = tan(eps); elseif (eps <= 7.5e-12) 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.85e-6) tmp = tan(eps); elseif (eps <= 7.5e-12) 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.85e-6], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 7.5e-12], 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.85 \cdot 10^{-6}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -1.8500000000000001e-6 or 7.5e-12 < eps Initial program 52.2%
Taylor expanded in x around 0 54.9%
tan-quot55.1%
expm1-log1p-u38.5%
expm1-udef37.7%
Applied egg-rr37.7%
expm1-def38.5%
expm1-log1p55.1%
Simplified55.1%
if -1.8500000000000001e-6 < eps < 7.5e-12Initial program 31.6%
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 simplification78.5%
(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 41.4%
Taylor expanded in x around 0 58.1%
add-sqr-sqrt31.5%
sqrt-unprod25.3%
pow225.3%
Applied egg-rr25.3%
unpow225.3%
rem-sqrt-square33.3%
Simplified33.3%
Taylor expanded in eps around 0 25.1%
rem-square-sqrt22.0%
fabs-sqr22.0%
rem-square-sqrt38.2%
Simplified38.2%
Final simplification38.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 41.4%
Taylor expanded in x around 0 58.1%
tan-quot58.2%
expm1-log1p-u50.4%
expm1-udef20.9%
Applied egg-rr20.9%
expm1-def50.4%
expm1-log1p58.2%
Simplified58.2%
Final simplification58.2%
(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 41.4%
Taylor expanded in x around 0 58.1%
Taylor expanded in eps around 0 34.3%
Final simplification34.3%
(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 2023271
(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)))