
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))))
(if (<= eps -3e-7)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (sin x) (/ (cos x) (tan eps)))))
(/ (sin x) (cos x)))
(if (<= eps 9.5e-8)
(fma eps t_0 (/ (pow eps 2.0) (/ (/ (cos x) (sin x)) t_0)))
(-
(/
(- (- (tan x)) (tan eps))
(+ (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))) -1.0))
(tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
double tmp;
if (eps <= -3e-7) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (sin(x) / (cos(x) / tan(eps))))) - (sin(x) / cos(x));
} else if (eps <= 9.5e-8) {
tmp = fma(eps, t_0, (pow(eps, 2.0) / ((cos(x) / sin(x)) / t_0)));
} else {
tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + -1.0)) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))) tmp = 0.0 if (eps <= -3e-7) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(sin(x) / Float64(cos(x) / tan(eps))))) - Float64(sin(x) / cos(x))); elseif (eps <= 9.5e-8) tmp = fma(eps, t_0, Float64((eps ^ 2.0) / Float64(Float64(cos(x) / sin(x)) / t_0))); else tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / Float64(Float64(Float64(sin(x) * sin(eps)) / Float64(cos(x) * cos(eps))) + -1.0)) - tan(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]}, If[LessEqual[eps, -3e-7], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9.5e-8], 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[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{if}\;\varepsilon \leq -3 \cdot 10^{-7}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}} - \frac{\sin x}{\cos x}\\
\mathbf{elif}\;\varepsilon \leq 9.5 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, t_0, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{\frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon} + -1} - \tan x\\
\end{array}
\end{array}
if eps < -2.9999999999999999e-7Initial program 51.8%
tan-sum99.3%
div-inv99.3%
tan-quot99.3%
div-inv99.2%
prod-diff99.3%
Applied egg-rr99.3%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
Simplified99.4%
*-commutative99.4%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/l*99.5%
Simplified99.5%
if -2.9999999999999999e-7 < eps < 9.50000000000000036e-8Initial program 32.1%
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 9.50000000000000036e-8 < eps Initial program 55.4%
expm1-log1p-u50.0%
Applied egg-rr50.0%
expm1-log1p-u55.4%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.7%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-prod31.1%
add-sqr-sqrt58.3%
tan-quot58.3%
tan-quot58.3%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 99.4%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin x) (cos x))))
(if (<= eps -4.1e-7)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (sin x) (/ (cos x) (tan eps)))))
t_0)
(if (<= eps 2.3e-7)
(+
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(* (pow eps 2.0) (+ t_0 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(-
(/
(- (- (tan x)) (tan eps))
(+ (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))) -1.0))
(tan x))))))
double code(double x, double eps) {
double t_0 = sin(x) / cos(x);
double tmp;
if (eps <= -4.1e-7) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (sin(x) / (cos(x) / tan(eps))))) - t_0;
} else if (eps <= 2.3e-7) {
tmp = (eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + (pow(eps, 2.0) * (t_0 + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + -1.0)) - 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 = sin(x) / cos(x)
if (eps <= (-4.1d-7)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (sin(x) / (cos(x) / tan(eps))))) - t_0
else if (eps <= 2.3d-7) then
tmp = (eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))) + ((eps ** 2.0d0) * (t_0 + ((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0))))
else
tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + (-1.0d0))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) / Math.cos(x);
double tmp;
if (eps <= -4.1e-7) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.sin(x) / (Math.cos(x) / Math.tan(eps))))) - t_0;
} else if (eps <= 2.3e-7) {
tmp = (eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)))) + (Math.pow(eps, 2.0) * (t_0 + (Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = ((-Math.tan(x) - Math.tan(eps)) / (((Math.sin(x) * Math.sin(eps)) / (Math.cos(x) * Math.cos(eps))) + -1.0)) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) / math.cos(x) tmp = 0 if eps <= -4.1e-7: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.sin(x) / (math.cos(x) / math.tan(eps))))) - t_0 elif eps <= 2.3e-7: tmp = (eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)))) + (math.pow(eps, 2.0) * (t_0 + (math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)))) else: tmp = ((-math.tan(x) - math.tan(eps)) / (((math.sin(x) * math.sin(eps)) / (math.cos(x) * math.cos(eps))) + -1.0)) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(sin(x) / cos(x)) tmp = 0.0 if (eps <= -4.1e-7) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(sin(x) / Float64(cos(x) / tan(eps))))) - t_0); elseif (eps <= 2.3e-7) tmp = Float64(Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64((eps ^ 2.0) * Float64(t_0 + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / Float64(Float64(Float64(sin(x) * sin(eps)) / Float64(cos(x) * cos(eps))) + -1.0)) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) / cos(x); tmp = 0.0; if (eps <= -4.1e-7) tmp = ((tan(x) + tan(eps)) / (1.0 - (sin(x) / (cos(x) / tan(eps))))) - t_0; elseif (eps <= 2.3e-7) tmp = (eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + ((eps ^ 2.0) * (t_0 + ((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))); else tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + -1.0)) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.1e-7], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[eps, 2.3e-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[(t$95$0 + 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[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
\mathbf{if}\;\varepsilon \leq -4.1 \cdot 10^{-7}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}} - t_0\\
\mathbf{elif}\;\varepsilon \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{2} \cdot \left(t_0 + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{\frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon} + -1} - \tan x\\
\end{array}
\end{array}
if eps < -4.0999999999999999e-7Initial program 51.8%
tan-sum99.3%
div-inv99.3%
tan-quot99.3%
div-inv99.2%
prod-diff99.3%
Applied egg-rr99.3%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
Simplified99.4%
*-commutative99.4%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/l*99.5%
Simplified99.5%
if -4.0999999999999999e-7 < eps < 2.29999999999999995e-7Initial program 32.1%
tan-sum32.8%
div-inv32.8%
tan-quot32.6%
div-inv32.8%
prod-diff32.2%
Applied egg-rr32.2%
+-commutative32.2%
fma-udef32.2%
associate-+r+32.8%
Simplified32.6%
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 2.29999999999999995e-7 < eps Initial program 55.4%
expm1-log1p-u50.0%
Applied egg-rr50.0%
expm1-log1p-u55.4%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.7%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-prod31.1%
add-sqr-sqrt58.3%
tan-quot58.3%
tan-quot58.3%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 99.4%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (<= eps -4.6e-9)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (sin x) (/ (cos x) (tan eps)))))
(/ (sin x) (cos x)))
(if (<= eps 4e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(-
(/
(- (- (tan x)) (tan eps))
(+ (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))) -1.0))
(tan x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -4.6e-9) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (sin(x) / (cos(x) / tan(eps))))) - (sin(x) / cos(x));
} else if (eps <= 4e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + -1.0)) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-4.6d-9)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (sin(x) / (cos(x) / tan(eps))))) - (sin(x) / cos(x))
else if (eps <= 4d-9) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + (-1.0d0))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -4.6e-9) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.sin(x) / (Math.cos(x) / Math.tan(eps))))) - (Math.sin(x) / Math.cos(x));
} else if (eps <= 4e-9) {
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(eps)) / (((Math.sin(x) * Math.sin(eps)) / (Math.cos(x) * Math.cos(eps))) + -1.0)) - Math.tan(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -4.6e-9: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.sin(x) / (math.cos(x) / math.tan(eps))))) - (math.sin(x) / math.cos(x)) elif eps <= 4e-9: 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(eps)) / (((math.sin(x) * math.sin(eps)) / (math.cos(x) * math.cos(eps))) + -1.0)) - math.tan(x) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -4.6e-9) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(sin(x) / Float64(cos(x) / tan(eps))))) - Float64(sin(x) / cos(x))); elseif (eps <= 4e-9) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / Float64(Float64(Float64(sin(x) * sin(eps)) / Float64(cos(x) * cos(eps))) + -1.0)) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -4.6e-9) tmp = ((tan(x) + tan(eps)) / (1.0 - (sin(x) / (cos(x) / tan(eps))))) - (sin(x) / cos(x)); elseif (eps <= 4e-9) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = ((-tan(x) - tan(eps)) / (((sin(x) * sin(eps)) / (cos(x) * cos(eps))) + -1.0)) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -4.6e-9], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4e-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[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}} - \frac{\sin x}{\cos x}\\
\mathbf{elif}\;\varepsilon \leq 4 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{\frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon} + -1} - \tan x\\
\end{array}
\end{array}
if eps < -4.5999999999999998e-9Initial program 51.8%
tan-sum99.3%
div-inv99.3%
tan-quot99.3%
div-inv99.2%
prod-diff99.3%
Applied egg-rr99.3%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
Simplified99.4%
*-commutative99.4%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/l*99.5%
Simplified99.5%
if -4.5999999999999998e-9 < eps < 4.00000000000000025e-9Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
if 4.00000000000000025e-9 < eps Initial program 55.4%
expm1-log1p-u50.0%
Applied egg-rr50.0%
expm1-log1p-u55.4%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.7%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-prod31.1%
add-sqr-sqrt58.3%
tan-quot58.3%
tan-quot58.3%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -5.5e-9)
(- (/ t_0 (- 1.0 (/ (sin x) (/ (cos x) (tan eps))))) (/ (sin x) (cos x)))
(if (<= eps 4.2e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* t_0 (/ -1.0 (fma (tan x) (tan eps) -1.0))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -5.5e-9) {
tmp = (t_0 / (1.0 - (sin(x) / (cos(x) / tan(eps))))) - (sin(x) / cos(x));
} else if (eps <= 4.2e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (-1.0 / fma(tan(x), tan(eps), -1.0))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -5.5e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(sin(x) / Float64(cos(x) / tan(eps))))) - Float64(sin(x) / cos(x))); elseif (eps <= 4.2e-9) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 * Float64(-1.0 / fma(tan(x), tan(eps), -1.0))) - 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, -5.5e-9], N[(N[(t$95$0 / N[(1.0 - N[(N[Sin[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.2e-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 * N[(-1.0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $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.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\sin x}{\frac{\cos x}{\tan \varepsilon}}} - \frac{\sin x}{\cos x}\\
\mathbf{elif}\;\varepsilon \leq 4.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)} - \tan x\\
\end{array}
\end{array}
if eps < -5.4999999999999996e-9Initial program 51.8%
tan-sum99.3%
div-inv99.3%
tan-quot99.3%
div-inv99.2%
prod-diff99.3%
Applied egg-rr99.3%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
Simplified99.4%
*-commutative99.4%
tan-quot99.5%
associate-*r/99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/l*99.5%
Simplified99.5%
if -5.4999999999999996e-9 < eps < 4.20000000000000039e-9Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
if 4.20000000000000039e-9 < eps Initial program 55.4%
expm1-log1p-u50.0%
Applied egg-rr50.0%
expm1-log1p-u55.4%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.7%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-prod31.1%
add-sqr-sqrt58.3%
tan-quot58.3%
tan-quot58.3%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
div-inv99.3%
Applied egg-rr99.3%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -4.8e-9)
(- (/ t_0 (- 1.0 (/ (tan eps) (/ 1.0 (tan x))))) (/ (sin x) (cos x)))
(if (<= eps 1.65e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* t_0 (/ -1.0 (fma (tan x) (tan eps) -1.0))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -4.8e-9) {
tmp = (t_0 / (1.0 - (tan(eps) / (1.0 / tan(x))))) - (sin(x) / cos(x));
} else if (eps <= 1.65e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (-1.0 / fma(tan(x), tan(eps), -1.0))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4.8e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(eps) / Float64(1.0 / tan(x))))) - Float64(sin(x) / cos(x))); elseif (eps <= 1.65e-9) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(t_0 * Float64(-1.0 / fma(tan(x), tan(eps), -1.0))) - 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, -4.8e-9], 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[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.65e-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 * N[(-1.0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan \varepsilon}{\frac{1}{\tan x}}} - \frac{\sin x}{\cos x}\\
\mathbf{elif}\;\varepsilon \leq 1.65 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)} - \tan x\\
\end{array}
\end{array}
if eps < -4.8e-9Initial program 51.8%
tan-sum99.3%
div-inv99.3%
tan-quot99.3%
div-inv99.2%
prod-diff99.3%
Applied egg-rr99.3%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
Simplified99.4%
*-commutative99.4%
tan-quot99.5%
clear-num99.5%
un-div-inv99.5%
clear-num99.5%
tan-quot99.4%
Applied egg-rr99.4%
if -4.8e-9 < eps < 1.65000000000000009e-9Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
if 1.65000000000000009e-9 < eps Initial program 55.4%
expm1-log1p-u50.0%
Applied egg-rr50.0%
expm1-log1p-u55.4%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.7%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-prod31.1%
add-sqr-sqrt58.3%
tan-quot58.3%
tan-quot58.3%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
div-inv99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (fma (tan x) (tan eps) -1.0)))
(if (<= eps -4e-9)
(- (/ (- (- (tan x)) (tan eps)) t_0) (tan x))
(if (<= eps 2.8e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* (+ (tan x) (tan eps)) (/ -1.0 t_0)) (tan x))))))
double code(double x, double eps) {
double t_0 = fma(tan(x), tan(eps), -1.0);
double tmp;
if (eps <= -4e-9) {
tmp = ((-tan(x) - tan(eps)) / t_0) - tan(x);
} else if (eps <= 2.8e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = ((tan(x) + tan(eps)) * (-1.0 / t_0)) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = fma(tan(x), tan(eps), -1.0) tmp = 0.0 if (eps <= -4e-9) tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / t_0) - tan(x)); elseif (eps <= 2.8e-9) tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); else tmp = Float64(Float64(Float64(tan(x) + tan(eps)) * Float64(-1.0 / t_0)) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[eps, -4e-9], N[(N[(N[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.8e-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[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)\\
\mathbf{if}\;\varepsilon \leq -4 \cdot 10^{-9}:\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{t_0} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{-1}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -4.00000000000000025e-9Initial program 51.8%
expm1-log1p-u45.6%
Applied egg-rr45.6%
expm1-log1p-u51.8%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt54.5%
sqrt-unprod76.5%
sqr-neg76.5%
sqrt-prod22.0%
add-sqr-sqrt55.7%
tan-quot55.7%
tan-quot55.7%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.4%
metadata-eval99.4%
Simplified99.4%
if -4.00000000000000025e-9 < eps < 2.79999999999999984e-9Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
if 2.79999999999999984e-9 < eps Initial program 55.4%
expm1-log1p-u50.0%
Applied egg-rr50.0%
expm1-log1p-u55.4%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt46.7%
sqrt-unprod77.8%
sqr-neg77.8%
sqrt-prod31.1%
add-sqr-sqrt58.3%
tan-quot58.3%
tan-quot58.3%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
div-inv99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.2e-9) (not (<= eps 4e-9))) (- (/ (- (- (tan x)) (tan eps)) (fma (tan x) (tan eps) -1.0)) (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.2e-9) || !(eps <= 4e-9)) {
tmp = ((-tan(x) - tan(eps)) / fma(tan(x), tan(eps), -1.0)) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.2e-9) || !(eps <= 4e-9)) tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / fma(tan(x), tan(eps), -1.0)) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.2e-9], N[Not[LessEqual[eps, 4e-9]], $MachinePrecision]], N[(N[(N[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $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.2 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 4 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -3.20000000000000012e-9 or 4.00000000000000025e-9 < eps Initial program 53.6%
expm1-log1p-u47.7%
Applied egg-rr47.7%
expm1-log1p-u53.6%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt50.7%
sqrt-unprod77.2%
sqr-neg77.2%
sqrt-prod26.4%
add-sqr-sqrt57.0%
tan-quot57.0%
tan-quot57.0%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
if -3.20000000000000012e-9 < eps < 4.00000000000000025e-9Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.9e-9) (not (<= eps 1.5e-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 <= -2.9e-9) || !(eps <= 1.5e-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 <= (-2.9d-9)) .or. (.not. (eps <= 1.5d-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 <= -2.9e-9) || !(eps <= 1.5e-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 <= -2.9e-9) or not (eps <= 1.5e-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 <= -2.9e-9) || !(eps <= 1.5e-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 <= -2.9e-9) || ~((eps <= 1.5e-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, -2.9e-9], N[Not[LessEqual[eps, 1.5e-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 -2.9 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 1.5 \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 < -2.89999999999999991e-9 or 1.49999999999999999e-9 < eps Initial program 53.6%
tan-sum99.3%
div-inv99.3%
*-un-lft-identity99.3%
prod-diff99.3%
*-commutative99.3%
*-un-lft-identity99.3%
*-commutative99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
Simplified99.3%
if -2.89999999999999991e-9 < eps < 1.49999999999999999e-9Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -7.5e-5) (not (<= eps 3.2e-5))) (- (/ (- (- (tan x)) (tan eps)) -1.0) (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 <= -7.5e-5) || !(eps <= 3.2e-5)) {
tmp = ((-tan(x) - tan(eps)) / -1.0) - 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 <= (-7.5d-5)) .or. (.not. (eps <= 3.2d-5))) then
tmp = ((-tan(x) - tan(eps)) / (-1.0d0)) - 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 <= -7.5e-5) || !(eps <= 3.2e-5)) {
tmp = ((-Math.tan(x) - Math.tan(eps)) / -1.0) - 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 <= -7.5e-5) or not (eps <= 3.2e-5): tmp = ((-math.tan(x) - math.tan(eps)) / -1.0) - 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 <= -7.5e-5) || !(eps <= 3.2e-5)) tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / -1.0) - 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 <= -7.5e-5) || ~((eps <= 3.2e-5))) tmp = ((-tan(x) - tan(eps)) / -1.0) - 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, -7.5e-5], N[Not[LessEqual[eps, 3.2e-5]], $MachinePrecision]], N[(N[(N[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / -1.0), $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 -7.5 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 3.2 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{-1} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -7.49999999999999934e-5 or 3.19999999999999986e-5 < eps Initial program 53.6%
expm1-log1p-u47.7%
Applied egg-rr47.7%
expm1-log1p-u53.6%
tan-sum99.3%
div-inv99.3%
frac-2neg99.3%
metadata-eval99.3%
associate-*r/99.3%
sub-neg99.3%
distribute-neg-in99.3%
metadata-eval99.3%
distribute-lft-neg-in99.3%
add-sqr-sqrt50.7%
sqrt-unprod77.2%
sqr-neg77.2%
sqrt-prod26.4%
add-sqr-sqrt57.0%
tan-quot57.0%
tan-quot57.0%
Applied egg-rr99.3%
*-commutative99.3%
neg-mul-199.3%
distribute-neg-frac99.3%
+-commutative99.3%
metadata-eval99.3%
sub-neg99.3%
fma-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around 0 57.5%
if -7.49999999999999934e-5 < eps < 3.19999999999999986e-5Initial program 32.1%
Taylor expanded in eps around 0 99.3%
cancel-sign-sub-inv99.3%
metadata-eval99.3%
*-lft-identity99.3%
Simplified99.3%
Final simplification76.3%
(FPCore (x eps) :precision binary64 (/ (sin eps) (cos eps)))
double code(double x, double eps) {
return sin(eps) / cos(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / cos(eps)
end function
public static double code(double x, double eps) {
return Math.sin(eps) / Math.cos(eps);
}
def code(x, eps): return math.sin(eps) / math.cos(eps)
function code(x, eps) return Float64(sin(eps) / cos(eps)) end
function tmp = code(x, eps) tmp = sin(eps) / cos(eps); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos \varepsilon}
\end{array}
Initial program 43.9%
Taylor expanded in x around 0 59.5%
Final simplification59.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.3e-6) (not (<= eps 2.6e-6))) (+ x (tan (+ eps x))) eps))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.3e-6) || !(eps <= 2.6e-6)) {
tmp = x + tan((eps + x));
} else {
tmp = eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.3d-6)) .or. (.not. (eps <= 2.6d-6))) then
tmp = x + tan((eps + x))
else
tmp = eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.3e-6) || !(eps <= 2.6e-6)) {
tmp = x + Math.tan((eps + x));
} else {
tmp = eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.3e-6) or not (eps <= 2.6e-6): tmp = x + math.tan((eps + x)) else: tmp = eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.3e-6) || !(eps <= 2.6e-6)) tmp = Float64(x + tan(Float64(eps + x))); else tmp = eps; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.3e-6) || ~((eps <= 2.6e-6))) tmp = x + tan((eps + x)); else tmp = eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.3e-6], N[Not[LessEqual[eps, 2.6e-6]], $MachinePrecision]], N[(x + N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], eps]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.3 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 2.6 \cdot 10^{-6}\right):\\
\;\;\;\;x + \tan \left(\varepsilon + x\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon\\
\end{array}
\end{array}
if eps < -1.30000000000000005e-6 or 2.60000000000000009e-6 < eps Initial program 53.6%
add-sqr-sqrt25.1%
sqrt-unprod53.3%
pow253.3%
Applied egg-rr53.3%
unpow253.3%
sqr-neg53.3%
sqrt-unprod28.3%
add-sqr-sqrt53.6%
tan-quot53.6%
add-sqr-sqrt25.3%
distribute-rgt-neg-in25.3%
tan-quot25.3%
tan-quot25.3%
Applied egg-rr25.3%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
Simplified50.9%
sub-neg50.9%
Applied egg-rr50.9%
remove-double-neg50.9%
+-commutative50.9%
Simplified50.9%
if -1.30000000000000005e-6 < eps < 2.60000000000000009e-6Initial program 32.1%
tan-sum32.8%
div-inv32.8%
tan-quot32.6%
div-inv32.8%
prod-diff32.2%
Applied egg-rr32.2%
+-commutative32.2%
fma-udef32.2%
associate-+r+32.8%
Simplified32.6%
add-cube-cbrt32.6%
pow332.6%
Applied egg-rr32.6%
Taylor expanded in eps around 0 62.2%
Final simplification56.0%
(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}
Initial program 43.9%
expm1-log1p-u40.3%
Applied egg-rr40.3%
expm1-log1p-u43.9%
tan-sum69.4%
div-inv69.4%
frac-2neg69.4%
metadata-eval69.4%
associate-*r/69.4%
sub-neg69.4%
distribute-neg-in69.4%
metadata-eval69.4%
distribute-lft-neg-in69.4%
add-sqr-sqrt38.6%
sqrt-unprod57.2%
sqr-neg57.2%
sqrt-prod18.6%
add-sqr-sqrt45.8%
tan-quot45.8%
tan-quot45.8%
Applied egg-rr69.4%
*-commutative69.4%
neg-mul-169.4%
distribute-neg-frac69.4%
+-commutative69.4%
metadata-eval69.4%
sub-neg69.4%
fma-neg69.5%
metadata-eval69.5%
Simplified69.5%
Taylor expanded in eps around 0 4.1%
distribute-lft1-in4.1%
metadata-eval4.1%
mul0-lft4.1%
metadata-eval4.1%
Simplified4.1%
Final simplification4.1%
(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 43.9%
tan-sum69.4%
div-inv69.4%
tan-quot69.3%
div-inv69.3%
prod-diff69.1%
Applied egg-rr69.1%
+-commutative69.1%
fma-udef69.1%
associate-+r+69.4%
Simplified69.3%
add-cube-cbrt69.2%
pow369.2%
Applied egg-rr69.2%
Taylor expanded in eps around 0 30.0%
Final simplification30.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 2023326
(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)))