
(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 (pow (sin x) 2.0))
(t_1 (- 1.0 (* (tan x) (tan eps))))
(t_2 (/ (tan eps) t_1))
(t_3 (pow (cos x) 2.0)))
(if (<= eps -0.033)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(tan x))
(if (<= eps 2.6e-9)
(+
t_2
(+
(*
(pow eps 3.0)
(-
(/ (pow (sin x) 4.0) (pow (cos x) 4.0))
(* -0.3333333333333333 (/ t_0 t_3))))
(+
(/ (* eps t_0) t_3)
(/ (* (pow eps 2.0) (pow (sin x) 3.0)) (pow (cos x) 3.0)))))
(+ t_2 (- (/ (tan x) t_1) (tan x)))))))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0);
double t_1 = 1.0 - (tan(x) * tan(eps));
double t_2 = tan(eps) / t_1;
double t_3 = pow(cos(x), 2.0);
double tmp;
if (eps <= -0.033) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x);
} else if (eps <= 2.6e-9) {
tmp = t_2 + ((pow(eps, 3.0) * ((pow(sin(x), 4.0) / pow(cos(x), 4.0)) - (-0.3333333333333333 * (t_0 / t_3)))) + (((eps * t_0) / t_3) + ((pow(eps, 2.0) * pow(sin(x), 3.0)) / pow(cos(x), 3.0))));
} else {
tmp = t_2 + ((tan(x) / 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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(x) ** 2.0d0
t_1 = 1.0d0 - (tan(x) * tan(eps))
t_2 = tan(eps) / t_1
t_3 = cos(x) ** 2.0d0
if (eps <= (-0.033d0)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x)
else if (eps <= 2.6d-9) then
tmp = t_2 + (((eps ** 3.0d0) * (((sin(x) ** 4.0d0) / (cos(x) ** 4.0d0)) - ((-0.3333333333333333d0) * (t_0 / t_3)))) + (((eps * t_0) / t_3) + (((eps ** 2.0d0) * (sin(x) ** 3.0d0)) / (cos(x) ** 3.0d0))))
else
tmp = t_2 + ((tan(x) / t_1) - tan(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(Math.sin(x), 2.0);
double t_1 = 1.0 - (Math.tan(x) * Math.tan(eps));
double t_2 = Math.tan(eps) / t_1;
double t_3 = Math.pow(Math.cos(x), 2.0);
double tmp;
if (eps <= -0.033) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - Math.tan(x);
} else if (eps <= 2.6e-9) {
tmp = t_2 + ((Math.pow(eps, 3.0) * ((Math.pow(Math.sin(x), 4.0) / Math.pow(Math.cos(x), 4.0)) - (-0.3333333333333333 * (t_0 / t_3)))) + (((eps * t_0) / t_3) + ((Math.pow(eps, 2.0) * Math.pow(Math.sin(x), 3.0)) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = t_2 + ((Math.tan(x) / t_1) - Math.tan(x));
}
return tmp;
}
def code(x, eps): t_0 = math.pow(math.sin(x), 2.0) t_1 = 1.0 - (math.tan(x) * math.tan(eps)) t_2 = math.tan(eps) / t_1 t_3 = math.pow(math.cos(x), 2.0) tmp = 0 if eps <= -0.033: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - math.tan(x) elif eps <= 2.6e-9: tmp = t_2 + ((math.pow(eps, 3.0) * ((math.pow(math.sin(x), 4.0) / math.pow(math.cos(x), 4.0)) - (-0.3333333333333333 * (t_0 / t_3)))) + (((eps * t_0) / t_3) + ((math.pow(eps, 2.0) * math.pow(math.sin(x), 3.0)) / math.pow(math.cos(x), 3.0)))) else: tmp = t_2 + ((math.tan(x) / t_1) - math.tan(x)) return tmp
function code(x, eps) t_0 = sin(x) ^ 2.0 t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_2 = Float64(tan(eps) / t_1) t_3 = cos(x) ^ 2.0 tmp = 0.0 if (eps <= -0.033) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - tan(x)); elseif (eps <= 2.6e-9) tmp = Float64(t_2 + Float64(Float64((eps ^ 3.0) * Float64(Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - Float64(-0.3333333333333333 * Float64(t_0 / t_3)))) + Float64(Float64(Float64(eps * t_0) / t_3) + Float64(Float64((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0))))); else tmp = Float64(t_2 + Float64(Float64(tan(x) / t_1) - tan(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) ^ 2.0; t_1 = 1.0 - (tan(x) * tan(eps)); t_2 = tan(eps) / t_1; t_3 = cos(x) ^ 2.0; tmp = 0.0; if (eps <= -0.033) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x); elseif (eps <= 2.6e-9) tmp = t_2 + (((eps ^ 3.0) * (((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - (-0.3333333333333333 * (t_0 / t_3)))) + (((eps * t_0) / t_3) + (((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0)))); else tmp = t_2 + ((tan(x) / t_1) - tan(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Tan[eps], $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[eps, -0.033], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.6e-9], N[(t$95$2 + N[(N[(N[Power[eps, 3.0], $MachinePrecision] * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] - N[(-0.3333333333333333 * N[(t$95$0 / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(eps * t$95$0), $MachinePrecision] / t$95$3), $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]), $MachinePrecision], N[(t$95$2 + N[(N[(N[Tan[x], $MachinePrecision] / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
t_2 := \frac{\tan \varepsilon}{t_1}\\
t_3 := {\cos x}^{2}\\
\mathbf{if}\;\varepsilon \leq -0.033:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;t_2 + \left({\varepsilon}^{3} \cdot \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - -0.3333333333333333 \cdot \frac{t_0}{t_3}\right) + \left(\frac{\varepsilon \cdot t_0}{t_3} + \frac{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 + \left(\frac{\tan x}{t_1} - \tan x\right)\\
\end{array}
\end{array}
if eps < -0.033000000000000002Initial program 54.1%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
*-commutative99.6%
tan-quot99.6%
clear-num99.6%
tan-quot99.7%
frac-times99.7%
*-un-lft-identity99.7%
clear-num99.7%
tan-quot99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
associate-/l*99.6%
*-commutative99.6%
associate-/l*99.7%
Simplified99.7%
if -0.033000000000000002 < eps < 2.6000000000000001e-9Initial program 29.9%
tan-sum30.5%
div-inv30.5%
*-un-lft-identity30.5%
prod-diff30.5%
*-commutative30.5%
*-un-lft-identity30.5%
*-commutative30.5%
*-un-lft-identity30.5%
Applied egg-rr30.5%
+-commutative30.5%
fma-udef30.5%
associate-+r+30.5%
unsub-neg30.5%
Simplified30.5%
Taylor expanded in x around inf 30.4%
associate--l+63.2%
associate-/r*63.2%
times-frac63.2%
Simplified63.2%
*-un-lft-identity63.2%
tan-quot63.2%
tan-quot63.2%
tan-quot63.2%
Applied egg-rr63.2%
Taylor expanded in eps around 0 99.7%
if 2.6000000000000001e-9 < eps Initial program 61.4%
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%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
associate-/r*98.9%
times-frac98.9%
Simplified99.2%
*-un-lft-identity99.2%
tan-quot99.5%
tan-quot99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps))))
(t_1 (/ (pow (sin x) 2.0) (cos x))))
(if (<= eps -0.00032)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(tan x))
(if (<= eps 0.0003)
(/
(+
(* eps (+ (cos x) t_1))
(*
(pow eps 3.0)
(- (* (cos x) 0.3333333333333333) (* -0.3333333333333333 t_1))))
(* (cos x) t_0))
(+ (/ (tan eps) t_0) (- (/ (tan x) t_0) (tan x)))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = pow(sin(x), 2.0) / cos(x);
double tmp;
if (eps <= -0.00032) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x);
} else if (eps <= 0.0003) {
tmp = ((eps * (cos(x) + t_1)) + (pow(eps, 3.0) * ((cos(x) * 0.3333333333333333) - (-0.3333333333333333 * t_1)))) / (cos(x) * t_0);
} else {
tmp = (tan(eps) / t_0) + ((tan(x) / t_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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (tan(x) * tan(eps))
t_1 = (sin(x) ** 2.0d0) / cos(x)
if (eps <= (-0.00032d0)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x)
else if (eps <= 0.0003d0) then
tmp = ((eps * (cos(x) + t_1)) + ((eps ** 3.0d0) * ((cos(x) * 0.3333333333333333d0) - ((-0.3333333333333333d0) * t_1)))) / (cos(x) * t_0)
else
tmp = (tan(eps) / t_0) + ((tan(x) / t_0) - tan(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(x) * Math.tan(eps));
double t_1 = Math.pow(Math.sin(x), 2.0) / Math.cos(x);
double tmp;
if (eps <= -0.00032) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - Math.tan(x);
} else if (eps <= 0.0003) {
tmp = ((eps * (Math.cos(x) + t_1)) + (Math.pow(eps, 3.0) * ((Math.cos(x) * 0.3333333333333333) - (-0.3333333333333333 * t_1)))) / (Math.cos(x) * t_0);
} else {
tmp = (Math.tan(eps) / t_0) + ((Math.tan(x) / t_0) - Math.tan(x));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(x) * math.tan(eps)) t_1 = math.pow(math.sin(x), 2.0) / math.cos(x) tmp = 0 if eps <= -0.00032: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - math.tan(x) elif eps <= 0.0003: tmp = ((eps * (math.cos(x) + t_1)) + (math.pow(eps, 3.0) * ((math.cos(x) * 0.3333333333333333) - (-0.3333333333333333 * t_1)))) / (math.cos(x) * t_0) else: tmp = (math.tan(eps) / t_0) + ((math.tan(x) / t_0) - math.tan(x)) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64((sin(x) ^ 2.0) / cos(x)) tmp = 0.0 if (eps <= -0.00032) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - tan(x)); elseif (eps <= 0.0003) tmp = Float64(Float64(Float64(eps * Float64(cos(x) + t_1)) + Float64((eps ^ 3.0) * Float64(Float64(cos(x) * 0.3333333333333333) - Float64(-0.3333333333333333 * t_1)))) / Float64(cos(x) * t_0)); else tmp = Float64(Float64(tan(eps) / t_0) + Float64(Float64(tan(x) / t_0) - tan(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(x) * tan(eps)); t_1 = (sin(x) ^ 2.0) / cos(x); tmp = 0.0; if (eps <= -0.00032) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x); elseif (eps <= 0.0003) tmp = ((eps * (cos(x) + t_1)) + ((eps ^ 3.0) * ((cos(x) * 0.3333333333333333) - (-0.3333333333333333 * t_1)))) / (cos(x) * t_0); else tmp = (tan(eps) / t_0) + ((tan(x) / t_0) - tan(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00032], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0003], N[(N[(N[(eps * N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] - N[(-0.3333333333333333 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \frac{{\sin x}^{2}}{\cos x}\\
\mathbf{if}\;\varepsilon \leq -0.00032:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 0.0003:\\
\;\;\;\;\frac{\varepsilon \cdot \left(\cos x + t_1\right) + {\varepsilon}^{3} \cdot \left(\cos x \cdot 0.3333333333333333 - -0.3333333333333333 \cdot t_1\right)}{\cos x \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_0} + \left(\frac{\tan x}{t_0} - \tan x\right)\\
\end{array}
\end{array}
if eps < -3.20000000000000026e-4Initial program 54.9%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
*-commutative99.6%
tan-quot99.6%
clear-num99.6%
tan-quot99.7%
frac-times99.7%
*-un-lft-identity99.7%
clear-num99.7%
tan-quot99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
associate-/l*99.6%
*-commutative99.6%
associate-/l*99.7%
Simplified99.7%
if -3.20000000000000026e-4 < eps < 2.99999999999999974e-4Initial program 30.8%
tan-sum31.9%
tan-quot31.6%
frac-sub31.6%
Applied egg-rr31.6%
Taylor expanded in eps around 0 99.5%
if 2.99999999999999974e-4 < eps Initial program 60.5%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.4%
*-commutative99.4%
*-un-lft-identity99.4%
*-commutative99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
+-commutative99.4%
fma-udef99.5%
associate-+r+99.5%
unsub-neg99.5%
Simplified99.5%
Taylor expanded in x around inf 99.1%
associate--l+99.1%
associate-/r*99.1%
times-frac99.1%
Simplified99.3%
*-un-lft-identity99.3%
tan-quot99.7%
tan-quot99.7%
tan-quot99.7%
Applied egg-rr99.7%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps)))) (t_1 (/ (tan eps) t_0)))
(if (<= eps -0.033)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(tan x))
(if (<= eps 2.6e-9)
(+
t_1
(+
(/ (* 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 (- (/ (tan x) t_0) (tan x)))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(eps) / t_0;
double tmp;
if (eps <= -0.033) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x);
} else if (eps <= 2.6e-9) {
tmp = t_1 + (((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 + ((tan(x) / t_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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (tan(x) * tan(eps))
t_1 = tan(eps) / t_0
if (eps <= (-0.033d0)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x)
else if (eps <= 2.6d-9) then
tmp = t_1 + (((eps * (sin(x) ** 2.0d0)) / (cos(x) ** 2.0d0)) + (((eps ** 2.0d0) * (sin(x) ** 3.0d0)) / (cos(x) ** 3.0d0)))
else
tmp = t_1 + ((tan(x) / t_0) - tan(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(x) * Math.tan(eps));
double t_1 = Math.tan(eps) / t_0;
double tmp;
if (eps <= -0.033) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - Math.tan(x);
} else if (eps <= 2.6e-9) {
tmp = t_1 + (((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.tan(x) / t_0) - Math.tan(x));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(x) * math.tan(eps)) t_1 = math.tan(eps) / t_0 tmp = 0 if eps <= -0.033: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - math.tan(x) elif eps <= 2.6e-9: tmp = t_1 + (((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.tan(x) / t_0) - math.tan(x)) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(eps) / t_0) tmp = 0.0 if (eps <= -0.033) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - tan(x)); elseif (eps <= 2.6e-9) tmp = Float64(t_1 + 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(t_1 + Float64(Float64(tan(x) / t_0) - tan(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(x) * tan(eps)); t_1 = tan(eps) / t_0; tmp = 0.0; if (eps <= -0.033) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x); elseif (eps <= 2.6e-9) tmp = t_1 + (((eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)) + (((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0))); else tmp = t_1 + ((tan(x) / t_0) - tan(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[eps, -0.033], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.6e-9], N[(t$95$1 + 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[(t$95$1 + N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \frac{\tan \varepsilon}{t_0}\\
\mathbf{if}\;\varepsilon \leq -0.033:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;t_1 + \left(\frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}} + \frac{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(\frac{\tan x}{t_0} - \tan x\right)\\
\end{array}
\end{array}
if eps < -0.033000000000000002Initial program 54.1%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
*-commutative99.6%
tan-quot99.6%
clear-num99.6%
tan-quot99.7%
frac-times99.7%
*-un-lft-identity99.7%
clear-num99.7%
tan-quot99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
associate-/l*99.6%
*-commutative99.6%
associate-/l*99.7%
Simplified99.7%
if -0.033000000000000002 < eps < 2.6000000000000001e-9Initial program 29.9%
tan-sum30.5%
div-inv30.5%
*-un-lft-identity30.5%
prod-diff30.5%
*-commutative30.5%
*-un-lft-identity30.5%
*-commutative30.5%
*-un-lft-identity30.5%
Applied egg-rr30.5%
+-commutative30.5%
fma-udef30.5%
associate-+r+30.5%
unsub-neg30.5%
Simplified30.5%
Taylor expanded in x around inf 30.4%
associate--l+63.2%
associate-/r*63.2%
times-frac63.2%
Simplified63.2%
*-un-lft-identity63.2%
tan-quot63.2%
tan-quot63.2%
tan-quot63.2%
Applied egg-rr63.2%
Taylor expanded in eps around 0 99.5%
if 2.6000000000000001e-9 < eps Initial program 61.4%
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%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
associate-/r*98.9%
times-frac98.9%
Simplified99.2%
*-un-lft-identity99.2%
tan-quot99.5%
tan-quot99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps))))
(t_1 (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0)))
(if (<= eps -2.1e-6)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(tan x))
(if (<= eps 2.6e-9)
(+ (* eps t_1) (/ (* (pow eps 2.0) (* (sin x) t_1)) (cos x)))
(+ (/ (tan eps) t_0) (- (/ (tan x) t_0) (tan x)))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = (pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0;
double tmp;
if (eps <= -2.1e-6) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x);
} else if (eps <= 2.6e-9) {
tmp = (eps * t_1) + ((pow(eps, 2.0) * (sin(x) * t_1)) / cos(x));
} else {
tmp = (tan(eps) / t_0) + ((tan(x) / t_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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (tan(x) * tan(eps))
t_1 = ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0
if (eps <= (-2.1d-6)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x)
else if (eps <= 2.6d-9) then
tmp = (eps * t_1) + (((eps ** 2.0d0) * (sin(x) * t_1)) / cos(x))
else
tmp = (tan(eps) / t_0) + ((tan(x) / t_0) - tan(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(x) * Math.tan(eps));
double t_1 = (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0;
double tmp;
if (eps <= -2.1e-6) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - Math.tan(x);
} else if (eps <= 2.6e-9) {
tmp = (eps * t_1) + ((Math.pow(eps, 2.0) * (Math.sin(x) * t_1)) / Math.cos(x));
} else {
tmp = (Math.tan(eps) / t_0) + ((Math.tan(x) / t_0) - Math.tan(x));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(x) * math.tan(eps)) t_1 = (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0 tmp = 0 if eps <= -2.1e-6: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - math.tan(x) elif eps <= 2.6e-9: tmp = (eps * t_1) + ((math.pow(eps, 2.0) * (math.sin(x) * t_1)) / math.cos(x)) else: tmp = (math.tan(eps) / t_0) + ((math.tan(x) / t_0) - math.tan(x)) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0) tmp = 0.0 if (eps <= -2.1e-6) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - tan(x)); elseif (eps <= 2.6e-9) tmp = Float64(Float64(eps * t_1) + Float64(Float64((eps ^ 2.0) * Float64(sin(x) * t_1)) / cos(x))); else tmp = Float64(Float64(tan(eps) / t_0) + Float64(Float64(tan(x) / t_0) - tan(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(x) * tan(eps)); t_1 = ((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0; tmp = 0.0; if (eps <= -2.1e-6) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x); elseif (eps <= 2.6e-9) tmp = (eps * t_1) + (((eps ^ 2.0) * (sin(x) * t_1)) / cos(x)); else tmp = (tan(eps) / t_0) + ((tan(x) / t_0) - tan(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[eps, -2.1e-6], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.6e-9], N[(N[(eps * t$95$1), $MachinePrecision] + N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\\
\mathbf{if}\;\varepsilon \leq -2.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot t_1 + \frac{{\varepsilon}^{2} \cdot \left(\sin x \cdot t_1\right)}{\cos x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_0} + \left(\frac{\tan x}{t_0} - \tan x\right)\\
\end{array}
\end{array}
if eps < -2.0999999999999998e-6Initial program 54.9%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
+-commutative99.6%
fma-udef99.6%
associate-+r+99.6%
unsub-neg99.6%
Simplified99.6%
*-commutative99.6%
tan-quot99.6%
clear-num99.6%
tan-quot99.7%
frac-times99.7%
*-un-lft-identity99.7%
clear-num99.7%
tan-quot99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
associate-/l*99.6%
*-commutative99.6%
associate-/l*99.7%
Simplified99.7%
if -2.0999999999999998e-6 < eps < 2.6000000000000001e-9Initial program 29.4%
Taylor expanded in eps around 0 99.4%
if 2.6000000000000001e-9 < eps Initial program 61.4%
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%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
associate-/r*98.9%
times-frac98.9%
Simplified99.2%
*-un-lft-identity99.2%
tan-quot99.5%
tan-quot99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -4.1e-9)
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(tan x))
(if (<= eps 2.4e-9)
(/
eps
(/ (cos x) (+ (cos x) (/ (- 0.5 (* 0.5 (cos (* x 2.0)))) (cos x)))))
(+ (/ (tan eps) t_0) (- (/ (tan x) t_0) (tan x)))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -4.1e-9) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x);
} else if (eps <= 2.4e-9) {
tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x))));
} else {
tmp = (tan(eps) / t_0) + ((tan(x) / t_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 = 1.0d0 - (tan(x) * tan(eps))
if (eps <= (-4.1d-9)) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x)
else if (eps <= 2.4d-9) then
tmp = eps / (cos(x) / (cos(x) + ((0.5d0 - (0.5d0 * cos((x * 2.0d0)))) / cos(x))))
else
tmp = (tan(eps) / t_0) + ((tan(x) / t_0) - tan(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(x) * Math.tan(eps));
double tmp;
if (eps <= -4.1e-9) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - Math.tan(x);
} else if (eps <= 2.4e-9) {
tmp = eps / (Math.cos(x) / (Math.cos(x) + ((0.5 - (0.5 * Math.cos((x * 2.0)))) / Math.cos(x))));
} else {
tmp = (Math.tan(eps) / t_0) + ((Math.tan(x) / t_0) - Math.tan(x));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(x) * math.tan(eps)) tmp = 0 if eps <= -4.1e-9: tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - math.tan(x) elif eps <= 2.4e-9: tmp = eps / (math.cos(x) / (math.cos(x) + ((0.5 - (0.5 * math.cos((x * 2.0)))) / math.cos(x)))) else: tmp = (math.tan(eps) / t_0) + ((math.tan(x) / t_0) - math.tan(x)) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -4.1e-9) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - tan(x)); elseif (eps <= 2.4e-9) tmp = Float64(eps / Float64(cos(x) / Float64(cos(x) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(x * 2.0)))) / cos(x))))); else tmp = Float64(Float64(tan(eps) / t_0) + Float64(Float64(tan(x) / t_0) - tan(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(x) * tan(eps)); tmp = 0.0; if (eps <= -4.1e-9) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x); elseif (eps <= 2.4e-9) tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x)))); else tmp = (tan(eps) / t_0) + ((tan(x) / t_0) - tan(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.1e-9], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.4e-9], N[(eps / N[(N[Cos[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{\varepsilon}{\frac{\cos x}{\cos x + \frac{0.5 - 0.5 \cdot \cos \left(x \cdot 2\right)}{\cos x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_0} + \left(\frac{\tan x}{t_0} - \tan x\right)\\
\end{array}
\end{array}
if eps < -4.1000000000000003e-9Initial program 54.0%
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.2%
clear-num99.1%
tan-quot99.3%
frac-times99.3%
*-un-lft-identity99.3%
clear-num99.3%
tan-quot99.2%
Applied egg-rr99.2%
*-commutative99.2%
associate-*r/99.2%
*-rgt-identity99.2%
associate-/l*99.2%
*-commutative99.2%
associate-/l*99.2%
Simplified99.2%
if -4.1000000000000003e-9 < eps < 2.4e-9Initial program 29.6%
tan-sum29.6%
tan-quot29.3%
frac-sub29.3%
Applied egg-rr29.3%
Taylor expanded in eps around 0 99.5%
unpow299.5%
sin-mult99.6%
Applied egg-rr99.6%
div-sub99.6%
+-inverses99.6%
cos-099.6%
metadata-eval99.6%
count-299.6%
*-commutative99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate-/l*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
if 2.4e-9 < eps Initial program 61.4%
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%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
associate-/r*98.9%
times-frac98.9%
Simplified99.2%
*-un-lft-identity99.2%
tan-quot99.5%
tan-quot99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -2.9e-9) (not (<= eps 2.6e-9)))
(-
(/ (+ (tan x) (tan eps)) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(tan x))
(/
eps
(/ (cos x) (+ (cos x) (/ (- 0.5 (* 0.5 (cos (* x 2.0)))) (cos x)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.9e-9) || !(eps <= 2.6e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x);
} else {
tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x))));
}
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 <= 2.6d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x)
else
tmp = eps / (cos(x) / (cos(x) + ((0.5d0 - (0.5d0 * cos((x * 2.0d0)))) / cos(x))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2.9e-9) || !(eps <= 2.6e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - Math.tan(x);
} else {
tmp = eps / (Math.cos(x) / (Math.cos(x) + ((0.5 - (0.5 * Math.cos((x * 2.0)))) / Math.cos(x))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.9e-9) or not (eps <= 2.6e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - math.tan(x) else: tmp = eps / (math.cos(x) / (math.cos(x) + ((0.5 - (0.5 * math.cos((x * 2.0)))) / math.cos(x)))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.9e-9) || !(eps <= 2.6e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - tan(x)); else tmp = Float64(eps / Float64(cos(x) / Float64(cos(x) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(x * 2.0)))) / cos(x))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.9e-9) || ~((eps <= 2.6e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - tan(x); else tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.9e-9], N[Not[LessEqual[eps, 2.6e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps / N[(N[Cos[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.9 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2.6 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon}{\frac{\cos x}{\cos x + \frac{0.5 - 0.5 \cdot \cos \left(x \cdot 2\right)}{\cos x}}}\\
\end{array}
\end{array}
if eps < -2.89999999999999991e-9 or 2.6000000000000001e-9 < eps Initial program 57.9%
tan-sum99.2%
div-inv99.2%
*-un-lft-identity99.2%
prod-diff99.2%
*-commutative99.2%
*-un-lft-identity99.2%
*-commutative99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-udef99.2%
associate-+r+99.2%
unsub-neg99.2%
Simplified99.2%
*-commutative99.2%
tan-quot99.2%
clear-num99.2%
tan-quot99.3%
frac-times99.3%
*-un-lft-identity99.3%
clear-num99.3%
tan-quot99.3%
Applied egg-rr99.3%
*-commutative99.3%
associate-*r/99.3%
*-rgt-identity99.3%
associate-/l*99.2%
*-commutative99.2%
associate-/l*99.3%
Simplified99.3%
if -2.89999999999999991e-9 < eps < 2.6000000000000001e-9Initial program 29.6%
tan-sum29.6%
tan-quot29.3%
frac-sub29.3%
Applied egg-rr29.3%
Taylor expanded in eps around 0 99.5%
unpow299.5%
sin-mult99.6%
Applied egg-rr99.6%
div-sub99.6%
+-inverses99.6%
cos-099.6%
metadata-eval99.6%
count-299.6%
*-commutative99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate-/l*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -3.3e-9) (not (<= eps 2.6e-9)))
(- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x))
(/
eps
(/ (cos x) (+ (cos x) (/ (- 0.5 (* 0.5 (cos (* x 2.0)))) (cos x)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.3e-9) || !(eps <= 2.6e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.3d-9)) .or. (.not. (eps <= 2.6d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = eps / (cos(x) / (cos(x) + ((0.5d0 - (0.5d0 * cos((x * 2.0d0)))) / cos(x))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.3e-9) || !(eps <= 2.6e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = eps / (Math.cos(x) / (Math.cos(x) + ((0.5 - (0.5 * Math.cos((x * 2.0)))) / Math.cos(x))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.3e-9) or not (eps <= 2.6e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = eps / (math.cos(x) / (math.cos(x) + ((0.5 - (0.5 * math.cos((x * 2.0)))) / math.cos(x)))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.3e-9) || !(eps <= 2.6e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(eps / Float64(cos(x) / Float64(cos(x) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(x * 2.0)))) / cos(x))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.3e-9) || ~((eps <= 2.6e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.3e-9], N[Not[LessEqual[eps, 2.6e-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[(N[Cos[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 2.6 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon}{\frac{\cos x}{\cos x + \frac{0.5 - 0.5 \cdot \cos \left(x \cdot 2\right)}{\cos x}}}\\
\end{array}
\end{array}
if eps < -3.30000000000000018e-9 or 2.6000000000000001e-9 < eps Initial program 57.9%
tan-sum99.2%
div-inv99.2%
*-un-lft-identity99.2%
prod-diff99.2%
*-commutative99.2%
*-un-lft-identity99.2%
*-commutative99.2%
*-un-lft-identity99.2%
Applied egg-rr99.2%
+-commutative99.2%
fma-udef99.2%
associate-+r+99.2%
unsub-neg99.2%
Simplified99.2%
if -3.30000000000000018e-9 < eps < 2.6000000000000001e-9Initial program 29.6%
tan-sum29.6%
tan-quot29.3%
frac-sub29.3%
Applied egg-rr29.3%
Taylor expanded in eps around 0 99.5%
unpow299.5%
sin-mult99.6%
Applied egg-rr99.6%
div-sub99.6%
+-inverses99.6%
cos-099.6%
metadata-eval99.6%
count-299.6%
*-commutative99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate-/l*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -2.95e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 2e-9)
(/
eps
(/ (cos x) (+ (cos x) (/ (- 0.5 (* 0.5 (cos (* x 2.0)))) (cos x)))))
(- (/ t_0 (- 1.0 (* (tan x) (tan eps)))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -2.95e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 2e-9) {
tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x))));
} else {
tmp = (t_0 / (1.0 - (tan(x) * tan(eps)))) - 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 <= (-2.95d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 2d-9) then
tmp = eps / (cos(x) / (cos(x) + ((0.5d0 - (0.5d0 * cos((x * 2.0d0)))) / cos(x))))
else
tmp = (t_0 / (1.0d0 - (tan(x) * tan(eps)))) - 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 <= -2.95e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 2e-9) {
tmp = eps / (Math.cos(x) / (Math.cos(x) + ((0.5 - (0.5 * Math.cos((x * 2.0)))) / Math.cos(x))));
} else {
tmp = (t_0 / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -2.95e-9: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 2e-9: tmp = eps / (math.cos(x) / (math.cos(x) + ((0.5 - (0.5 * math.cos((x * 2.0)))) / math.cos(x)))) else: tmp = (t_0 / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -2.95e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 2e-9) tmp = Float64(eps / Float64(cos(x) / Float64(cos(x) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(x * 2.0)))) / cos(x))))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); tmp = 0.0; if (eps <= -2.95e-9) tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 2e-9) tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x)))); else tmp = (t_0 / (1.0 - (tan(x) * tan(eps)))) - 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, -2.95e-9], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2e-9], N[(eps / N[(N[Cos[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.95 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\varepsilon}{\frac{\cos x}{\cos x + \frac{0.5 - 0.5 \cdot \cos \left(x \cdot 2\right)}{\cos x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -2.9499999999999999e-9Initial program 54.0%
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%
tan-quot99.2%
clear-num99.1%
un-div-inv99.2%
clear-num99.2%
tan-quot99.2%
Applied egg-rr99.2%
if -2.9499999999999999e-9 < eps < 2.00000000000000012e-9Initial program 29.6%
tan-sum29.6%
tan-quot29.3%
frac-sub29.3%
Applied egg-rr29.3%
Taylor expanded in eps around 0 99.5%
unpow299.5%
sin-mult99.6%
Applied egg-rr99.6%
div-sub99.6%
+-inverses99.6%
cos-099.6%
metadata-eval99.6%
count-299.6%
*-commutative99.6%
Simplified99.6%
*-un-lft-identity99.6%
associate-/l*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
if 2.00000000000000012e-9 < eps Initial program 61.4%
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%
+-commutative99.3%
fma-udef99.3%
associate-+r+99.3%
unsub-neg99.3%
Simplified99.3%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -6.4e-6) (not (<= eps 0.000145)))
(tan eps)
(*
eps
(/ (+ (cos x) (/ (+ 0.5 (* (cos (* x 2.0)) -0.5)) (cos x))) (cos x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -6.4e-6) || !(eps <= 0.000145)) {
tmp = tan(eps);
} else {
tmp = eps * ((cos(x) + ((0.5 + (cos((x * 2.0)) * -0.5)) / cos(x))) / cos(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-6.4d-6)) .or. (.not. (eps <= 0.000145d0))) then
tmp = tan(eps)
else
tmp = eps * ((cos(x) + ((0.5d0 + (cos((x * 2.0d0)) * (-0.5d0))) / cos(x))) / cos(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -6.4e-6) || !(eps <= 0.000145)) {
tmp = Math.tan(eps);
} else {
tmp = eps * ((Math.cos(x) + ((0.5 + (Math.cos((x * 2.0)) * -0.5)) / Math.cos(x))) / Math.cos(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -6.4e-6) or not (eps <= 0.000145): tmp = math.tan(eps) else: tmp = eps * ((math.cos(x) + ((0.5 + (math.cos((x * 2.0)) * -0.5)) / math.cos(x))) / math.cos(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -6.4e-6) || !(eps <= 0.000145)) tmp = tan(eps); else tmp = Float64(eps * Float64(Float64(cos(x) + Float64(Float64(0.5 + Float64(cos(Float64(x * 2.0)) * -0.5)) / cos(x))) / cos(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -6.4e-6) || ~((eps <= 0.000145))) tmp = tan(eps); else tmp = eps * ((cos(x) + ((0.5 + (cos((x * 2.0)) * -0.5)) / cos(x))) / cos(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -6.4e-6], N[Not[LessEqual[eps, 0.000145]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[(N[(N[Cos[x], $MachinePrecision] + N[(N[(0.5 + N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -6.4 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 0.000145\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \frac{\cos x + \frac{0.5 + \cos \left(x \cdot 2\right) \cdot -0.5}{\cos x}}{\cos x}\\
\end{array}
\end{array}
if eps < -6.3999999999999997e-6 or 1.45e-4 < eps Initial program 57.8%
Taylor expanded in x around 0 60.8%
tan-quot61.1%
expm1-log1p-u44.7%
expm1-udef44.3%
Applied egg-rr44.3%
expm1-def44.7%
expm1-log1p61.1%
Simplified61.1%
if -6.3999999999999997e-6 < eps < 1.45e-4Initial program 30.8%
tan-sum31.9%
tan-quot31.6%
frac-sub31.6%
Applied egg-rr31.6%
Taylor expanded in eps around 0 98.7%
unpow298.7%
sin-mult98.7%
Applied egg-rr98.7%
div-sub98.7%
+-inverses98.7%
cos-098.7%
metadata-eval98.7%
count-298.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in eps around 0 98.7%
sub-neg98.7%
associate-*r/98.7%
*-commutative98.7%
*-commutative98.7%
associate-*r/98.7%
neg-mul-198.7%
remove-double-neg98.7%
associate-*r/98.7%
Simplified98.7%
Final simplification80.6%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -1.3e-5) (not (<= eps 0.000145)))
(tan eps)
(/
eps
(/ (cos x) (+ (cos x) (/ (- 0.5 (* 0.5 (cos (* x 2.0)))) (cos x)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.3e-5) || !(eps <= 0.000145)) {
tmp = tan(eps);
} else {
tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x))));
}
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-5)) .or. (.not. (eps <= 0.000145d0))) then
tmp = tan(eps)
else
tmp = eps / (cos(x) / (cos(x) + ((0.5d0 - (0.5d0 * cos((x * 2.0d0)))) / cos(x))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.3e-5) || !(eps <= 0.000145)) {
tmp = Math.tan(eps);
} else {
tmp = eps / (Math.cos(x) / (Math.cos(x) + ((0.5 - (0.5 * Math.cos((x * 2.0)))) / Math.cos(x))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.3e-5) or not (eps <= 0.000145): tmp = math.tan(eps) else: tmp = eps / (math.cos(x) / (math.cos(x) + ((0.5 - (0.5 * math.cos((x * 2.0)))) / math.cos(x)))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.3e-5) || !(eps <= 0.000145)) tmp = tan(eps); else tmp = Float64(eps / Float64(cos(x) / Float64(cos(x) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(x * 2.0)))) / cos(x))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.3e-5) || ~((eps <= 0.000145))) tmp = tan(eps); else tmp = eps / (cos(x) / (cos(x) + ((0.5 - (0.5 * cos((x * 2.0)))) / cos(x)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.3e-5], N[Not[LessEqual[eps, 0.000145]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps / N[(N[Cos[x], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.3 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 0.000145\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon}{\frac{\cos x}{\cos x + \frac{0.5 - 0.5 \cdot \cos \left(x \cdot 2\right)}{\cos x}}}\\
\end{array}
\end{array}
if eps < -1.29999999999999992e-5 or 1.45e-4 < eps Initial program 57.8%
Taylor expanded in x around 0 60.8%
tan-quot61.1%
expm1-log1p-u44.7%
expm1-udef44.3%
Applied egg-rr44.3%
expm1-def44.7%
expm1-log1p61.1%
Simplified61.1%
if -1.29999999999999992e-5 < eps < 1.45e-4Initial program 30.8%
tan-sum31.9%
tan-quot31.6%
frac-sub31.6%
Applied egg-rr31.6%
Taylor expanded in eps around 0 98.7%
unpow298.7%
sin-mult98.7%
Applied egg-rr98.7%
div-sub98.7%
+-inverses98.7%
cos-098.7%
metadata-eval98.7%
count-298.7%
*-commutative98.7%
Simplified98.7%
*-un-lft-identity98.7%
associate-/l*98.7%
cancel-sign-sub-inv98.7%
metadata-eval98.7%
*-un-lft-identity98.7%
div-inv98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification80.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.3e-6) (not (<= eps 0.000145))) (tan eps) (* eps (+ (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) 1.0))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.3e-6) || !(eps <= 0.000145)) {
tmp = tan(eps);
} else {
tmp = eps * ((pow(sin(x), 2.0) / pow(cos(x), 2.0)) + 1.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.3d-6)) .or. (.not. (eps <= 0.000145d0))) then
tmp = tan(eps)
else
tmp = eps * (((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.3e-6) || !(eps <= 0.000145)) {
tmp = Math.tan(eps);
} else {
tmp = eps * ((Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)) + 1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.3e-6) or not (eps <= 0.000145): tmp = math.tan(eps) else: tmp = eps * ((math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)) + 1.0) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.3e-6) || !(eps <= 0.000145)) tmp = tan(eps); else tmp = Float64(eps * Float64(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.3e-6) || ~((eps <= 0.000145))) tmp = tan(eps); else tmp = eps * (((sin(x) ^ 2.0) / (cos(x) ^ 2.0)) + 1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.3e-6], N[Not[LessEqual[eps, 0.000145]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 0.000145\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\frac{{\sin x}^{2}}{{\cos x}^{2}} + 1\right)\\
\end{array}
\end{array}
if eps < -3.30000000000000017e-6 or 1.45e-4 < eps Initial program 57.8%
Taylor expanded in x around 0 60.8%
tan-quot61.1%
expm1-log1p-u44.7%
expm1-udef44.3%
Applied egg-rr44.3%
expm1-def44.7%
expm1-log1p61.1%
Simplified61.1%
if -3.30000000000000017e-6 < eps < 1.45e-4Initial program 30.8%
Taylor expanded in eps around 0 98.7%
cancel-sign-sub-inv98.7%
metadata-eval98.7%
*-lft-identity98.7%
Simplified98.7%
Final simplification80.6%
(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 43.8%
Taylor expanded in x around 0 61.9%
tan-quot62.1%
expm1-log1p-u54.2%
expm1-udef24.9%
Applied egg-rr24.9%
expm1-def54.2%
expm1-log1p62.1%
Simplified62.1%
Final simplification62.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.8%
Taylor expanded in x around 0 61.9%
Taylor expanded in eps around 0 34.4%
Final simplification34.4%
(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 2023321
(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)))