
(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 11 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))))
(if (<= eps -4.7e-9)
(fma (/ 1.0 t_0) t_1 (- (tan x)))
(if (<= eps 1.25e-26)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_1 t_0) (pow (/ 1.0 (tan x)) -1.0))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -4.7e-9) {
tmp = fma((1.0 / t_0), t_1, -tan(x));
} else if (eps <= 1.25e-26) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_1 / t_0) - pow((1.0 / tan(x)), -1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4.7e-9) tmp = fma(Float64(1.0 / t_0), t_1, Float64(-tan(x))); elseif (eps <= 1.25e-26) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_1 / t_0) - (Float64(1.0 / tan(x)) ^ -1.0)); 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]}, If[LessEqual[eps, -4.7e-9], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 1.25e-26], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Power[N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.7 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{t_0}, t_1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.25 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - {\left(\frac{1}{\tan x}\right)}^{-1}\\
\end{array}
\end{array}
if eps < -4.6999999999999999e-9Initial program 50.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
*-commutative99.6%
fma-neg99.6%
Applied egg-rr99.6%
if -4.6999999999999999e-9 < eps < 1.25000000000000005e-26Initial program 31.8%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.7%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
if 1.25000000000000005e-26 < eps Initial program 59.0%
tan-sum99.1%
div-inv99.0%
tan-quot98.9%
div-inv98.8%
prod-diff98.8%
Applied egg-rr98.8%
+-commutative98.8%
fma-udef98.8%
associate-+r+98.9%
unsub-neg98.9%
Simplified98.9%
clear-num99.0%
inv-pow99.0%
clear-num99.0%
tan-quot99.1%
Applied egg-rr99.1%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (let* ((t_0 (* (tan x) (tan eps))) (t_1 (- 1.0 t_0))) (+ (/ (/ (sin eps) (cos eps)) t_1) (* (tan x) (/ t_0 t_1)))))
double code(double x, double eps) {
double t_0 = tan(x) * tan(eps);
double t_1 = 1.0 - t_0;
return ((sin(eps) / cos(eps)) / t_1) + (tan(x) * (t_0 / t_1));
}
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 = 1.0d0 - t_0
code = ((sin(eps) / cos(eps)) / t_1) + (tan(x) * (t_0 / t_1))
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(x) * Math.tan(eps);
double t_1 = 1.0 - t_0;
return ((Math.sin(eps) / Math.cos(eps)) / t_1) + (Math.tan(x) * (t_0 / t_1));
}
def code(x, eps): t_0 = math.tan(x) * math.tan(eps) t_1 = 1.0 - t_0 return ((math.sin(eps) / math.cos(eps)) / t_1) + (math.tan(x) * (t_0 / t_1))
function code(x, eps) t_0 = Float64(tan(x) * tan(eps)) t_1 = Float64(1.0 - t_0) return Float64(Float64(Float64(sin(eps) / cos(eps)) / t_1) + Float64(tan(x) * Float64(t_0 / t_1))) end
function tmp = code(x, eps) t_0 = tan(x) * tan(eps); t_1 = 1.0 - t_0; tmp = ((sin(eps) / cos(eps)) / t_1) + (tan(x) * (t_0 / t_1)); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, N[(N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan \varepsilon\\
t_1 := 1 - t_0\\
\frac{\frac{\sin \varepsilon}{\cos \varepsilon}}{t_1} + \tan x \cdot \frac{t_0}{t_1}
\end{array}
\end{array}
Initial program 44.0%
tan-sum68.5%
div-inv68.5%
Applied egg-rr68.5%
Taylor expanded in x around inf 68.2%
associate--l+83.4%
associate-/r*83.3%
times-frac83.3%
Simplified83.4%
tan-quot82.4%
clear-num80.9%
frac-sub80.2%
Applied egg-rr81.4%
associate-/r/81.4%
rgt-mult-inverse83.4%
associate--r-99.4%
metadata-eval99.4%
+-lft-identity99.4%
*-commutative99.4%
*-commutative99.4%
Simplified99.4%
clear-num99.4%
clear-num99.4%
frac-times99.5%
metadata-eval99.5%
clear-num99.5%
tan-quot99.4%
clear-num99.4%
tan-quot99.5%
Applied egg-rr99.5%
associate-/r*99.5%
remove-double-div99.4%
associate-/r/99.5%
/-rgt-identity99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps)))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -4.1e-9)
(fma (/ 1.0 t_0) t_1 (- (tan x)))
(if (<= eps 1.25e-26)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_1 t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -4.1e-9) {
tmp = fma((1.0 / t_0), t_1, -tan(x));
} else if (eps <= 1.25e-26) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_1 / t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4.1e-9) tmp = fma(Float64(1.0 / t_0), t_1, Float64(-tan(x))); elseif (eps <= 1.25e-26) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_1 / t_0) - tan(x)); 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]}, If[LessEqual[eps, -4.1e-9], N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 1.25e-26], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{t_0}, t_1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 1.25 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -4.1000000000000003e-9Initial program 50.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
*-commutative99.6%
fma-neg99.6%
Applied egg-rr99.6%
if -4.1000000000000003e-9 < eps < 1.25000000000000005e-26Initial program 31.8%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.7%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
if 1.25000000000000005e-26 < eps Initial program 59.0%
tan-sum99.1%
div-inv99.0%
*-un-lft-identity99.0%
prod-diff98.9%
*-commutative98.9%
*-un-lft-identity98.9%
*-commutative98.9%
*-un-lft-identity98.9%
Applied egg-rr98.9%
+-commutative98.9%
fma-udef99.0%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.1%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.3e-9) (not (<= eps 1.25e-26))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.3e-9) || !(eps <= 1.25e-26)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.3e-9) || !(eps <= 1.25e-26)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.3e-9], N[Not[LessEqual[eps, 1.25e-26]], $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[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.3 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 1.25 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -3.30000000000000018e-9 or 1.25000000000000005e-26 < eps Initial program 54.3%
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%
if -3.30000000000000018e-9 < eps < 1.25000000000000005e-26Initial program 31.8%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.7%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps)))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -4e-9)
(- (* (/ 1.0 t_0) t_1) (tan x))
(if (<= eps 1.25e-26)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_1 t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -4e-9) {
tmp = ((1.0 / t_0) * t_1) - tan(x);
} else if (eps <= 1.25e-26) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_1 / t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -4e-9) tmp = Float64(Float64(Float64(1.0 / t_0) * t_1) - tan(x)); elseif (eps <= 1.25e-26) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_1 / t_0) - tan(x)); 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]}, If[LessEqual[eps, -4e-9], N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.25e-26], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{t_0} \cdot t_1 - \tan x\\
\mathbf{elif}\;\varepsilon \leq 1.25 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -4.00000000000000025e-9Initial program 50.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
if -4.00000000000000025e-9 < eps < 1.25000000000000005e-26Initial program 31.8%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.7%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
if 1.25000000000000005e-26 < eps Initial program 59.0%
tan-sum99.1%
div-inv99.0%
*-un-lft-identity99.0%
prod-diff98.9%
*-commutative98.9%
*-un-lft-identity98.9%
*-commutative98.9%
*-un-lft-identity98.9%
Applied egg-rr98.9%
+-commutative98.9%
fma-udef99.0%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.1%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan x) (tan eps)))) (t_1 (+ (tan x) (tan eps))))
(if (<= eps -5e-9)
(- (/ 1.0 (/ t_0 t_1)) (tan x))
(if (<= eps 1.25e-26)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_1 t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(x) * tan(eps));
double t_1 = tan(x) + tan(eps);
double tmp;
if (eps <= -5e-9) {
tmp = (1.0 / (t_0 / t_1)) - tan(x);
} else if (eps <= 1.25e-26) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_1 / t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(x) * tan(eps))) t_1 = Float64(tan(x) + tan(eps)) tmp = 0.0 if (eps <= -5e-9) tmp = Float64(Float64(1.0 / Float64(t_0 / t_1)) - tan(x)); elseif (eps <= 1.25e-26) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_1 / t_0) - tan(x)); 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]}, If[LessEqual[eps, -5e-9], N[(N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.25e-26], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan x \cdot \tan \varepsilon\\
t_1 := \tan x + \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -5 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\frac{t_0}{t_1}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 1.25 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -5.0000000000000001e-9Initial program 50.9%
tan-sum99.6%
clear-num99.6%
Applied egg-rr99.6%
if -5.0000000000000001e-9 < eps < 1.25000000000000005e-26Initial program 31.8%
Taylor expanded in eps around 0 99.7%
cancel-sign-sub-inv99.7%
metadata-eval99.7%
*-lft-identity99.7%
Simplified99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
unpow299.7%
unpow299.7%
frac-times99.7%
tan-quot99.7%
tan-quot99.7%
pow299.7%
Applied egg-rr99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
if 1.25000000000000005e-26 < eps Initial program 59.0%
tan-sum99.1%
div-inv99.0%
*-un-lft-identity99.0%
prod-diff98.9%
*-commutative98.9%
*-un-lft-identity98.9%
*-commutative98.9%
*-un-lft-identity98.9%
Applied egg-rr98.9%
+-commutative98.9%
fma-udef99.0%
associate-+r+99.0%
unsub-neg99.0%
Simplified99.1%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.1e-6) (not (<= eps 1.35e-5))) (tan eps) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-6) || !(eps <= 1.35e-5)) {
tmp = tan(eps);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -1.1e-6) || !(eps <= 1.35e-5)) tmp = tan(eps); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -1.1e-6], N[Not[LessEqual[eps, 1.35e-5]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 1.35 \cdot 10^{-5}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.1000000000000001e-6 or 1.3499999999999999e-5 < eps Initial program 54.3%
Taylor expanded in x around 0 56.9%
tan-quot57.2%
expm1-log1p-u41.1%
expm1-udef40.7%
Applied egg-rr40.7%
expm1-def41.1%
expm1-log1p57.2%
Simplified57.2%
if -1.1000000000000001e-6 < eps < 1.3499999999999999e-5Initial program 32.1%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
distribute-lft-in99.4%
*-rgt-identity99.4%
unpow299.4%
unpow299.4%
frac-times99.4%
tan-quot99.4%
tan-quot99.4%
pow299.4%
Applied egg-rr99.4%
+-commutative99.4%
fma-def99.5%
Simplified99.5%
Final simplification76.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -9.2e-6) (not (<= eps 7.4e-6))) (tan eps) (* eps (+ 1.0 (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -9.2e-6) || !(eps <= 7.4e-6)) {
tmp = tan(eps);
} else {
tmp = eps * (1.0 + 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 <= (-9.2d-6)) .or. (.not. (eps <= 7.4d-6))) then
tmp = tan(eps)
else
tmp = eps * (1.0d0 + (tan(x) ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -9.2e-6) || !(eps <= 7.4e-6)) {
tmp = Math.tan(eps);
} else {
tmp = eps * (1.0 + Math.pow(Math.tan(x), 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -9.2e-6) or not (eps <= 7.4e-6): tmp = math.tan(eps) else: tmp = eps * (1.0 + math.pow(math.tan(x), 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -9.2e-6) || !(eps <= 7.4e-6)) tmp = tan(eps); else tmp = Float64(eps * Float64(1.0 + (tan(x) ^ 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -9.2e-6) || ~((eps <= 7.4e-6))) tmp = tan(eps); else tmp = eps * (1.0 + (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -9.2e-6], N[Not[LessEqual[eps, 7.4e-6]], $MachinePrecision]], N[Tan[eps], $MachinePrecision], N[(eps * N[(1.0 + N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -9.2 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 7.4 \cdot 10^{-6}\right):\\
\;\;\;\;\tan \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + {\tan x}^{2}\right)\\
\end{array}
\end{array}
if eps < -9.2e-6 or 7.4000000000000003e-6 < eps Initial program 54.3%
Taylor expanded in x around 0 56.9%
tan-quot57.2%
expm1-log1p-u41.1%
expm1-udef40.7%
Applied egg-rr40.7%
expm1-def41.1%
expm1-log1p57.2%
Simplified57.2%
if -9.2e-6 < eps < 7.4000000000000003e-6Initial program 32.1%
Taylor expanded in eps around 0 99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
*-lft-identity99.4%
Simplified99.4%
distribute-lft-in99.4%
*-rgt-identity99.4%
unpow299.4%
unpow299.4%
frac-times99.4%
tan-quot99.4%
tan-quot99.4%
pow299.4%
Applied egg-rr99.4%
*-rgt-identity99.4%
distribute-lft-in99.4%
Simplified99.4%
Final simplification76.8%
(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 44.0%
Taylor expanded in x around 0 60.6%
tan-quot60.8%
expm1-log1p-u52.1%
expm1-udef24.9%
Applied egg-rr24.9%
expm1-def52.1%
expm1-log1p60.8%
Simplified60.8%
Final simplification60.8%
(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 44.0%
add-cube-cbrt43.2%
pow343.1%
Applied egg-rr43.1%
Taylor expanded in eps around 0 4.1%
pow-base-14.1%
*-lft-identity4.1%
+-inverses4.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 44.0%
Taylor expanded in x around 0 60.6%
Taylor expanded in eps around 0 32.4%
Final simplification32.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 2023310
(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)))