
(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 (fma -1.0 (tan x) (tan x)))
(t_1 (/ (sin eps) (cos eps)))
(t_2 (- (tan x)))
(t_3 (+ (tan x) (tan eps))))
(if (<= eps -3.7e-9)
(- t_2 (/ t_3 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 2.55e-23)
(+
(+
(/ t_1 (- 1.0 (* t_1 (/ (sin x) (cos x)))))
(/ eps (/ (pow (cos x) 2.0) (pow (sin x) 2.0))))
t_0)
(+
t_0
(fma t_3 (/ 1.0 (- 1.0 (/ (* (tan x) (sin eps)) (cos eps)))) t_2))))))
double code(double x, double eps) {
double t_0 = fma(-1.0, tan(x), tan(x));
double t_1 = sin(eps) / cos(eps);
double t_2 = -tan(x);
double t_3 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.7e-9) {
tmp = t_2 - (t_3 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 2.55e-23) {
tmp = ((t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) + (eps / (pow(cos(x), 2.0) / pow(sin(x), 2.0)))) + t_0;
} else {
tmp = t_0 + fma(t_3, (1.0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))), t_2);
}
return tmp;
}
function code(x, eps) t_0 = fma(-1.0, tan(x), tan(x)) t_1 = Float64(sin(eps) / cos(eps)) t_2 = Float64(-tan(x)) t_3 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.7e-9) tmp = Float64(t_2 - Float64(t_3 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 2.55e-23) tmp = Float64(Float64(Float64(t_1 / Float64(1.0 - Float64(t_1 * Float64(sin(x) / cos(x))))) + Float64(eps / Float64((cos(x) ^ 2.0) / (sin(x) ^ 2.0)))) + t_0); else tmp = Float64(t_0 + fma(t_3, Float64(1.0 / Float64(1.0 - Float64(Float64(tan(x) * sin(eps)) / cos(eps)))), t_2)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[Tan[x], $MachinePrecision])}, Block[{t$95$3 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.7e-9], N[(t$95$2 - N[(t$95$3 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.55e-23], N[(N[(N[(t$95$1 / N[(1.0 - N[(t$95$1 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps / N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(t$95$0 + N[(t$95$3 * N[(1.0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \tan x, \tan x\right)\\
t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_2 := -\tan x\\
t_3 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.7 \cdot 10^{-9}:\\
\;\;\;\;t_2 - \frac{t_3}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{-23}:\\
\;\;\;\;\left(\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon}{\frac{{\cos x}^{2}}{{\sin x}^{2}}}\right) + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 + \mathsf{fma}\left(t_3, \frac{1}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}}, t_2\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -3.3e-9)
(- t_0 (/ t_1 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 2.55e-23)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(+
(fma -1.0 (tan x) (tan x))
(fma t_1 (/ 1.0 (- 1.0 (/ (* (tan x) (sin eps)) (cos eps)))) t_0))))))
double code(double x, double eps) {
double t_0 = -tan(x);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -3.3e-9) {
tmp = t_0 - (t_1 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 2.55e-23) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = fma(-1.0, tan(x), tan(x)) + fma(t_1, (1.0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.3e-9) tmp = Float64(t_0 - Float64(t_1 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 2.55e-23) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(fma(-1.0, tan(x), tan(x)) + fma(t_1, Float64(1.0 / Float64(1.0 - Float64(Float64(tan(x) * sin(eps)) / cos(eps)))), t_0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.3e-9], N[(t$95$0 - N[(t$95$1 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.55e-23], 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[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-9}:\\
\;\;\;\;t_0 - \frac{t_1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{-23}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \tan x, \tan x\right) + \mathsf{fma}\left(t_1, \frac{1}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}}, t_0\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -4.6e-9)
(- t_0 (/ t_1 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 2.55e-23)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(+
(fma -1.0 (tan x) (tan x))
(fma t_1 (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_0))))))
double code(double x, double eps) {
double t_0 = -tan(x);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -4.6e-9) {
tmp = t_0 - (t_1 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 2.55e-23) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = fma(-1.0, tan(x), tan(x)) + fma(t_1, (1.0 / (1.0 - (tan(x) * tan(eps)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4.6e-9) tmp = Float64(t_0 - Float64(t_1 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 2.55e-23) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(fma(-1.0, tan(x), tan(x)) + fma(t_1, Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.6e-9], N[(t$95$0 - N[(t$95$1 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.55e-23], 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[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-9}:\\
\;\;\;\;t_0 - \frac{t_1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{-23}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \tan x, \tan x\right) + \mathsf{fma}\left(t_1, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_0\right)\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -2.5e-9)
(- (- (tan x)) (/ t_0 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 2.55e-23)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* t_0 (/ 1.0 (- 1.0 (* (tan x) (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.5e-9) {
tmp = -tan(x) - (t_0 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 2.55e-23) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -2.5e-9) tmp = Float64(Float64(-tan(x)) - Float64(t_0 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 2.55e-23) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - 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, -2.5e-9], N[((-N[Tan[x], $MachinePrecision]) - N[(t$95$0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.55e-23], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * 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.5 \cdot 10^{-9}:\\
\;\;\;\;\left(-\tan x\right) - \frac{t_0}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{-23}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\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 -4.6e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 2.55e-23)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* t_0 (/ 1.0 t_1)) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -4.6e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 2.55e-23) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = 1.0d0 - (tan(x) * tan(eps))
if (eps <= (-4.6d-9)) then
tmp = (t_0 / t_1) - tan(x)
else if (eps <= 2.55d-23) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 * (1.0d0 / t_1)) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double t_1 = 1.0 - (Math.tan(x) * Math.tan(eps));
double tmp;
if (eps <= -4.6e-9) {
tmp = (t_0 / t_1) - Math.tan(x);
} else if (eps <= 2.55e-23) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 * (1.0 / t_1)) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = 1.0 - (math.tan(x) * math.tan(eps)) tmp = 0 if eps <= -4.6e-9: tmp = (t_0 / t_1) - math.tan(x) elif eps <= 2.55e-23: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 * (1.0 / t_1)) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -4.6e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 2.55e-23) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 * Float64(1.0 / t_1)) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = 1.0 - (tan(x) * tan(eps)); tmp = 0.0; if (eps <= -4.6e-9) tmp = (t_0 / t_1) - tan(x); elseif (eps <= 2.55e-23) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 * (1.0 / t_1)) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.6e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.55e-23], 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 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{-23}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.5e-9) (not (<= eps 2.55e-23))) (- (/ (+ (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 <= -2.5e-9) || !(eps <= 2.55e-23)) {
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 <= (-2.5d-9)) .or. (.not. (eps <= 2.55d-23))) 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 <= -2.5e-9) || !(eps <= 2.55e-23)) {
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 <= -2.5e-9) or not (eps <= 2.55e-23): 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 <= -2.5e-9) || !(eps <= 2.55e-23)) 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 <= -2.5e-9) || ~((eps <= 2.55e-23))) 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, -2.5e-9], N[Not[LessEqual[eps, 2.55e-23]], $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 -2.5 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2.55 \cdot 10^{-23}\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
(if (<= eps -0.0026)
(tan eps)
(if (<= eps 0.47)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (- (tan x)) (/ (+ (tan x) (tan eps)) -1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0026) {
tmp = tan(eps);
} else if (eps <= 0.47) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = -tan(x) - ((tan(x) + tan(eps)) / -1.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.0026d0)) then
tmp = tan(eps)
else if (eps <= 0.47d0) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = -tan(x) - ((tan(x) + tan(eps)) / (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.0026) {
tmp = Math.tan(eps);
} else if (eps <= 0.47) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = -Math.tan(x) - ((Math.tan(x) + Math.tan(eps)) / -1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.0026: tmp = math.tan(eps) elif eps <= 0.47: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = -math.tan(x) - ((math.tan(x) + math.tan(eps)) / -1.0) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.0026) tmp = tan(eps); elseif (eps <= 0.47) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(-tan(x)) - Float64(Float64(tan(x) + tan(eps)) / -1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.0026) tmp = tan(eps); elseif (eps <= 0.47) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = -tan(x) - ((tan(x) + tan(eps)) / -1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0026], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 0.47], 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[Tan[x], $MachinePrecision]) - N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0026:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 0.47:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\tan x\right) - \frac{\tan x + \tan \varepsilon}{-1}\\
\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 (/ 1.0 (+ (* eps -0.3333333333333333) (/ 1.0 eps))))
double code(double x, double eps) {
return 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0 / ((eps * (-0.3333333333333333d0)) + (1.0d0 / eps))
end function
public static double code(double x, double eps) {
return 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps));
}
def code(x, eps): return 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps))
function code(x, eps) return Float64(1.0 / Float64(Float64(eps * -0.3333333333333333) + Float64(1.0 / eps))) end
function tmp = code(x, eps) tmp = 1.0 / ((eps * -0.3333333333333333) + (1.0 / eps)); end
code[x_, eps_] := N[(1.0 / N[(N[(eps * -0.3333333333333333), $MachinePrecision] + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\varepsilon \cdot -0.3333333333333333 + \frac{1}{\varepsilon}}
\end{array}
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
(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}
(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 2023347
(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)))