
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))))
(+
(+
(/
(sin eps)
(* (cos eps) (- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))))
(/ t_0 (/ (- 1.0 t_0) (tan x))))
(fma -1.0 (tan x) (tan x)))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
return ((sin(eps) / (cos(eps) * (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + (t_0 / ((1.0 - t_0) / tan(x)))) + fma(-1.0, tan(x), tan(x));
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) return Float64(Float64(Float64(sin(eps) / Float64(cos(eps) * Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x)))))) + Float64(t_0 / Float64(Float64(1.0 - t_0) / tan(x)))) + fma(-1.0, tan(x), tan(x))) end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
\left(\frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}\right)} + \frac{t_0}{\frac{1 - t_0}{\tan x}}\right) + \mathsf{fma}\left(-1, \tan x, \tan x\right)
\end{array}
\end{array}
Initial program 41.2%
tan-sum66.8%
div-inv66.8%
*-un-lft-identity66.8%
*-commutative66.8%
prod-diff66.8%
*-un-lft-identity66.8%
metadata-eval66.8%
*-un-lft-identity66.8%
Applied egg-rr66.8%
Taylor expanded in x around inf 66.7%
Simplified79.9%
tan-quot78.2%
clear-num76.9%
frac-sub76.2%
Applied egg-rr77.6%
rgt-mult-inverse79.9%
associate--r-99.5%
metadata-eval99.5%
+-lft-identity99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))))
(+
(fma -1.0 (tan x) (tan x))
(+
(/ t_0 (/ (- 1.0 t_0) (tan x)))
(/ (sin eps) (* (cos eps) (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
return fma(-1.0, tan(x), tan(x)) + ((t_0 / ((1.0 - t_0) / tan(x))) + (sin(eps) / (cos(eps) * (1.0 - ((sin(x) * tan(eps)) / cos(x))))));
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) return Float64(fma(-1.0, tan(x), tan(x)) + Float64(Float64(t_0 / Float64(Float64(1.0 - t_0) / tan(x))) + Float64(sin(eps) / Float64(cos(eps) * Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x))))))) end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 / N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
\mathsf{fma}\left(-1, \tan x, \tan x\right) + \left(\frac{t_0}{\frac{1 - t_0}{\tan x}} + \frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}\right)}\right)
\end{array}
\end{array}
Initial program 41.2%
tan-sum66.8%
div-inv66.8%
*-un-lft-identity66.8%
*-commutative66.8%
prod-diff66.8%
*-un-lft-identity66.8%
metadata-eval66.8%
*-un-lft-identity66.8%
Applied egg-rr66.8%
Taylor expanded in x around inf 66.7%
Simplified79.9%
tan-quot78.2%
clear-num76.9%
frac-sub76.2%
Applied egg-rr77.6%
rgt-mult-inverse79.9%
associate--r-99.5%
metadata-eval99.5%
+-lft-identity99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
clear-num99.5%
frac-times99.5%
*-un-lft-identity99.5%
clear-num99.5%
tan-quot99.5%
Applied egg-rr99.5%
associate-/r*99.5%
associate-/l*99.5%
/-rgt-identity99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))))
(+
(fma -1.0 (tan x) (tan x))
(+
(/ t_0 (/ (- 1.0 t_0) (tan x)))
(/ (sin eps) (* (cos eps) (+ 1.0 (+ 1.0 (- -1.0 t_0)))))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
return fma(-1.0, tan(x), tan(x)) + ((t_0 / ((1.0 - t_0) / tan(x))) + (sin(eps) / (cos(eps) * (1.0 + (1.0 + (-1.0 - t_0))))));
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) return Float64(fma(-1.0, tan(x), tan(x)) + Float64(Float64(t_0 / Float64(Float64(1.0 - t_0) / tan(x))) + Float64(sin(eps) / Float64(cos(eps) * Float64(1.0 + Float64(1.0 + Float64(-1.0 - t_0))))))) end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 / N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[(1.0 + N[(1.0 + N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
\mathsf{fma}\left(-1, \tan x, \tan x\right) + \left(\frac{t_0}{\frac{1 - t_0}{\tan x}} + \frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 + \left(1 + \left(-1 - t_0\right)\right)\right)}\right)
\end{array}
\end{array}
Initial program 41.2%
tan-sum66.8%
div-inv66.8%
*-un-lft-identity66.8%
*-commutative66.8%
prod-diff66.8%
*-un-lft-identity66.8%
metadata-eval66.8%
*-un-lft-identity66.8%
Applied egg-rr66.8%
Taylor expanded in x around inf 66.7%
Simplified79.9%
tan-quot78.2%
clear-num76.9%
frac-sub76.2%
Applied egg-rr77.6%
rgt-mult-inverse79.9%
associate--r-99.5%
metadata-eval99.5%
+-lft-identity99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
tan-quot99.5%
tan-quot99.5%
*-commutative99.5%
rem-exp-log47.4%
expm1-log1p-u47.4%
expm1-udef47.4%
log1p-udef47.4%
add-exp-log47.4%
rem-exp-log99.5%
*-commutative99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))) (t_1 (- 1.0 t_0)))
(+
(fma -1.0 (tan x) (tan x))
(+ (/ t_0 (/ t_1 (tan x))) (/ (sin eps) (* (cos eps) t_1))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = 1.0 - t_0;
return fma(-1.0, tan(x), tan(x)) + ((t_0 / (t_1 / tan(x))) + (sin(eps) / (cos(eps) * t_1)));
}
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = Float64(1.0 - t_0) return Float64(fma(-1.0, tan(x), tan(x)) + Float64(Float64(t_0 / Float64(t_1 / tan(x))) + Float64(sin(eps) / Float64(cos(eps) * t_1)))) 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 - t$95$0), $MachinePrecision]}, N[(N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 / N[(t$95$1 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := 1 - t_0\\
\mathsf{fma}\left(-1, \tan x, \tan x\right) + \left(\frac{t_0}{\frac{t_1}{\tan x}} + \frac{\sin \varepsilon}{\cos \varepsilon \cdot t_1}\right)
\end{array}
\end{array}
Initial program 41.2%
tan-sum66.8%
div-inv66.8%
*-un-lft-identity66.8%
*-commutative66.8%
prod-diff66.8%
*-un-lft-identity66.8%
metadata-eval66.8%
*-un-lft-identity66.8%
Applied egg-rr66.8%
Taylor expanded in x around inf 66.7%
Simplified79.9%
tan-quot78.2%
clear-num76.9%
frac-sub76.2%
Applied egg-rr77.6%
rgt-mult-inverse79.9%
associate--r-99.5%
metadata-eval99.5%
+-lft-identity99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
clear-num99.5%
clear-num99.5%
frac-times99.5%
metadata-eval99.5%
clear-num99.5%
tan-quot99.5%
clear-num99.5%
tan-quot99.5%
Applied egg-rr99.5%
associate-/r*99.5%
remove-double-div99.5%
associate-/r/99.5%
/-rgt-identity99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -6.6e-8)
(- (/ t_0 (- 1.0 (/ (* (sin eps) (tan x)) (cos eps)))) (tan x))
(if (<= eps 2.8e-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 (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -6.6e-8) {
tmp = (t_0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))) - tan(x);
} else if (eps <= 2.8e-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 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = tan(x) + tan(eps)
if (eps <= (-6.6d-8)) then
tmp = (t_0 / (1.0d0 - ((sin(eps) * tan(x)) / cos(eps)))) - tan(x)
else if (eps <= 2.8d-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 / (1.0d0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double tmp;
if (eps <= -6.6e-8) {
tmp = (t_0 / (1.0 - ((Math.sin(eps) * Math.tan(x)) / Math.cos(eps)))) - Math.tan(x);
} else if (eps <= 2.8e-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 / (1.0 - ((Math.sin(x) * Math.tan(eps)) / Math.cos(x)))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -6.6e-8: tmp = (t_0 / (1.0 - ((math.sin(eps) * math.tan(x)) / math.cos(eps)))) - math.tan(x) elif eps <= 2.8e-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 / (1.0 - ((math.sin(x) * math.tan(eps)) / math.cos(x)))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -6.6e-8) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(Float64(sin(eps) * tan(x)) / cos(eps)))) - tan(x)); elseif (eps <= 2.8e-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(t_0 / Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); tmp = 0.0; if (eps <= -6.6e-8) tmp = (t_0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))) - tan(x); elseif (eps <= 2.8e-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 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6.6e-8], N[(N[(t$95$0 / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.8e-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[(t$95$0 / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $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 -6.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.8 \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}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} - \tan x\\
\end{array}
\end{array}
if eps < -6.59999999999999954e-8Initial program 52.6%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.4%
*-commutative99.4%
*-un-lft-identity99.4%
*-commutative99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
+-commutative99.4%
fma-udef99.4%
associate-+r+99.4%
unsub-neg99.4%
Simplified99.4%
tan-quot99.4%
associate-*r/99.5%
Applied egg-rr99.5%
if -6.59999999999999954e-8 < eps < 2.80000000000000019e-7Initial program 29.7%
tan-sum30.1%
div-inv30.1%
*-un-lft-identity30.1%
prod-diff30.1%
*-commutative30.1%
*-un-lft-identity30.1%
*-commutative30.1%
*-un-lft-identity30.1%
Applied egg-rr30.1%
+-commutative30.1%
fma-udef30.1%
associate-+r+30.1%
unsub-neg30.1%
Simplified30.1%
add-exp-log20.9%
Applied egg-rr20.9%
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.80000000000000019e-7 < eps Initial program 49.8%
tan-sum99.1%
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%
+-commutative99.1%
fma-udef99.1%
associate-+r+99.1%
unsub-neg99.1%
Simplified99.1%
*-commutative99.1%
tan-quot99.1%
associate-*r/99.1%
Applied egg-rr99.1%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -4e-9) (not (<= eps 4.8e-9)))
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (* (sin x) (tan eps)) (cos x))))
(tan x))
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -4e-9) || !(eps <= 4.8e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-4d-9)) .or. (.not. (eps <= 4.8d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -4e-9) || !(eps <= 4.8e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - ((Math.sin(x) * Math.tan(eps)) / Math.cos(x)))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -4e-9) or not (eps <= 4.8e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - ((math.sin(x) * math.tan(eps)) / math.cos(x)))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -4e-9) || !(eps <= 4.8e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -4e-9) || ~((eps <= 4.8e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -4e-9], N[Not[LessEqual[eps, 4.8e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $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 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 4.8 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -4.00000000000000025e-9 or 4.8e-9 < eps Initial program 51.4%
tan-sum99.2%
div-inv99.3%
*-un-lft-identity99.3%
prod-diff99.2%
*-commutative99.2%
*-un-lft-identity99.2%
*-commutative99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.2%
*-commutative99.2%
tan-quot99.3%
associate-*r/99.3%
Applied egg-rr99.3%
if -4.00000000000000025e-9 < eps < 4.8e-9Initial program 29.7%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -4e-9)
(- (/ t_0 (- 1.0 (/ (* (sin eps) (tan x)) (cos eps)))) (tan x))
(if (<= eps 4.8e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -4e-9) {
tmp = (t_0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))) - tan(x);
} else if (eps <= 4.8e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = tan(x) + tan(eps)
if (eps <= (-4d-9)) then
tmp = (t_0 / (1.0d0 - ((sin(eps) * tan(x)) / cos(eps)))) - tan(x)
else if (eps <= 4.8d-9) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / (1.0d0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double tmp;
if (eps <= -4e-9) {
tmp = (t_0 / (1.0 - ((Math.sin(eps) * Math.tan(x)) / Math.cos(eps)))) - Math.tan(x);
} else if (eps <= 4.8e-9) {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - ((Math.sin(x) * Math.tan(eps)) / Math.cos(x)))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -4e-9: tmp = (t_0 / (1.0 - ((math.sin(eps) * math.tan(x)) / math.cos(eps)))) - math.tan(x) elif eps <= 4.8e-9: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) else: tmp = (t_0 / (1.0 - ((math.sin(x) * math.tan(eps)) / math.cos(x)))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(Float64(sin(eps) * tan(x)) / cos(eps)))) - tan(x)); elseif (eps <= 4.8e-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 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); tmp = 0.0; if (eps <= -4e-9) tmp = (t_0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))) - tan(x); elseif (eps <= 4.8e-9) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4e-9], N[(N[(t$95$0 / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.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[(t$95$0 / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $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 -4 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 4.8 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} - \tan x\\
\end{array}
\end{array}
if eps < -4.00000000000000025e-9Initial program 52.6%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.4%
*-commutative99.4%
*-un-lft-identity99.4%
*-commutative99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
+-commutative99.4%
fma-udef99.4%
associate-+r+99.4%
unsub-neg99.4%
Simplified99.4%
tan-quot99.4%
associate-*r/99.5%
Applied egg-rr99.5%
if -4.00000000000000025e-9 < eps < 4.8e-9Initial program 29.7%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
if 4.8e-9 < eps Initial program 49.8%
tan-sum99.1%
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%
+-commutative99.1%
fma-udef99.1%
associate-+r+99.1%
unsub-neg99.1%
Simplified99.1%
*-commutative99.1%
tan-quot99.1%
associate-*r/99.1%
Applied egg-rr99.1%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps)))
(t_1 (/ 1.0 (- 1.0 (* (tan x) (tan eps))))))
(if (<= eps -5.6e-9)
(fma t_0 t_1 (- (tan x)))
(if (<= eps 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 / (1.0 - (tan(x) * tan(eps)));
double tmp;
if (eps <= -5.6e-9) {
tmp = fma(t_0, t_1, -tan(x));
} else if (eps <= 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;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) tmp = 0.0 if (eps <= -5.6e-9) tmp = fma(t_0, t_1, Float64(-tan(x))); elseif (eps <= 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
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[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.6e-9], N[(t$95$0 * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 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 := \frac{1}{1 - \tan x \cdot \tan \varepsilon}\\
\mathbf{if}\;\varepsilon \leq -5.6 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot t_1 - \tan x\\
\end{array}
\end{array}
if eps < -5.59999999999999969e-9Initial program 52.6%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.4%
*-commutative99.4%
*-un-lft-identity99.4%
*-commutative99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
+-commutative99.4%
fma-udef99.4%
associate-+r+99.4%
unsub-neg99.4%
Simplified99.4%
add-exp-log36.5%
Applied egg-rr36.5%
add-exp-log99.4%
*-commutative99.4%
tan-quot99.4%
tan-quot99.4%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.4%
+-commutative99.4%
*-commutative99.4%
Simplified99.4%
if -5.59999999999999969e-9 < eps < 5.0000000000000001e-9Initial program 29.7%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
if 5.0000000000000001e-9 < eps Initial program 49.8%
tan-sum99.1%
div-inv99.1%
Applied egg-rr99.1%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.25e-9) (not (<= eps 5e-9))) (- (* (+ (tan x) (tan eps)) (/ 1.0 (- 1.0 (* (tan x) (tan eps))))) (tan x)) (* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.25e-9) || !(eps <= 5e-9)) {
tmp = ((tan(x) + tan(eps)) * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
} else {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.25d-9)) .or. (.not. (eps <= 5d-9))) then
tmp = ((tan(x) + tan(eps)) * (1.0d0 / (1.0d0 - (tan(x) * tan(eps))))) - tan(x)
else
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.25e-9) || !(eps <= 5e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) * (1.0 / (1.0 - (Math.tan(x) * Math.tan(eps))))) - Math.tan(x);
} else {
tmp = eps * (1.0 + (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.25e-9) or not (eps <= 5e-9): tmp = ((math.tan(x) + math.tan(eps)) * (1.0 / (1.0 - (math.tan(x) * math.tan(eps))))) - math.tan(x) else: tmp = eps * (1.0 + (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.25e-9) || !(eps <= 5e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - tan(x)); else tmp = Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.25e-9) || ~((eps <= 5e-9))) tmp = ((tan(x) + tan(eps)) * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x); else tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.25e-9], N[Not[LessEqual[eps, 5e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.25 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{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 < -3.2500000000000002e-9 or 5.0000000000000001e-9 < eps Initial program 51.4%
tan-sum99.2%
div-inv99.3%
Applied egg-rr99.3%
if -3.2500000000000002e-9 < eps < 5.0000000000000001e-9Initial program 29.7%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -4.4e-9) (not (<= eps 4.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.4e-9) || !(eps <= 4.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.4d-9)) .or. (.not. (eps <= 4.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.4e-9) || !(eps <= 4.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.4e-9) or not (eps <= 4.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.4e-9) || !(eps <= 4.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.4e-9) || ~((eps <= 4.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.4e-9], N[Not[LessEqual[eps, 4.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.4 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 4.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.3999999999999997e-9 or 4.8e-9 < eps Initial program 51.4%
tan-sum99.2%
div-inv99.3%
*-un-lft-identity99.3%
prod-diff99.2%
*-commutative99.2%
*-un-lft-identity99.2%
*-commutative99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.2%
if -4.3999999999999997e-9 < eps < 4.8e-9Initial program 29.7%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -6.6e-8) (not (<= eps 0.00012))) (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 <= -6.6e-8) || !(eps <= 0.00012)) {
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 <= (-6.6d-8)) .or. (.not. (eps <= 0.00012d0))) 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 <= -6.6e-8) || !(eps <= 0.00012)) {
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 <= -6.6e-8) or not (eps <= 0.00012): 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 <= -6.6e-8) || !(eps <= 0.00012)) 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 <= -6.6e-8) || ~((eps <= 0.00012))) 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, -6.6e-8], N[Not[LessEqual[eps, 0.00012]], $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 -6.6 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 0.00012\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -6.59999999999999954e-8 or 1.20000000000000003e-4 < eps Initial program 51.7%
Taylor expanded in x around 0 55.1%
tan-quot55.4%
Applied egg-rr55.4%
if -6.59999999999999954e-8 < eps < 1.20000000000000003e-4Initial program 29.4%
Taylor expanded in eps around 0 98.9%
cancel-sign-sub-inv98.9%
metadata-eval98.9%
*-lft-identity98.9%
Simplified98.9%
Final simplification76.0%
(FPCore (x eps) :precision binary64 (tan eps))
double code(double x, double eps) {
return tan(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan(eps)
end function
public static double code(double x, double eps) {
return Math.tan(eps);
}
def code(x, eps): return math.tan(eps)
function code(x, eps) return tan(eps) end
function tmp = code(x, eps) tmp = tan(eps); end
code[x_, eps_] := N[Tan[eps], $MachinePrecision]
\begin{array}{l}
\\
\tan \varepsilon
\end{array}
Initial program 41.2%
Taylor expanded in x around 0 56.3%
tan-quot56.5%
Applied egg-rr56.5%
Final simplification56.5%
(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}
Initial program 41.2%
Taylor expanded in x around 0 56.3%
add-cbrt-cube40.8%
pow1/321.6%
tan-quot21.6%
tan-quot21.6%
tan-quot21.6%
pow321.6%
Applied egg-rr21.6%
unpow1/340.8%
rem-cbrt-cube56.5%
tan-quot56.3%
clear-num56.2%
clear-num56.2%
tan-quot56.3%
Applied egg-rr56.3%
Taylor expanded in eps around 0 29.7%
Final simplification29.7%
(FPCore (x eps) :precision binary64 eps)
double code(double x, double eps) {
return eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps
end function
public static double code(double x, double eps) {
return eps;
}
def code(x, eps): return eps
function code(x, eps) return eps end
function tmp = code(x, eps) tmp = eps; end
code[x_, eps_] := eps
\begin{array}{l}
\\
\varepsilon
\end{array}
Initial program 41.2%
Taylor expanded in x around 0 56.3%
Taylor expanded in eps around 0 29.3%
Final simplification29.3%
(FPCore (x eps) :precision binary64 (/ (sin eps) (* (cos x) (cos (+ x eps)))))
double code(double x, double eps) {
return sin(eps) / (cos(x) * cos((x + eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / (cos(x) * cos((x + eps)))
end function
public static double code(double x, double eps) {
return Math.sin(eps) / (Math.cos(x) * Math.cos((x + eps)));
}
def code(x, eps): return math.sin(eps) / (math.cos(x) * math.cos((x + eps)))
function code(x, eps) return Float64(sin(eps) / Float64(cos(x) * cos(Float64(x + eps)))) end
function tmp = code(x, eps) tmp = sin(eps) / (cos(x) * cos((x + eps))); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}
\end{array}
herbie shell --seed 2023339
(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)))