
(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 10 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 (/ (sin eps) (cos eps)))
(t_1 (+ (tan x) (tan eps)))
(t_2 (* (tan x) (tan eps)))
(t_3 (- 1.0 t_2)))
(if (<= eps -2.3e-6)
(- (* t_1 (/ 1.0 t_3)) (tan x))
(if (<= eps 3.4e-6)
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(+
(/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0))
(/ (* (pow eps 2.0) (pow (sin x) 3.0)) (pow (cos x) 3.0))))
(/ (+ (* t_1 (cos x)) (* (sin x) (+ t_2 -1.0))) (* t_3 (cos x)))))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
double t_1 = tan(x) + tan(eps);
double t_2 = tan(x) * tan(eps);
double t_3 = 1.0 - t_2;
double tmp;
if (eps <= -2.3e-6) {
tmp = (t_1 * (1.0 / t_3)) - tan(x);
} else if (eps <= 3.4e-6) {
tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + (((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0)) + ((pow(eps, 2.0) * pow(sin(x), 3.0)) / pow(cos(x), 3.0)));
} else {
tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + -1.0))) / (t_3 * cos(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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(eps) / cos(eps)
t_1 = tan(x) + tan(eps)
t_2 = tan(x) * tan(eps)
t_3 = 1.0d0 - t_2
if (eps <= (-2.3d-6)) then
tmp = (t_1 * (1.0d0 / t_3)) - tan(x)
else if (eps <= 3.4d-6) then
tmp = (t_0 / (1.0d0 - (t_0 * (sin(x) / cos(x))))) + (((eps * (sin(x) ** 2.0d0)) / (cos(x) ** 2.0d0)) + (((eps ** 2.0d0) * (sin(x) ** 3.0d0)) / (cos(x) ** 3.0d0)))
else
tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + (-1.0d0)))) / (t_3 * cos(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) / Math.cos(eps);
double t_1 = Math.tan(x) + Math.tan(eps);
double t_2 = Math.tan(x) * Math.tan(eps);
double t_3 = 1.0 - t_2;
double tmp;
if (eps <= -2.3e-6) {
tmp = (t_1 * (1.0 / t_3)) - Math.tan(x);
} else if (eps <= 3.4e-6) {
tmp = (t_0 / (1.0 - (t_0 * (Math.sin(x) / Math.cos(x))))) + (((eps * Math.pow(Math.sin(x), 2.0)) / Math.pow(Math.cos(x), 2.0)) + ((Math.pow(eps, 2.0) * Math.pow(Math.sin(x), 3.0)) / Math.pow(Math.cos(x), 3.0)));
} else {
tmp = ((t_1 * Math.cos(x)) + (Math.sin(x) * (t_2 + -1.0))) / (t_3 * Math.cos(x));
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) / math.cos(eps) t_1 = math.tan(x) + math.tan(eps) t_2 = math.tan(x) * math.tan(eps) t_3 = 1.0 - t_2 tmp = 0 if eps <= -2.3e-6: tmp = (t_1 * (1.0 / t_3)) - math.tan(x) elif eps <= 3.4e-6: tmp = (t_0 / (1.0 - (t_0 * (math.sin(x) / math.cos(x))))) + (((eps * math.pow(math.sin(x), 2.0)) / math.pow(math.cos(x), 2.0)) + ((math.pow(eps, 2.0) * math.pow(math.sin(x), 3.0)) / math.pow(math.cos(x), 3.0))) else: tmp = ((t_1 * math.cos(x)) + (math.sin(x) * (t_2 + -1.0))) / (t_3 * math.cos(x)) return tmp
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(tan(x) * tan(eps)) t_3 = Float64(1.0 - t_2) tmp = 0.0 if (eps <= -2.3e-6) tmp = Float64(Float64(t_1 * Float64(1.0 / t_3)) - tan(x)); elseif (eps <= 3.4e-6) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)) + Float64(Float64((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0)))); else tmp = Float64(Float64(Float64(t_1 * cos(x)) + Float64(sin(x) * Float64(t_2 + -1.0))) / Float64(t_3 * cos(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) / cos(eps); t_1 = tan(x) + tan(eps); t_2 = tan(x) * tan(eps); t_3 = 1.0 - t_2; tmp = 0.0; if (eps <= -2.3e-6) tmp = (t_1 * (1.0 / t_3)) - tan(x); elseif (eps <= 3.4e-6) tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + (((eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)) + (((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0))); else tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + -1.0))) / (t_3 * cos(x)); end tmp_2 = 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[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$2), $MachinePrecision]}, If[LessEqual[eps, -2.3e-6], N[(N[(t$95$1 * N[(1.0 / t$95$3), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.4e-6], 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[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(t$95$2 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_1 := \tan x + \tan \varepsilon\\
t_2 := \tan x \cdot \tan \varepsilon\\
t_3 := 1 - t_2\\
\mathbf{if}\;\varepsilon \leq -2.3 \cdot 10^{-6}:\\
\;\;\;\;t_1 \cdot \frac{1}{t_3} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \left(\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}} + \frac{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 \cdot \cos x + \sin x \cdot \left(t_2 + -1\right)}{t_3 \cdot \cos x}\\
\end{array}
\end{array}
if eps < -2.3e-6Initial program 66.6%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -2.3e-6 < eps < 3.40000000000000006e-6Initial program 26.8%
tan-sum28.2%
div-inv28.2%
Applied egg-rr28.2%
Taylor expanded in x around inf 28.2%
associate--l+62.3%
associate-/r*62.3%
times-frac62.3%
Simplified62.3%
Taylor expanded in eps around 0 99.7%
if 3.40000000000000006e-6 < eps Initial program 53.1%
tan-sum99.2%
tan-quot99.0%
frac-sub99.2%
Applied egg-rr99.2%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(t_1 (+ (tan x) (tan eps)))
(t_2 (* (tan x) (tan eps)))
(t_3 (- 1.0 t_2)))
(if (<= eps -1.75e-7)
(- (* t_1 (/ 1.0 t_3)) (tan x))
(if (<= eps 3.2e-7)
(fma eps t_0 (/ (pow eps 2.0) (/ (/ (cos x) (sin x)) t_0)))
(/ (+ (* t_1 (cos x)) (* (sin x) (+ t_2 -1.0))) (* t_3 (cos x)))))))
double code(double x, double eps) {
double t_0 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
double t_1 = tan(x) + tan(eps);
double t_2 = tan(x) * tan(eps);
double t_3 = 1.0 - t_2;
double tmp;
if (eps <= -1.75e-7) {
tmp = (t_1 * (1.0 / t_3)) - tan(x);
} else if (eps <= 3.2e-7) {
tmp = fma(eps, t_0, (pow(eps, 2.0) / ((cos(x) / sin(x)) / t_0)));
} else {
tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + -1.0))) / (t_3 * cos(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(tan(x) * tan(eps)) t_3 = Float64(1.0 - t_2) tmp = 0.0 if (eps <= -1.75e-7) tmp = Float64(Float64(t_1 * Float64(1.0 / t_3)) - tan(x)); elseif (eps <= 3.2e-7) tmp = fma(eps, t_0, Float64((eps ^ 2.0) / Float64(Float64(cos(x) / sin(x)) / t_0))); else tmp = Float64(Float64(Float64(t_1 * cos(x)) + Float64(sin(x) * Float64(t_2 + -1.0))) / Float64(t_3 * cos(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$2), $MachinePrecision]}, If[LessEqual[eps, -1.75e-7], N[(N[(t$95$1 * N[(1.0 / t$95$3), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.2e-7], N[(eps * t$95$0 + N[(N[Power[eps, 2.0], $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(t$95$2 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
t_1 := \tan x + \tan \varepsilon\\
t_2 := \tan x \cdot \tan \varepsilon\\
t_3 := 1 - t_2\\
\mathbf{if}\;\varepsilon \leq -1.75 \cdot 10^{-7}:\\
\;\;\;\;t_1 \cdot \frac{1}{t_3} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, t_0, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 \cdot \cos x + \sin x \cdot \left(t_2 + -1\right)}{t_3 \cdot \cos x}\\
\end{array}
\end{array}
if eps < -1.74999999999999992e-7Initial program 66.6%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -1.74999999999999992e-7 < eps < 3.2000000000000001e-7Initial program 26.8%
Taylor expanded in eps around 0 99.6%
fma-def99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
associate-/l*99.6%
associate-/r*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 3.2000000000000001e-7 < eps Initial program 53.1%
tan-sum99.2%
tan-quot99.0%
frac-sub99.2%
Applied egg-rr99.2%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps)))
(t_1 (* (tan x) (tan eps)))
(t_2 (- 1.0 t_1)))
(if (<= eps -3.5e-7)
(- (* t_0 (/ 1.0 t_2)) (tan x))
(if (<= eps 4.65e-7)
(+
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
(pow eps 2.0)
(+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(/ (+ (* t_0 (cos x)) (* (sin x) (+ t_1 -1.0))) (* t_2 (cos x)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = tan(x) * tan(eps);
double t_2 = 1.0 - t_1;
double tmp;
if (eps <= -3.5e-7) {
tmp = (t_0 * (1.0 / t_2)) - tan(x);
} else if (eps <= 4.65e-7) {
tmp = (eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + (pow(eps, 2.0) * ((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = ((t_0 * cos(x)) + (sin(x) * (t_1 + -1.0))) / (t_2 * cos(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) :: t_2
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = tan(x) * tan(eps)
t_2 = 1.0d0 - t_1
if (eps <= (-3.5d-7)) then
tmp = (t_0 * (1.0d0 / t_2)) - tan(x)
else if (eps <= 4.65d-7) then
tmp = (eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))) + ((eps ** 2.0d0) * ((sin(x) / cos(x)) + ((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0))))
else
tmp = ((t_0 * cos(x)) + (sin(x) * (t_1 + (-1.0d0)))) / (t_2 * cos(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 = Math.tan(x) * Math.tan(eps);
double t_2 = 1.0 - t_1;
double tmp;
if (eps <= -3.5e-7) {
tmp = (t_0 * (1.0 / t_2)) - Math.tan(x);
} else if (eps <= 4.65e-7) {
tmp = (eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)))) + (Math.pow(eps, 2.0) * ((Math.sin(x) / Math.cos(x)) + (Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = ((t_0 * Math.cos(x)) + (Math.sin(x) * (t_1 + -1.0))) / (t_2 * Math.cos(x));
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = math.tan(x) * math.tan(eps) t_2 = 1.0 - t_1 tmp = 0 if eps <= -3.5e-7: tmp = (t_0 * (1.0 / t_2)) - math.tan(x) elif eps <= 4.65e-7: tmp = (eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)))) + (math.pow(eps, 2.0) * ((math.sin(x) / math.cos(x)) + (math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)))) else: tmp = ((t_0 * math.cos(x)) + (math.sin(x) * (t_1 + -1.0))) / (t_2 * math.cos(x)) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(tan(x) * tan(eps)) t_2 = Float64(1.0 - t_1) tmp = 0.0 if (eps <= -3.5e-7) tmp = Float64(Float64(t_0 * Float64(1.0 / t_2)) - tan(x)); elseif (eps <= 4.65e-7) tmp = Float64(Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64((eps ^ 2.0) * Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(Float64(t_0 * cos(x)) + Float64(sin(x) * Float64(t_1 + -1.0))) / Float64(t_2 * cos(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = tan(x) * tan(eps); t_2 = 1.0 - t_1; tmp = 0.0; if (eps <= -3.5e-7) tmp = (t_0 * (1.0 / t_2)) - tan(x); elseif (eps <= 4.65e-7) tmp = (eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + ((eps ^ 2.0) * ((sin(x) / cos(x)) + ((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))); else tmp = ((t_0 * cos(x)) + (sin(x) * (t_1 + -1.0))) / (t_2 * cos(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[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, If[LessEqual[eps, -3.5e-7], N[(N[(t$95$0 * N[(1.0 / t$95$2), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.65e-7], N[(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[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \tan x \cdot \tan \varepsilon\\
t_2 := 1 - t_1\\
\mathbf{if}\;\varepsilon \leq -3.5 \cdot 10^{-7}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_2} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 4.65 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 \cdot \cos x + \sin x \cdot \left(t_1 + -1\right)}{t_2 \cdot \cos x}\\
\end{array}
\end{array}
if eps < -3.49999999999999984e-7Initial program 66.6%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -3.49999999999999984e-7 < eps < 4.6499999999999999e-7Initial program 26.8%
tan-sum28.2%
div-inv28.2%
Applied egg-rr28.2%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 4.6499999999999999e-7 < eps Initial program 53.1%
tan-sum99.2%
tan-quot99.0%
frac-sub99.2%
Applied egg-rr99.2%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin eps) (cos eps)))
(t_1 (+ (tan x) (tan eps)))
(t_2 (* (tan x) (tan eps)))
(t_3 (- 1.0 t_2)))
(if (<= eps -6.4e-9)
(- (* t_1 (/ 1.0 t_3)) (tan x))
(if (<= eps 3.8e-8)
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
(/ (+ (* t_1 (cos x)) (* (sin x) (+ t_2 -1.0))) (* t_3 (cos x)))))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
double t_1 = tan(x) + tan(eps);
double t_2 = tan(x) * tan(eps);
double t_3 = 1.0 - t_2;
double tmp;
if (eps <= -6.4e-9) {
tmp = (t_1 * (1.0 / t_3)) - tan(x);
} else if (eps <= 3.8e-8) {
tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
} else {
tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + -1.0))) / (t_3 * cos(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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(eps) / cos(eps)
t_1 = tan(x) + tan(eps)
t_2 = tan(x) * tan(eps)
t_3 = 1.0d0 - t_2
if (eps <= (-6.4d-9)) then
tmp = (t_1 * (1.0d0 / t_3)) - tan(x)
else if (eps <= 3.8d-8) then
tmp = (t_0 / (1.0d0 - (t_0 * (sin(x) / cos(x))))) + ((eps * (sin(x) ** 2.0d0)) / (cos(x) ** 2.0d0))
else
tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + (-1.0d0)))) / (t_3 * cos(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) / Math.cos(eps);
double t_1 = Math.tan(x) + Math.tan(eps);
double t_2 = Math.tan(x) * Math.tan(eps);
double t_3 = 1.0 - t_2;
double tmp;
if (eps <= -6.4e-9) {
tmp = (t_1 * (1.0 / t_3)) - Math.tan(x);
} else if (eps <= 3.8e-8) {
tmp = (t_0 / (1.0 - (t_0 * (Math.sin(x) / Math.cos(x))))) + ((eps * Math.pow(Math.sin(x), 2.0)) / Math.pow(Math.cos(x), 2.0));
} else {
tmp = ((t_1 * Math.cos(x)) + (Math.sin(x) * (t_2 + -1.0))) / (t_3 * Math.cos(x));
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) / math.cos(eps) t_1 = math.tan(x) + math.tan(eps) t_2 = math.tan(x) * math.tan(eps) t_3 = 1.0 - t_2 tmp = 0 if eps <= -6.4e-9: tmp = (t_1 * (1.0 / t_3)) - math.tan(x) elif eps <= 3.8e-8: tmp = (t_0 / (1.0 - (t_0 * (math.sin(x) / math.cos(x))))) + ((eps * math.pow(math.sin(x), 2.0)) / math.pow(math.cos(x), 2.0)) else: tmp = ((t_1 * math.cos(x)) + (math.sin(x) * (t_2 + -1.0))) / (t_3 * math.cos(x)) return tmp
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(tan(x) * tan(eps)) t_3 = Float64(1.0 - t_2) tmp = 0.0 if (eps <= -6.4e-9) tmp = Float64(Float64(t_1 * Float64(1.0 / t_3)) - tan(x)); elseif (eps <= 3.8e-8) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0))); else tmp = Float64(Float64(Float64(t_1 * cos(x)) + Float64(sin(x) * Float64(t_2 + -1.0))) / Float64(t_3 * cos(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) / cos(eps); t_1 = tan(x) + tan(eps); t_2 = tan(x) * tan(eps); t_3 = 1.0 - t_2; tmp = 0.0; if (eps <= -6.4e-9) tmp = (t_1 * (1.0 / t_3)) - tan(x); elseif (eps <= 3.8e-8) tmp = (t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + ((eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)); else tmp = ((t_1 * cos(x)) + (sin(x) * (t_2 + -1.0))) / (t_3 * cos(x)); end tmp_2 = 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[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$2), $MachinePrecision]}, If[LessEqual[eps, -6.4e-9], N[(N[(t$95$1 * N[(1.0 / t$95$3), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.8e-8], 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[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(t$95$2 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
t_1 := \tan x + \tan \varepsilon\\
t_2 := \tan x \cdot \tan \varepsilon\\
t_3 := 1 - t_2\\
\mathbf{if}\;\varepsilon \leq -6.4 \cdot 10^{-9}:\\
\;\;\;\;t_1 \cdot \frac{1}{t_3} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.8 \cdot 10^{-8}:\\
\;\;\;\;\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 \cdot \cos x + \sin x \cdot \left(t_2 + -1\right)}{t_3 \cdot \cos x}\\
\end{array}
\end{array}
if eps < -6.40000000000000023e-9Initial program 65.6%
tan-sum98.9%
div-inv99.0%
Applied egg-rr99.0%
if -6.40000000000000023e-9 < eps < 3.80000000000000028e-8Initial program 26.9%
tan-sum27.9%
div-inv27.9%
Applied egg-rr27.9%
Taylor expanded in x around inf 27.9%
associate--l+62.3%
associate-/r*62.3%
times-frac62.3%
Simplified62.3%
Taylor expanded in eps around 0 99.4%
if 3.80000000000000028e-8 < eps Initial program 53.1%
tan-sum99.2%
tan-quot99.0%
frac-sub99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps)))
(t_1 (* (tan x) (tan eps)))
(t_2 (- 1.0 t_1)))
(if (<= eps -4.8e-9)
(- (* t_0 (/ 1.0 t_2)) (tan x))
(if (<= eps 7e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(/ (+ (* t_0 (cos x)) (* (sin x) (+ t_1 -1.0))) (* t_2 (cos x)))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = tan(x) * tan(eps);
double t_2 = 1.0 - t_1;
double tmp;
if (eps <= -4.8e-9) {
tmp = (t_0 * (1.0 / t_2)) - tan(x);
} else if (eps <= 7e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = ((t_0 * cos(x)) + (sin(x) * (t_1 + -1.0))) / (t_2 * cos(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) :: t_2
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = tan(x) * tan(eps)
t_2 = 1.0d0 - t_1
if (eps <= (-4.8d-9)) then
tmp = (t_0 * (1.0d0 / t_2)) - tan(x)
else if (eps <= 7d-9) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = ((t_0 * cos(x)) + (sin(x) * (t_1 + (-1.0d0)))) / (t_2 * cos(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 = Math.tan(x) * Math.tan(eps);
double t_2 = 1.0 - t_1;
double tmp;
if (eps <= -4.8e-9) {
tmp = (t_0 * (1.0 / t_2)) - Math.tan(x);
} else if (eps <= 7e-9) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = ((t_0 * Math.cos(x)) + (Math.sin(x) * (t_1 + -1.0))) / (t_2 * Math.cos(x));
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = math.tan(x) * math.tan(eps) t_2 = 1.0 - t_1 tmp = 0 if eps <= -4.8e-9: tmp = (t_0 * (1.0 / t_2)) - math.tan(x) elif eps <= 7e-9: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = ((t_0 * math.cos(x)) + (math.sin(x) * (t_1 + -1.0))) / (t_2 * math.cos(x)) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(tan(x) * tan(eps)) t_2 = Float64(1.0 - t_1) tmp = 0.0 if (eps <= -4.8e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / t_2)) - tan(x)); elseif (eps <= 7e-9) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(Float64(t_0 * cos(x)) + Float64(sin(x) * Float64(t_1 + -1.0))) / Float64(t_2 * cos(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = tan(x) * tan(eps); t_2 = 1.0 - t_1; tmp = 0.0; if (eps <= -4.8e-9) tmp = (t_0 * (1.0 / t_2)) - tan(x); elseif (eps <= 7e-9) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = ((t_0 * cos(x)) + (sin(x) * (t_1 + -1.0))) / (t_2 * cos(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[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, If[LessEqual[eps, -4.8e-9], N[(N[(t$95$0 * N[(1.0 / t$95$2), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7e-9], 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[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := \tan x \cdot \tan \varepsilon\\
t_2 := 1 - t_1\\
\mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_2} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 7 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 \cdot \cos x + \sin x \cdot \left(t_1 + -1\right)}{t_2 \cdot \cos x}\\
\end{array}
\end{array}
if eps < -4.8e-9Initial program 65.6%
tan-sum98.9%
div-inv99.0%
Applied egg-rr99.0%
if -4.8e-9 < eps < 6.9999999999999998e-9Initial program 26.9%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
if 6.9999999999999998e-9 < eps Initial program 53.1%
tan-sum99.2%
tan-quot99.0%
frac-sub99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -4.2e-9) (not (<= eps 6.8e-9))) (- (/ (+ (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 <= -4.2e-9) || !(eps <= 6.8e-9)) {
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 <= (-4.2d-9)) .or. (.not. (eps <= 6.8d-9))) 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 <= -4.2e-9) || !(eps <= 6.8e-9)) {
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 <= -4.2e-9) or not (eps <= 6.8e-9): 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 <= -4.2e-9) || !(eps <= 6.8e-9)) 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 <= -4.2e-9) || ~((eps <= 6.8e-9))) 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, -4.2e-9], N[Not[LessEqual[eps, 6.8e-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[(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 -4.2 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 6.8 \cdot 10^{-9}\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}
if eps < -4.20000000000000039e-9 or 6.7999999999999997e-9 < eps Initial program 59.1%
tan-sum99.0%
div-inv99.1%
*-un-lft-identity99.1%
prod-diff99.0%
*-commutative99.0%
*-un-lft-identity99.0%
*-commutative99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
Simplified99.0%
if -4.20000000000000039e-9 < eps < 6.7999999999999997e-9Initial program 26.9%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
Final simplification99.1%
(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 3.5e-9)
(* 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 <= 3.5e-9) {
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 <= 3.5d-9) 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 <= 3.5e-9) {
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 <= 3.5e-9: 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 <= 3.5e-9) 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 <= 3.5e-9) 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, 3.5e-9], 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 3.5 \cdot 10^{-9}:\\
\;\;\;\;\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}
if eps < -5.2000000000000002e-9Initial program 65.6%
tan-sum98.9%
div-inv99.0%
Applied egg-rr99.0%
if -5.2000000000000002e-9 < eps < 3.4999999999999999e-9Initial program 26.9%
Taylor expanded in eps around 0 99.2%
cancel-sign-sub-inv99.2%
metadata-eval99.2%
*-lft-identity99.2%
Simplified99.2%
if 3.4999999999999999e-9 < eps Initial program 53.1%
tan-sum99.2%
div-inv99.1%
*-un-lft-identity99.1%
prod-diff99.1%
*-commutative99.1%
*-un-lft-identity99.1%
*-commutative99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
Simplified99.2%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.8e-6) (not (<= eps 1.45e-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 <= -3.8e-6) || !(eps <= 1.45e-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 <= (-3.8d-6)) .or. (.not. (eps <= 1.45d-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 <= -3.8e-6) || !(eps <= 1.45e-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 <= -3.8e-6) or not (eps <= 1.45e-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 <= -3.8e-6) || !(eps <= 1.45e-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 <= -3.8e-6) || ~((eps <= 1.45e-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, -3.8e-6], N[Not[LessEqual[eps, 1.45e-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 -3.8 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 1.45 \cdot 10^{-6}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -3.8e-6 or 1.4500000000000001e-6 < eps Initial program 59.6%
Taylor expanded in x around 0 60.8%
tan-quot61.1%
expm1-log1p-u45.5%
expm1-udef44.9%
Applied egg-rr44.9%
expm1-def45.5%
expm1-log1p61.1%
Simplified61.1%
if -3.8e-6 < eps < 1.4500000000000001e-6Initial program 26.8%
Taylor expanded in eps around 0 98.9%
cancel-sign-sub-inv98.9%
metadata-eval98.9%
*-lft-identity98.9%
Simplified98.9%
Final simplification80.9%
(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 42.4%
Taylor expanded in x around 0 61.2%
tan-quot61.3%
expm1-log1p-u53.9%
expm1-udef24.8%
Applied egg-rr24.8%
expm1-def53.9%
expm1-log1p61.3%
Simplified61.3%
Final simplification61.3%
(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 42.4%
Taylor expanded in x around 0 61.2%
Taylor expanded in eps around 0 34.0%
Final simplification34.0%
(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 2024020
(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)))