
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
double code(double x, double eps) {
return tan((x + eps)) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((x + eps)) - tan(x)
end function
public static double code(double x, double eps) {
return Math.tan((x + eps)) - Math.tan(x);
}
def code(x, eps): return math.tan((x + eps)) - math.tan(x)
function code(x, eps) return Float64(tan(Float64(x + eps)) - tan(x)) end
function tmp = code(x, eps) tmp = tan((x + eps)) - tan(x); end
code[x_, eps_] := N[(N[Tan[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(x + \varepsilon\right) - \tan x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps))))
(t_1 (+ (tan x) (tan eps)))
(t_2 (/ -1.0 (tan x))))
(if (<= eps -2.15e-9)
(- (- (tan x)) (/ t_1 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 5.2e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(/ (+ t_0 (* t_1 t_2)) (* t_0 t_2))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(x) + tan(eps);
double t_2 = -1.0 / tan(x);
double tmp;
if (eps <= -2.15e-9) {
tmp = -tan(x) - (t_1 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 5.2e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = (t_0 + (t_1 * t_2)) / (t_0 * t_2);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(x) + tan(eps)) t_2 = Float64(-1.0 / tan(x)) tmp = 0.0 if (eps <= -2.15e-9) tmp = Float64(Float64(-tan(x)) - Float64(t_1 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 5.2e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = Float64(Float64(t_0 + Float64(t_1 * t_2)) / Float64(t_0 * t_2)); end return 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[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.15e-9], N[((-N[Tan[x], $MachinePrecision]) - N[(t$95$1 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.2e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
t_2 := \frac{-1}{\tan x}\\
\mathbf{if}\;\varepsilon \leq -2.15 \cdot 10^{-9}:\\
\;\;\;\;\left(-\tan x\right) - \frac{t_1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + t_1 \cdot t_2}{t_0 \cdot t_2}\\
\end{array}
\end{array}
if eps < -2.14999999999999981e-9Initial program 44.9%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
*-commutative99.5%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.5%
associate-*l/99.5%
neg-mul-199.5%
distribute-neg-in99.5%
unsub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
sub-neg99.5%
fma-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -2.14999999999999981e-9 < eps < 5.2000000000000002e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
if 5.2000000000000002e-9 < eps Initial program 51.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.4%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
frac-2neg99.3%
*-commutative99.3%
tan-quot99.3%
tan-quot99.2%
tan-quot99.1%
clear-num99.1%
frac-sub99.1%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))) (t_1 (/ (sin eps) (cos eps))))
(-
(/ t_1 (- 1.0 (* t_1 (/ (sin x) (cos x)))))
(/ t_0 (/ (+ t_0 -1.0) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = sin(eps) / cos(eps);
return (t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) - (t_0 / ((t_0 + -1.0) / tan(x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
t_0 = tan(x) * tan(eps)
t_1 = sin(eps) / cos(eps)
code = (t_1 / (1.0d0 - (t_1 * (sin(x) / cos(x))))) - (t_0 / ((t_0 + (-1.0d0)) / tan(x)))
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) * Math.tan(eps);
double t_1 = Math.sin(eps) / Math.cos(eps);
return (t_1 / (1.0 - (t_1 * (Math.sin(x) / Math.cos(x))))) - (t_0 / ((t_0 + -1.0) / Math.tan(x)));
}
def code(x, eps): t_0 = math.tan(x) * math.tan(eps) t_1 = math.sin(eps) / math.cos(eps) return (t_1 / (1.0 - (t_1 * (math.sin(x) / math.cos(x))))) - (t_0 / ((t_0 + -1.0) / math.tan(x)))
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = Float64(sin(eps) / cos(eps)) return Float64(Float64(t_1 / Float64(1.0 - Float64(t_1 * Float64(sin(x) / cos(x))))) - Float64(t_0 / Float64(Float64(t_0 + -1.0) / tan(x)))) end
function tmp = code(x, eps) t_0 = tan(x) * tan(eps); t_1 = sin(eps) / cos(eps); tmp = (t_1 / (1.0 - (t_1 * (sin(x) / cos(x))))) - (t_0 / ((t_0 + -1.0) / tan(x))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$1 / N[(1.0 - N[(t$95$1 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 / N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
\frac{t_1}{1 - t_1 \cdot \frac{\sin x}{\cos x}} - \frac{t_0}{\frac{t_0 + -1}{\tan x}}
\end{array}
\end{array}
Initial program 38.5%
tan-sum65.3%
div-inv65.3%
Applied egg-rr65.3%
Taylor expanded in x around inf 65.1%
associate--l+76.8%
associate-/r*76.8%
*-commutative76.8%
times-frac76.9%
Simplified76.8%
tan-quot75.4%
frac-2neg75.4%
clear-num73.9%
frac-sub73.4%
Applied egg-rr74.6%
cancel-sign-sub74.6%
distribute-lft-neg-out74.6%
rgt-mult-inverse76.9%
metadata-eval76.9%
*-rgt-identity76.9%
associate-+r-99.5%
metadata-eval99.5%
neg-sub099.5%
distribute-rgt-neg-in99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (tan x) (tan eps))))
(-
(/ (/ (sin eps) (cos eps)) (- 1.0 t_0))
(/ t_0 (/ (+ t_0 -1.0) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
return ((sin(eps) / cos(eps)) / (1.0 - t_0)) - (t_0 / ((t_0 + -1.0) / tan(x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = tan(x) * tan(eps)
code = ((sin(eps) / cos(eps)) / (1.0d0 - t_0)) - (t_0 / ((t_0 + (-1.0d0)) / tan(x)))
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) * Math.tan(eps);
return ((Math.sin(eps) / Math.cos(eps)) / (1.0 - t_0)) - (t_0 / ((t_0 + -1.0) / Math.tan(x)));
}
def code(x, eps): t_0 = math.tan(x) * math.tan(eps) return ((math.sin(eps) / math.cos(eps)) / (1.0 - t_0)) - (t_0 / ((t_0 + -1.0) / math.tan(x)))
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) return Float64(Float64(Float64(sin(eps) / cos(eps)) / Float64(1.0 - t_0)) - Float64(t_0 / Float64(Float64(t_0 + -1.0) / tan(x)))) end
function tmp = code(x, eps) t_0 = tan(x) * tan(eps); tmp = ((sin(eps) / cos(eps)) / (1.0 - t_0)) - (t_0 / ((t_0 + -1.0) / tan(x))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 / N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{1 - t_0} - \frac{t_0}{\frac{t_0 + -1}{\tan x}}
\end{array}
\end{array}
Initial program 38.5%
tan-sum65.3%
div-inv65.3%
Applied egg-rr65.3%
Taylor expanded in x around inf 65.1%
associate--l+76.8%
associate-/r*76.8%
*-commutative76.8%
times-frac76.9%
Simplified76.8%
tan-quot75.4%
frac-2neg75.4%
clear-num73.9%
frac-sub73.4%
Applied egg-rr74.6%
cancel-sign-sub74.6%
distribute-lft-neg-out74.6%
rgt-mult-inverse76.9%
metadata-eval76.9%
*-rgt-identity76.9%
associate-+r-99.5%
metadata-eval99.5%
neg-sub099.5%
distribute-rgt-neg-in99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
tan-quot99.4%
tan-quot99.4%
*-commutative99.4%
tan-quot99.4%
clear-num99.4%
tan-quot99.5%
clear-num99.5%
frac-times99.5%
metadata-eval99.5%
clear-num99.5%
tan-quot99.5%
clear-num99.5%
tan-quot99.4%
Applied egg-rr99.4%
associate-/r*99.4%
remove-double-div99.4%
associate-/r/99.4%
/-rgt-identity99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -6.1e-9)
(- t_0 (/ t_1 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 4.5e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(fma t_1 (/ 1.0 (- 1.0 (/ (* (sin x) (tan eps)) (cos x)))) t_0)))))
double code(double x, double eps) {
double t_0 = -tan(x);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -6.1e-9) {
tmp = t_0 - (t_1 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 4.5e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = fma(t_1, (1.0 / (1.0 - ((sin(x) * tan(eps)) / cos(x)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -6.1e-9) tmp = Float64(t_0 - Float64(t_1 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 4.5e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = fma(t_1, Float64(1.0 / Float64(1.0 - Float64(Float64(sin(x) * tan(eps)) / cos(x)))), t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6.1e-9], N[(t$95$0 - N[(t$95$1 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.5e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[(N[Sin[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -6.1 \cdot 10^{-9}:\\
\;\;\;\;t_0 - \frac{t_1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 4.5 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}}, t_0\right)\\
\end{array}
\end{array}
if eps < -6.1e-9Initial program 44.9%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
*-commutative99.5%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.5%
associate-*l/99.5%
neg-mul-199.5%
distribute-neg-in99.5%
unsub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
sub-neg99.5%
fma-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -6.1e-9 < eps < 4.49999999999999976e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
if 4.49999999999999976e-9 < eps Initial program 51.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
*-commutative99.4%
tan-quot99.3%
associate-*r/99.4%
Applied egg-rr99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -1.9e-9)
(- t_0 (/ t_1 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 3.8e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(fma t_1 (/ 1.0 (- 1.0 (* (tan x) (tan eps)))) t_0)))))
double code(double x, double eps) {
double t_0 = -tan(x);
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -1.9e-9) {
tmp = t_0 - (t_1 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 3.8e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = fma(t_1, (1.0 / (1.0 - (tan(x) * tan(eps)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -1.9e-9) tmp = Float64(t_0 - Float64(t_1 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 3.8e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = fma(t_1, Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps)))), t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.9e-9], N[(t$95$0 - N[(t$95$1 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.8e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.9 \cdot 10^{-9}:\\
\;\;\;\;t_0 - \frac{t_1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 3.8 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, \frac{1}{1 - \tan x \cdot \tan \varepsilon}, t_0\right)\\
\end{array}
\end{array}
if eps < -1.90000000000000006e-9Initial program 44.9%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
*-commutative99.5%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.5%
associate-*l/99.5%
neg-mul-199.5%
distribute-neg-in99.5%
unsub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
sub-neg99.5%
fma-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -1.90000000000000006e-9 < eps < 3.80000000000000011e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
if 3.80000000000000011e-9 < eps Initial program 51.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -3.2e-9)
(- (- (tan x)) (/ t_0 (fma (tan x) (tan eps) -1.0)))
(if (<= eps 4.5e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(- (* t_0 (/ 1.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 <= -3.2e-9) {
tmp = -tan(x) - (t_0 / fma(tan(x), tan(eps), -1.0));
} else if (eps <= 4.5e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = (t_0 * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -3.2e-9) tmp = Float64(Float64(-tan(x)) - Float64(t_0 / fma(tan(x), tan(eps), -1.0))); elseif (eps <= 4.5e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.2e-9], N[((-N[Tan[x], $MachinePrecision]) - N[(t$95$0 / N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.5e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * 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 -3.2 \cdot 10^{-9}:\\
\;\;\;\;\left(-\tan x\right) - \frac{t_0}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}\\
\mathbf{elif}\;\varepsilon \leq 4.5 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -3.20000000000000012e-9Initial program 44.9%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
*-commutative99.5%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.5%
associate-*l/99.5%
neg-mul-199.5%
distribute-neg-in99.5%
unsub-neg99.5%
+-commutative99.5%
metadata-eval99.5%
sub-neg99.5%
fma-neg99.5%
metadata-eval99.5%
Simplified99.5%
if -3.20000000000000012e-9 < eps < 4.49999999999999976e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
if 4.49999999999999976e-9 < eps Initial program 51.7%
tan-sum99.3%
div-inv99.4%
Applied egg-rr99.4%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.45e-9) (not (<= eps 3.2e-9))) (- (* (+ (tan x) (tan eps)) (/ 1.0 (- 1.0 (* (tan x) (tan eps))))) (tan x)) (+ eps (* eps (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.45e-9) || !(eps <= 3.2e-9)) {
tmp = ((tan(x) + tan(eps)) * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
} else {
tmp = eps + (eps * pow(tan(x), 2.0));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.45d-9)) .or. (.not. (eps <= 3.2d-9))) then
tmp = ((tan(x) + tan(eps)) * (1.0d0 / (1.0d0 - (tan(x) * tan(eps))))) - tan(x)
else
tmp = eps + (eps * (tan(x) ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.45e-9) || !(eps <= 3.2e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) * (1.0 / (1.0 - (Math.tan(x) * Math.tan(eps))))) - Math.tan(x);
} else {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.45e-9) or not (eps <= 3.2e-9): tmp = ((math.tan(x) + math.tan(eps)) * (1.0 / (1.0 - (math.tan(x) * math.tan(eps))))) - math.tan(x) else: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.45e-9) || !(eps <= 3.2e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - tan(x)); else tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.45e-9) || ~((eps <= 3.2e-9))) tmp = ((tan(x) + tan(eps)) * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x); else tmp = eps + (eps * (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.45e-9], N[Not[LessEqual[eps, 3.2e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.45 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 3.2 \cdot 10^{-9}\right):\\
\;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\end{array}
if eps < -3.44999999999999987e-9 or 3.20000000000000012e-9 < eps Initial program 48.3%
tan-sum99.4%
div-inv99.4%
Applied egg-rr99.4%
if -3.44999999999999987e-9 < eps < 3.20000000000000012e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -3.4e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 5.2e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(- (* t_0 (/ 1.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 <= -3.4e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 5.2e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = (t_0 * (1.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 <= (-3.4d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 5.2d-9) then
tmp = eps + (eps * (tan(x) ** 2.0d0))
else
tmp = (t_0 * (1.0d0 / (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 <= -3.4e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 5.2e-9) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = (t_0 * (1.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 <= -3.4e-9: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 5.2e-9: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = (t_0 * (1.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 <= -3.4e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 5.2e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = Float64(Float64(t_0 * Float64(1.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 <= -3.4e-9) tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 5.2e-9) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = (t_0 * (1.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, -3.4e-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, 5.2e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * 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 -3.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -3.3999999999999998e-9Initial program 44.9%
tan-sum99.5%
div-inv99.5%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
tan-quot99.3%
clear-num99.4%
un-div-inv99.4%
clear-num99.3%
tan-quot99.5%
Applied egg-rr99.5%
if -3.3999999999999998e-9 < eps < 5.2000000000000002e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
if 5.2000000000000002e-9 < eps Initial program 51.7%
tan-sum99.3%
div-inv99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))))
(if (<= eps -4.6e-9)
(- (* t_0 (/ 1.0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps)))))) (tan x))
(if (<= eps 3.6e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(- (* t_0 (/ 1.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 <= -4.6e-9) {
tmp = (t_0 * (1.0 / (1.0 - (tan(x) / (1.0 / tan(eps)))))) - tan(x);
} else if (eps <= 3.6e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = (t_0 * (1.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 <= (-4.6d-9)) then
tmp = (t_0 * (1.0d0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps)))))) - tan(x)
else if (eps <= 3.6d-9) then
tmp = eps + (eps * (tan(x) ** 2.0d0))
else
tmp = (t_0 * (1.0d0 / (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 <= -4.6e-9) {
tmp = (t_0 * (1.0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps)))))) - Math.tan(x);
} else if (eps <= 3.6e-9) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = (t_0 * (1.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 <= -4.6e-9: tmp = (t_0 * (1.0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps)))))) - math.tan(x) elif eps <= 3.6e-9: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = (t_0 * (1.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 <= -4.6e-9) tmp = Float64(Float64(t_0 * Float64(1.0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps)))))) - tan(x)); elseif (eps <= 3.6e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = Float64(Float64(t_0 * Float64(1.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 <= -4.6e-9) tmp = (t_0 * (1.0 / (1.0 - (tan(x) / (1.0 / tan(eps)))))) - tan(x); elseif (eps <= 3.6e-9) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = (t_0 * (1.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, -4.6e-9], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] / N[(1.0 / N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.6e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * 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 -4.6 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.6 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -4.5999999999999998e-9Initial program 44.9%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
tan-quot99.3%
clear-num99.4%
un-div-inv99.4%
clear-num99.3%
tan-quot99.5%
Applied egg-rr99.5%
if -4.5999999999999998e-9 < eps < 3.6e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
if 3.6e-9 < eps Initial program 51.7%
tan-sum99.3%
div-inv99.4%
Applied egg-rr99.4%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.4e-9) (not (<= eps 5.8e-9))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (+ eps (* eps (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.4e-9) || !(eps <= 5.8e-9)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = eps + (eps * pow(tan(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 <= (-1.4d-9)) .or. (.not. (eps <= 5.8d-9))) then
tmp = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
else
tmp = eps + (eps * (tan(x) ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.4e-9) || !(eps <= 5.8e-9)) {
tmp = ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
} else {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.4e-9) or not (eps <= 5.8e-9): tmp = ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x) else: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.4e-9) || !(eps <= 5.8e-9)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.4e-9) || ~((eps <= 5.8e-9))) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); else tmp = eps + (eps * (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.4e-9], N[Not[LessEqual[eps, 5.8e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.4 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 5.8 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\end{array}
if eps < -1.39999999999999992e-9 or 5.79999999999999982e-9 < eps Initial program 48.3%
tan-sum99.4%
div-inv99.4%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.4%
associate-*r/99.4%
*-rgt-identity99.4%
Simplified99.4%
if -1.39999999999999992e-9 < eps < 5.79999999999999982e-9Initial program 28.0%
tan-sum28.5%
div-inv28.4%
fma-neg28.4%
Applied egg-rr28.4%
fma-neg28.4%
associate-*r/28.5%
*-rgt-identity28.5%
Simplified28.5%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
Simplified99.5%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.6%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (<= eps -0.0105) (tan eps) (if (<= eps 0.118) (* eps (+ 1.0 (pow (tan x) 2.0))) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0105) {
tmp = tan(eps);
} else if (eps <= 0.118) {
tmp = eps * (1.0 + pow(tan(x), 2.0));
} else {
tmp = tan(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.0105d0)) then
tmp = tan(eps)
else if (eps <= 0.118d0) then
tmp = eps * (1.0d0 + (tan(x) ** 2.0d0))
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.0105) {
tmp = Math.tan(eps);
} else if (eps <= 0.118) {
tmp = eps * (1.0 + Math.pow(Math.tan(x), 2.0));
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.0105: tmp = math.tan(eps) elif eps <= 0.118: tmp = eps * (1.0 + math.pow(math.tan(x), 2.0)) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.0105) tmp = tan(eps); elseif (eps <= 0.118) tmp = Float64(eps * Float64(1.0 + (tan(x) ^ 2.0))); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.0105) tmp = tan(eps); elseif (eps <= 0.118) tmp = eps * (1.0 + (tan(x) ^ 2.0)); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0105], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 0.118], N[(eps * N[(1.0 + N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0105:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 0.118:\\
\;\;\;\;\varepsilon \cdot \left(1 + {\tan x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -0.0105000000000000007 or 0.11799999999999999 < eps Initial program 49.3%
Taylor expanded in x around 0 52.8%
tan-quot53.0%
expm1-log1p-u40.8%
expm1-udef40.4%
Applied egg-rr40.4%
expm1-def40.8%
expm1-log1p53.0%
Simplified53.0%
if -0.0105000000000000007 < eps < 0.11799999999999999Initial program 27.4%
tan-sum30.0%
div-inv30.0%
fma-neg30.0%
Applied egg-rr30.0%
fma-neg30.0%
associate-*r/30.0%
*-rgt-identity30.0%
Simplified30.0%
Taylor expanded in eps around 0 97.9%
cancel-sign-sub-inv97.9%
metadata-eval97.9%
*-lft-identity97.9%
Simplified97.9%
unpow297.9%
unpow297.9%
frac-times97.8%
tan-quot97.9%
tan-quot97.9%
Applied egg-rr97.9%
unpow297.9%
Simplified97.9%
Final simplification75.1%
(FPCore (x eps) :precision binary64 (if (<= eps -0.0105) (tan eps) (if (<= eps 0.118) (+ eps (* eps (pow (tan x) 2.0))) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0105) {
tmp = tan(eps);
} else if (eps <= 0.118) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = tan(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.0105d0)) then
tmp = tan(eps)
else if (eps <= 0.118d0) then
tmp = eps + (eps * (tan(x) ** 2.0d0))
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.0105) {
tmp = Math.tan(eps);
} else if (eps <= 0.118) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.0105: tmp = math.tan(eps) elif eps <= 0.118: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.0105) tmp = tan(eps); elseif (eps <= 0.118) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.0105) tmp = tan(eps); elseif (eps <= 0.118) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0105], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 0.118], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0105:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 0.118:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -0.0105000000000000007 or 0.11799999999999999 < eps Initial program 49.3%
Taylor expanded in x around 0 52.8%
tan-quot53.0%
expm1-log1p-u40.8%
expm1-udef40.4%
Applied egg-rr40.4%
expm1-def40.8%
expm1-log1p53.0%
Simplified53.0%
if -0.0105000000000000007 < eps < 0.11799999999999999Initial program 27.4%
tan-sum30.0%
div-inv30.0%
fma-neg30.0%
Applied egg-rr30.0%
fma-neg30.0%
associate-*r/30.0%
*-rgt-identity30.0%
Simplified30.0%
Taylor expanded in eps around 0 97.9%
cancel-sign-sub-inv97.9%
metadata-eval97.9%
*-lft-identity97.9%
Simplified97.9%
distribute-rgt-in98.0%
*-un-lft-identity98.0%
unpow298.0%
unpow298.0%
frac-times98.0%
tan-quot98.0%
tan-quot98.0%
pow298.0%
Applied egg-rr98.0%
Final simplification75.1%
(FPCore (x eps) :precision binary64 (sin eps))
double code(double x, double eps) {
return sin(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps)
end function
public static double code(double x, double eps) {
return Math.sin(eps);
}
def code(x, eps): return math.sin(eps)
function code(x, eps) return sin(eps) end
function tmp = code(x, eps) tmp = sin(eps); end
code[x_, eps_] := N[Sin[eps], $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon
\end{array}
Initial program 38.5%
Taylor expanded in x around 0 52.4%
add-sqr-sqrt28.7%
sqrt-unprod25.5%
pow225.5%
Applied egg-rr25.5%
unpow225.5%
rem-sqrt-square30.6%
Simplified30.6%
Taylor expanded in eps around 0 21.3%
rem-square-sqrt17.5%
fabs-sqr17.5%
rem-square-sqrt30.9%
Simplified30.9%
Final simplification30.9%
(FPCore (x eps) :precision binary64 (tan eps))
double code(double x, double eps) {
return tan(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan(eps)
end function
public static double code(double x, double eps) {
return Math.tan(eps);
}
def code(x, eps): return math.tan(eps)
function code(x, eps) return tan(eps) end
function tmp = code(x, eps) tmp = tan(eps); end
code[x_, eps_] := N[Tan[eps], $MachinePrecision]
\begin{array}{l}
\\
\tan \varepsilon
\end{array}
Initial program 38.5%
Taylor expanded in x around 0 52.4%
tan-quot52.5%
expm1-log1p-u46.3%
expm1-udef23.5%
Applied egg-rr23.5%
expm1-def46.3%
expm1-log1p52.5%
Simplified52.5%
Final simplification52.5%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 38.5%
sub-neg38.5%
+-commutative38.5%
add-log-exp38.0%
add-log-exp27.5%
sum-log27.6%
Applied egg-rr27.6%
Taylor expanded in eps around 0 4.2%
exp-neg4.1%
rgt-mult-inverse4.1%
metadata-eval4.1%
Simplified4.1%
Final simplification4.1%
(FPCore (x eps) :precision binary64 eps)
double code(double x, double eps) {
return eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps
end function
public static double code(double x, double eps) {
return eps;
}
def code(x, eps): return eps
function code(x, eps) return eps end
function tmp = code(x, eps) tmp = eps; end
code[x_, eps_] := eps
\begin{array}{l}
\\
\varepsilon
\end{array}
Initial program 38.5%
Taylor expanded in x around 0 52.4%
Taylor expanded in eps around 0 27.3%
Final simplification27.3%
(FPCore (x eps) :precision binary64 (/ (sin eps) (* (cos x) (cos (+ x eps)))))
double code(double x, double eps) {
return sin(eps) / (cos(x) * cos((x + eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / (cos(x) * cos((x + eps)))
end function
public static double code(double x, double eps) {
return Math.sin(eps) / (Math.cos(x) * Math.cos((x + eps)));
}
def code(x, eps): return math.sin(eps) / (math.cos(x) * math.cos((x + eps)))
function code(x, eps) return Float64(sin(eps) / Float64(cos(x) * cos(Float64(x + eps)))) end
function tmp = code(x, eps) tmp = sin(eps) / (cos(x) * cos((x + eps))); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}
\end{array}
herbie shell --seed 2023201
(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)))