
(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 11 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 (+ (tan x) (tan eps))))
(if (<= eps -5.5e-7)
(- (/ t_1 (- 1.0 (cbrt (pow t_0 3.0)))) (tan x))
(if (<= eps 9e-7)
(/
(* eps (+ (/ (sin x) (cos x)) (/ (cos x) (sin x))))
(/ (- 1.0 t_0) (tan x)))
(- (/ t_1 (- 1.0 (/ (tan eps) (/ 1.0 (tan x))))) (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 <= -5.5e-7) {
tmp = (t_1 / (1.0 - cbrt(pow(t_0, 3.0)))) - tan(x);
} else if (eps <= 9e-7) {
tmp = (eps * ((sin(x) / cos(x)) + (cos(x) / sin(x)))) / ((1.0 - t_0) / tan(x));
} else {
tmp = (t_1 / (1.0 - (tan(eps) / (1.0 / tan(x))))) - tan(x);
}
return tmp;
}
public static double code(double x, double eps) {
double t_0 = Math.tan(x) * Math.tan(eps);
double t_1 = Math.tan(x) + Math.tan(eps);
double tmp;
if (eps <= -5.5e-7) {
tmp = (t_1 / (1.0 - Math.cbrt(Math.pow(t_0, 3.0)))) - Math.tan(x);
} else if (eps <= 9e-7) {
tmp = (eps * ((Math.sin(x) / Math.cos(x)) + (Math.cos(x) / Math.sin(x)))) / ((1.0 - t_0) / Math.tan(x));
} else {
tmp = (t_1 / (1.0 - (Math.tan(eps) / (1.0 / Math.tan(x))))) - Math.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 <= -5.5e-7) tmp = Float64(Float64(t_1 / Float64(1.0 - cbrt((t_0 ^ 3.0)))) - tan(x)); elseif (eps <= 9e-7) tmp = Float64(Float64(eps * Float64(Float64(sin(x) / cos(x)) + Float64(cos(x) / sin(x)))) / Float64(Float64(1.0 - t_0) / tan(x))); else tmp = Float64(Float64(t_1 / Float64(1.0 - Float64(tan(eps) / Float64(1.0 / tan(x))))) - 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, -5.5e-7], N[(N[(t$95$1 / N[(1.0 - N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9e-7], N[(N[(eps * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -5.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_1}{1 - \sqrt[3]{{t_0}^{3}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 9 \cdot 10^{-7}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(\frac{\sin x}{\cos x} + \frac{\cos x}{\sin x}\right)}{\frac{1 - t_0}{\tan x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 - \frac{\tan \varepsilon}{\frac{1}{\tan x}}} - \tan x\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (* (/ (tan x) (- 1.0 (* (tan x) (tan eps)))) (fma (tan eps) (tan x) (/ (tan eps) (tan x)))))
double code(double x, double eps) {
return (tan(x) / (1.0 - (tan(x) * tan(eps)))) * fma(tan(eps), tan(x), (tan(eps) / tan(x)));
}
function code(x, eps) return Float64(Float64(tan(x) / Float64(1.0 - Float64(tan(x) * tan(eps)))) * fma(tan(eps), tan(x), Float64(tan(eps) / tan(x)))) end
code[x_, eps_] := N[(N[(N[Tan[x], $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision] + N[(N[Tan[eps], $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan x}{1 - \tan x \cdot \tan \varepsilon} \cdot \mathsf{fma}\left(\tan \varepsilon, \tan x, \frac{\tan \varepsilon}{\tan x}\right)
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -3.8e-9)
(- (/ t_0 (- 1.0 (cbrt (pow (* (tan x) (tan eps)) 3.0)))) (tan x))
(if (<= eps 2.7e-11)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 (- 1.0 (/ (tan eps) (/ 1.0 (tan x))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.8e-9) {
tmp = (t_0 / (1.0 - cbrt(pow((tan(x) * tan(eps)), 3.0)))) - tan(x);
} else if (eps <= 2.7e-11) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (tan(eps) / (1.0 / tan(x))))) - tan(x);
}
return tmp;
}
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double tmp;
if (eps <= -3.8e-9) {
tmp = (t_0 / (1.0 - Math.cbrt(Math.pow((Math.tan(x) * Math.tan(eps)), 3.0)))) - Math.tan(x);
} else if (eps <= 2.7e-11) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (Math.tan(eps) / (1.0 / Math.tan(x))))) - Math.tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.8e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - cbrt((Float64(tan(x) * tan(eps)) ^ 3.0)))) - tan(x)); elseif (eps <= 2.7e-11) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(eps) / Float64(1.0 / tan(x))))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.8e-9], N[(N[(t$95$0 / N[(1.0 - N[Power[N[Power[N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.7e-11], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(1.0 / N[Tan[x], $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 -3.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \sqrt[3]{{\left(\tan x \cdot \tan \varepsilon\right)}^{3}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.7 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon}{\frac{1}{\tan x}}} - \tan x\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -6.6e-9) (not (<= eps 2.7e-11))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ 1.0 (tan x))))) (tan x)) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -6.6e-9) || !(eps <= 2.7e-11)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (1.0 / tan(x))))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-6.6d-9)) .or. (.not. (eps <= 2.7d-11))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (1.0d0 / tan(x))))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -6.6e-9) || !(eps <= 2.7e-11)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (1.0 / Math.tan(x))))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -6.6e-9) or not (eps <= 2.7e-11): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (1.0 / math.tan(x))))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -6.6e-9) || !(eps <= 2.7e-11)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(1.0 / tan(x))))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -6.6e-9) || ~((eps <= 2.7e-11))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (1.0 / tan(x))))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -6.6e-9], N[Not[LessEqual[eps, 2.7e-11]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -6.6 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2.7 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{1}{\tan x}}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -5.2e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 2.7e-11)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 (- 1.0 (/ (tan eps) (/ 1.0 (tan x))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -5.2e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 2.7e-11) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (tan(eps) / (1.0 / tan(x))))) - 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 <= (-5.2d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 2.7d-11) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / (1.0d0 - (tan(eps) / (1.0d0 / tan(x))))) - 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 <= -5.2e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 2.7e-11) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (Math.tan(eps) / (1.0 / Math.tan(x))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -5.2e-9: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 2.7e-11: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 / (1.0 - (math.tan(eps) / (1.0 / math.tan(x))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -5.2e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 2.7e-11) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(eps) / Float64(1.0 / tan(x))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); tmp = 0.0; if (eps <= -5.2e-9) tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 2.7e-11) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / (1.0 - (tan(eps) / (1.0 / tan(x))))) - 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, -5.2e-9], 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], If[LessEqual[eps, 2.7e-11], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -5.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.7 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon}{\frac{1}{\tan x}}} - \tan x\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.5e-9) (not (<= eps 2.7e-11))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.5e-9) || !(eps <= 2.7e-11)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.5d-9)) .or. (.not. (eps <= 2.7d-11))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.5e-9) || !(eps <= 2.7e-11)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.5e-9) or not (eps <= 2.7e-11): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.5e-9) || !(eps <= 2.7e-11)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.5e-9) || ~((eps <= 2.7e-11))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.5e-9], N[Not[LessEqual[eps, 2.7e-11]], $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[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.5 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2.7 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -5.2e-9)
(- (* t_0 (/ 1.0 t_1)) (tan x))
(if (<= eps 2.7e-11)
(* eps (+ 1.0 (/ (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 <= -5.2e-9) {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
} else if (eps <= 2.7e-11) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / t_1) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = 1.0d0 - (tan(x) * tan(eps))
if (eps <= (-5.2d-9)) then
tmp = (t_0 * (1.0d0 / t_1)) - tan(x)
else if (eps <= 2.7d-11) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / t_1) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double t_1 = 1.0 - (Math.tan(x) * Math.tan(eps));
double tmp;
if (eps <= -5.2e-9) {
tmp = (t_0 * (1.0 / t_1)) - Math.tan(x);
} else if (eps <= 2.7e-11) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 / t_1) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = 1.0 - (math.tan(x) * math.tan(eps)) tmp = 0 if eps <= -5.2e-9: tmp = (t_0 * (1.0 / t_1)) - math.tan(x) elif eps <= 2.7e-11: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 / t_1) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -5.2e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); elseif (eps <= 2.7e-11) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 / t_1) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = 1.0 - (tan(x) * tan(eps)); tmp = 0.0; if (eps <= -5.2e-9) tmp = (t_0 * (1.0 / t_1)) - tan(x); elseif (eps <= 2.7e-11) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / t_1) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.2e-9], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.7e-11], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / 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 -5.2 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.7 \cdot 10^{-11}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (or (<= eps -6e-6) (not (<= eps 1.9e-5)))
(-
(/
(+ (tan x) (tan eps))
(- 1.0 (/ (tan eps) (+ (* x -0.3333333333333333) (/ 1.0 x)))))
(tan x))
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -6e-6) || !(eps <= 1.9e-5)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / ((x * -0.3333333333333333) + (1.0 / x))))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-6d-6)) .or. (.not. (eps <= 1.9d-5))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / ((x * (-0.3333333333333333d0)) + (1.0d0 / x))))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -6e-6) || !(eps <= 1.9e-5)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / ((x * -0.3333333333333333) + (1.0 / x))))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -6e-6) or not (eps <= 1.9e-5): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / ((x * -0.3333333333333333) + (1.0 / x))))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -6e-6) || !(eps <= 1.9e-5)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(Float64(x * -0.3333333333333333) + Float64(1.0 / x))))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -6e-6) || ~((eps <= 1.9e-5))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / ((x * -0.3333333333333333) + (1.0 / x))))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -6e-6], N[Not[LessEqual[eps, 1.9e-5]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[(x * -0.3333333333333333), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -6 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 1.9 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{x \cdot -0.3333333333333333 + \frac{1}{x}}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.2e-6) (not (<= eps 7e-6))) (tan eps) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.2e-6) || !(eps <= 7e-6)) {
tmp = tan(eps);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.2d-6)) .or. (.not. (eps <= 7d-6))) then
tmp = tan(eps)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.2e-6) || !(eps <= 7e-6)) {
tmp = Math.tan(eps);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.2e-6) or not (eps <= 7e-6): tmp = math.tan(eps) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.2e-6) || !(eps <= 7e-6)) tmp = tan(eps); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.2e-6) || ~((eps <= 7e-6))) tmp = tan(eps); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.2e-6], N[Not[LessEqual[eps, 7e-6]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.2 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 7 \cdot 10^{-6}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
(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}
(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}
(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 2024006
(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)))