
(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 9 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)))
(t_1 (pow (sin x) 2.0))
(t_2 (pow (cos x) 2.0)))
(if (<= eps -4.9e-5)
(- (/ t_0 (- 1.0 (/ (* (tan x) (sin eps)) (cos eps)))) (tan x))
(if (<= eps 8e-5)
(+
(/
(sin eps)
(* (cos eps) (- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))))
(+
(*
(pow eps 3.0)
(-
(/ (pow (sin x) 4.0) (pow (cos x) 4.0))
(* -0.3333333333333333 (/ t_1 t_2))))
(+
(/ (* eps t_1) t_2)
(/ (* (pow eps 2.0) (pow (sin x) 3.0)) (pow (cos x) 3.0)))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = pow(sin(x), 2.0);
double t_2 = pow(cos(x), 2.0);
double tmp;
if (eps <= -4.9e-5) {
tmp = (t_0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x);
} else if (eps <= 8e-5) {
tmp = (sin(eps) / (cos(eps) * (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + ((pow(eps, 3.0) * ((pow(sin(x), 4.0) / pow(cos(x), 4.0)) - (-0.3333333333333333 * (t_1 / t_2)))) + (((eps * t_1) / t_2) + ((pow(eps, 2.0) * pow(sin(x), 3.0)) / pow(cos(x), 3.0))));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = sin(x) ** 2.0d0
t_2 = cos(x) ** 2.0d0
if (eps <= (-4.9d-5)) then
tmp = (t_0 / (1.0d0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x)
else if (eps <= 8d-5) then
tmp = (sin(eps) / (cos(eps) * (1.0d0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + (((eps ** 3.0d0) * (((sin(x) ** 4.0d0) / (cos(x) ** 4.0d0)) - ((-0.3333333333333333d0) * (t_1 / t_2)))) + (((eps * t_1) / t_2) + (((eps ** 2.0d0) * (sin(x) ** 3.0d0)) / (cos(x) ** 3.0d0))))
else
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / 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 t_1 = Math.pow(Math.sin(x), 2.0);
double t_2 = Math.pow(Math.cos(x), 2.0);
double tmp;
if (eps <= -4.9e-5) {
tmp = (t_0 / (1.0 - ((Math.tan(x) * Math.sin(eps)) / Math.cos(eps)))) - Math.tan(x);
} else if (eps <= 8e-5) {
tmp = (Math.sin(eps) / (Math.cos(eps) * (1.0 - ((Math.sin(eps) / Math.cos(eps)) * (Math.sin(x) / Math.cos(x)))))) + ((Math.pow(eps, 3.0) * ((Math.pow(Math.sin(x), 4.0) / Math.pow(Math.cos(x), 4.0)) - (-0.3333333333333333 * (t_1 / t_2)))) + (((eps * t_1) / t_2) + ((Math.pow(eps, 2.0) * Math.pow(Math.sin(x), 3.0)) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = math.pow(math.sin(x), 2.0) t_2 = math.pow(math.cos(x), 2.0) tmp = 0 if eps <= -4.9e-5: tmp = (t_0 / (1.0 - ((math.tan(x) * math.sin(eps)) / math.cos(eps)))) - math.tan(x) elif eps <= 8e-5: tmp = (math.sin(eps) / (math.cos(eps) * (1.0 - ((math.sin(eps) / math.cos(eps)) * (math.sin(x) / math.cos(x)))))) + ((math.pow(eps, 3.0) * ((math.pow(math.sin(x), 4.0) / math.pow(math.cos(x), 4.0)) - (-0.3333333333333333 * (t_1 / t_2)))) + (((eps * t_1) / t_2) + ((math.pow(eps, 2.0) * math.pow(math.sin(x), 3.0)) / math.pow(math.cos(x), 3.0)))) else: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = sin(x) ^ 2.0 t_2 = cos(x) ^ 2.0 tmp = 0.0 if (eps <= -4.9e-5) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(Float64(tan(x) * sin(eps)) / cos(eps)))) - tan(x)); elseif (eps <= 8e-5) tmp = Float64(Float64(sin(eps) / Float64(cos(eps) * Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x)))))) + Float64(Float64((eps ^ 3.0) * Float64(Float64((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - Float64(-0.3333333333333333 * Float64(t_1 / t_2)))) + Float64(Float64(Float64(eps * t_1) / t_2) + Float64(Float64((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = sin(x) ^ 2.0; t_2 = cos(x) ^ 2.0; tmp = 0.0; if (eps <= -4.9e-5) tmp = (t_0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x); elseif (eps <= 8e-5) tmp = (sin(eps) / (cos(eps) * (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + (((eps ^ 3.0) * (((sin(x) ^ 4.0) / (cos(x) ^ 4.0)) - (-0.3333333333333333 * (t_1 / t_2)))) + (((eps * t_1) / t_2) + (((eps ^ 2.0) * (sin(x) ^ 3.0)) / (cos(x) ^ 3.0)))); else tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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]}, Block[{t$95$1 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[eps, -4.9e-5], N[(N[(t$95$0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-5], 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[(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$1 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(eps * t$95$1), $MachinePrecision] / t$95$2), $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[(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]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := {\sin x}^{2}\\
t_2 := {\cos x}^{2}\\
\mathbf{if}\;\varepsilon \leq -4.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}\right)} + \left({\varepsilon}^{3} \cdot \left(\frac{{\sin x}^{4}}{{\cos x}^{4}} - -0.3333333333333333 \cdot \frac{t_1}{t_2}\right) + \left(\frac{\varepsilon \cdot t_1}{t_2} + \frac{{\varepsilon}^{2} \cdot {\sin x}^{3}}{{\cos x}^{3}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -4.9e-5Initial program 44.2%
tan-sum99.5%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.4%
associate-+r+99.4%
unsub-neg99.4%
Simplified99.5%
tan-quot99.5%
associate-*r/99.6%
Applied egg-rr99.6%
if -4.9e-5 < eps < 8.00000000000000065e-5Initial program 26.8%
tan-sum27.5%
div-inv27.5%
*-un-lft-identity27.5%
prod-diff27.5%
*-commutative27.5%
*-un-lft-identity27.5%
*-commutative27.5%
*-un-lft-identity27.5%
Applied egg-rr27.5%
+-commutative27.5%
fma-udef27.5%
associate-+r+27.5%
unsub-neg27.5%
Simplified27.5%
Taylor expanded in x around inf 27.4%
Simplified59.4%
tan-quot56.4%
sub-neg56.4%
tan-quot59.4%
tan-quot59.4%
tan-quot59.4%
*-commutative59.4%
Applied egg-rr59.4%
sub-neg59.4%
Simplified59.4%
Taylor expanded in eps around 0 99.7%
if 8.00000000000000065e-5 < eps Initial program 57.5%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.5%
associate-+r+99.5%
unsub-neg99.5%
Simplified99.5%
tan-quot99.5%
clear-num99.4%
un-div-inv99.5%
clear-num99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -1.05e-8)
(- (/ t_0 (- 1.0 (/ (* (tan x) (sin eps)) (cos eps)))) (tan x))
(if (<= eps 1e-8)
(+
(/
(sin eps)
(* (cos eps) (- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))))
(/ (* eps (pow (sin x) 2.0)) (pow (cos x) 2.0)))
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -1.05e-8) {
tmp = (t_0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x);
} else if (eps <= 1e-8) {
tmp = (sin(eps) / (cos(eps) * (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + ((eps * pow(sin(x), 2.0)) / pow(cos(x), 2.0));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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 <= (-1.05d-8)) then
tmp = (t_0 / (1.0d0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x)
else if (eps <= 1d-8) then
tmp = (sin(eps) / (cos(eps) * (1.0d0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + ((eps * (sin(x) ** 2.0d0)) / (cos(x) ** 2.0d0))
else
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / 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 <= -1.05e-8) {
tmp = (t_0 / (1.0 - ((Math.tan(x) * Math.sin(eps)) / Math.cos(eps)))) - Math.tan(x);
} else if (eps <= 1e-8) {
tmp = (Math.sin(eps) / (Math.cos(eps) * (1.0 - ((Math.sin(eps) / Math.cos(eps)) * (Math.sin(x) / Math.cos(x)))))) + ((eps * Math.pow(Math.sin(x), 2.0)) / Math.pow(Math.cos(x), 2.0));
} else {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -1.05e-8: tmp = (t_0 / (1.0 - ((math.tan(x) * math.sin(eps)) / math.cos(eps)))) - math.tan(x) elif eps <= 1e-8: tmp = (math.sin(eps) / (math.cos(eps) * (1.0 - ((math.sin(eps) / math.cos(eps)) * (math.sin(x) / math.cos(x)))))) + ((eps * math.pow(math.sin(x), 2.0)) / math.pow(math.cos(x), 2.0)) else: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -1.05e-8) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(Float64(tan(x) * sin(eps)) / cos(eps)))) - tan(x)); elseif (eps <= 1e-8) tmp = Float64(Float64(sin(eps) / Float64(cos(eps) * Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x)))))) + Float64(Float64(eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / 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 <= -1.05e-8) tmp = (t_0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x); elseif (eps <= 1e-8) tmp = (sin(eps) / (cos(eps) * (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x)))))) + ((eps * (sin(x) ^ 2.0)) / (cos(x) ^ 2.0)); else tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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, -1.05e-8], N[(N[(t$95$0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1e-8], 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[(N[(eps * N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.05 \cdot 10^{-8}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 10^{-8}:\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon \cdot \left(1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}\right)} + \frac{\varepsilon \cdot {\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -1.04999999999999997e-8Initial program 43.4%
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%
tan-quot99.3%
associate-*r/99.3%
Applied egg-rr99.3%
if -1.04999999999999997e-8 < eps < 1e-8Initial program 27.0%
tan-sum27.0%
div-inv27.0%
*-un-lft-identity27.0%
prod-diff27.0%
*-commutative27.0%
*-un-lft-identity27.0%
*-commutative27.0%
*-un-lft-identity27.0%
Applied egg-rr27.0%
+-commutative27.0%
fma-udef27.0%
associate-+r+27.0%
unsub-neg27.0%
Simplified27.0%
Taylor expanded in x around inf 27.0%
Simplified59.2%
Taylor expanded in eps around 0 99.7%
if 1e-8 < eps Initial program 57.5%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.5%
associate-+r+99.5%
unsub-neg99.5%
Simplified99.5%
tan-quot99.5%
clear-num99.4%
un-div-inv99.5%
clear-num99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -9.5e-9)
(- (/ t_0 (- 1.0 (/ (* (tan x) (sin eps)) (cos eps)))) (tan x))
(if (<= eps 2.5e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -9.5e-9) {
tmp = (t_0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x);
} else if (eps <= 2.5e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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 <= (-9.5d-9)) then
tmp = (t_0 / (1.0d0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x)
else if (eps <= 2.5d-9) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / 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 <= -9.5e-9) {
tmp = (t_0 / (1.0 - ((Math.tan(x) * Math.sin(eps)) / Math.cos(eps)))) - Math.tan(x);
} else if (eps <= 2.5e-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.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -9.5e-9: tmp = (t_0 / (1.0 - ((math.tan(x) * math.sin(eps)) / math.cos(eps)))) - math.tan(x) elif eps <= 2.5e-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.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -9.5e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(Float64(tan(x) * sin(eps)) / cos(eps)))) - tan(x)); elseif (eps <= 2.5e-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(tan(x) / Float64(1.0 / 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 <= -9.5e-9) tmp = (t_0 / (1.0 - ((tan(x) * sin(eps)) / cos(eps)))) - tan(x); elseif (eps <= 2.5e-9) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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, -9.5e-9], N[(N[(t$95$0 / N[(1.0 - N[(N[(N[Tan[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.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 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -9.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.5 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -9.5000000000000007e-9Initial program 43.4%
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%
tan-quot99.3%
associate-*r/99.3%
Applied egg-rr99.3%
if -9.5000000000000007e-9 < eps < 2.5000000000000001e-9Initial program 27.0%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
if 2.5000000000000001e-9 < eps Initial program 57.5%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.5%
associate-+r+99.5%
unsub-neg99.5%
Simplified99.5%
tan-quot99.5%
clear-num99.4%
un-div-inv99.5%
clear-num99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -9.5e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 3.7e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (* t_0 (/ 1.0 t_1)) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -9.5e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 3.7e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 * (1.0 / t_1)) - tan(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = tan(x) + tan(eps)
t_1 = 1.0d0 - (tan(x) * tan(eps))
if (eps <= (-9.5d-9)) then
tmp = (t_0 / t_1) - tan(x)
else if (eps <= 3.7d-9) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 * (1.0d0 / t_1)) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) + Math.tan(eps);
double t_1 = 1.0 - (Math.tan(x) * Math.tan(eps));
double tmp;
if (eps <= -9.5e-9) {
tmp = (t_0 / t_1) - Math.tan(x);
} else if (eps <= 3.7e-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 / t_1)) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) t_1 = 1.0 - (math.tan(x) * math.tan(eps)) tmp = 0 if eps <= -9.5e-9: tmp = (t_0 / t_1) - math.tan(x) elif eps <= 3.7e-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 / t_1)) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -9.5e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 3.7e-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 / t_1)) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(x) + tan(eps); t_1 = 1.0 - (tan(x) * tan(eps)); tmp = 0.0; if (eps <= -9.5e-9) tmp = (t_0 / t_1) - tan(x); elseif (eps <= 3.7e-9) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 * (1.0 / t_1)) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -9.5e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.7e-9], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -9.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.7 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -9.5000000000000007e-9Initial program 43.4%
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 -9.5000000000000007e-9 < eps < 3.7e-9Initial program 27.0%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
if 3.7e-9 < eps Initial program 57.5%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -9.5e-9)
(- (/ t_0 (- 1.0 (* (tan x) (tan eps)))) (tan x))
(if (<= eps 2.9e-9)
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double tmp;
if (eps <= -9.5e-9) {
tmp = (t_0 / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else if (eps <= 2.9e-9) {
tmp = eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)));
} else {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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 <= (-9.5d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else if (eps <= 2.9d-9) then
tmp = eps * (1.0d0 + ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))
else
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / 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 <= -9.5e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else if (eps <= 2.9e-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.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(x) + math.tan(eps) tmp = 0 if eps <= -9.5e-9: tmp = (t_0 / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) elif eps <= 2.9e-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.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -9.5e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); elseif (eps <= 2.9e-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(tan(x) / Float64(1.0 / 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 <= -9.5e-9) tmp = (t_0 / (1.0 - (tan(x) * tan(eps)))) - tan(x); elseif (eps <= 2.9e-9) tmp = eps * (1.0 + ((sin(x) ^ 2.0) / (cos(x) ^ 2.0))); else tmp = (t_0 / (1.0 - (tan(x) / (1.0 / 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, -9.5e-9], 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], If[LessEqual[eps, 2.9e-9], N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -9.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.9 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\end{array}
\end{array}
if eps < -9.5000000000000007e-9Initial program 43.4%
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 -9.5000000000000007e-9 < eps < 2.89999999999999991e-9Initial program 27.0%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
if 2.89999999999999991e-9 < eps Initial program 57.5%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
+-commutative99.5%
fma-udef99.5%
associate-+r+99.5%
unsub-neg99.5%
Simplified99.5%
tan-quot99.5%
clear-num99.4%
un-div-inv99.5%
clear-num99.5%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -9.5e-9) (not (<= eps 3.1e-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 <= -9.5e-9) || !(eps <= 3.1e-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 <= (-9.5d-9)) .or. (.not. (eps <= 3.1d-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 <= -9.5e-9) || !(eps <= 3.1e-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 <= -9.5e-9) or not (eps <= 3.1e-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 <= -9.5e-9) || !(eps <= 3.1e-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 <= -9.5e-9) || ~((eps <= 3.1e-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, -9.5e-9], N[Not[LessEqual[eps, 3.1e-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 -9.5 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.1 \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 < -9.5000000000000007e-9 or 3.10000000000000005e-9 < eps Initial program 52.1%
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%
if -9.5000000000000007e-9 < eps < 3.10000000000000005e-9Initial program 27.0%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.065) (not (<= eps 7e-20))) (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 <= -0.065) || !(eps <= 7e-20)) {
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 <= (-0.065d0)) .or. (.not. (eps <= 7d-20))) 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 <= -0.065) || !(eps <= 7e-20)) {
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 <= -0.065) or not (eps <= 7e-20): 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 <= -0.065) || !(eps <= 7e-20)) 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 <= -0.065) || ~((eps <= 7e-20))) 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, -0.065], N[Not[LessEqual[eps, 7e-20]], $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 -0.065 \lor \neg \left(\varepsilon \leq 7 \cdot 10^{-20}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right)\\
\end{array}
\end{array}
if eps < -0.065000000000000002 or 7.00000000000000007e-20 < eps Initial program 53.4%
Taylor expanded in x around 0 56.0%
tan-quot56.2%
Applied egg-rr56.2%
if -0.065000000000000002 < eps < 7.00000000000000007e-20Initial program 25.4%
Taylor expanded in eps around 0 98.5%
cancel-sign-sub-inv98.5%
metadata-eval98.5%
*-lft-identity98.5%
Simplified98.5%
Final simplification75.4%
(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 40.7%
Taylor expanded in x around 0 56.8%
tan-quot57.0%
Applied egg-rr57.0%
Final simplification57.0%
(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 40.7%
Taylor expanded in x around 0 56.8%
Taylor expanded in eps around 0 28.8%
Final simplification28.8%
(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 2023322
(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)))