
(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 8 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 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -3.4e-7)
(fma t_0 (/ 1.0 t_1) (- (tan x)))
(if (<= eps 2.3e-7)
(+
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
(* eps eps)
(+ (/ (pow (sin x) 3.0) (pow (cos x) 3.0)) (/ (sin x) (cos x)))))
(- (/ t_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 <= -3.4e-7) {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
} else if (eps <= 2.3e-7) {
tmp = (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + ((eps * eps) * ((pow(sin(x), 3.0) / pow(cos(x), 3.0)) + (sin(x) / cos(x))));
} else {
tmp = (t_0 / t_1) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -3.4e-7) tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); elseif (eps <= 2.3e-7) tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64(Float64(eps * eps) * Float64(Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0)) + Float64(sin(x) / cos(x))))); else tmp = Float64(Float64(t_0 / t_1) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.4e-7], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.3e-7], N[(N[(eps + N[(eps * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * eps), $MachinePrecision] * N[(N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.3 \cdot 10^{-7}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(\frac{{\sin x}^{3}}{{\cos x}^{3}} + \frac{\sin x}{\cos x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -3.39999999999999974e-7Initial program 58.7%
tan-sum99.6%
div-inv99.6%
fma-neg99.6%
Applied egg-rr99.6%
if -3.39999999999999974e-7 < eps < 2.29999999999999995e-7Initial program 35.9%
tan-sum36.7%
div-inv36.7%
fma-neg36.7%
Applied egg-rr36.7%
fma-neg36.7%
associate-*r/36.7%
*-rgt-identity36.7%
Simplified36.7%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
Simplified99.8%
if 2.29999999999999995e-7 < eps Initial program 56.0%
tan-sum99.5%
div-inv99.4%
fma-neg99.3%
Applied egg-rr99.3%
fma-neg99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -8.6e-9)
(fma t_0 (/ 1.0 t_1) (- (tan x)))
(if (<= eps 5.5e-17)
(fma (pow (tan x) 2.0) eps eps)
(- (/ t_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 <= -8.6e-9) {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
} else if (eps <= 5.5e-17) {
tmp = fma(pow(tan(x), 2.0), eps, eps);
} else {
tmp = (t_0 / t_1) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(x) + tan(eps)) t_1 = Float64(1.0 - Float64(tan(x) * tan(eps))) tmp = 0.0 if (eps <= -8.6e-9) tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); elseif (eps <= 5.5e-17) tmp = fma((tan(x) ^ 2.0), eps, eps); else tmp = Float64(Float64(t_0 / t_1) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -8.6e-9], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 5.5e-17], N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] * eps + eps), $MachinePrecision], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -8.6 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;\mathsf{fma}\left({\tan x}^{2}, \varepsilon, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -8.59999999999999925e-9Initial program 58.7%
tan-sum99.6%
div-inv99.6%
fma-neg99.6%
Applied egg-rr99.6%
if -8.59999999999999925e-9 < eps < 5.50000000000000001e-17Initial program 34.1%
add-cube-cbrt33.6%
pow333.6%
Applied egg-rr33.6%
Taylor expanded in eps around 0 97.9%
cancel-sign-sub-inv97.9%
metadata-eval97.9%
*-lft-identity97.9%
distribute-lft-in97.7%
*-rgt-identity97.7%
Simplified97.7%
rem-cube-cbrt99.7%
+-commutative99.7%
*-commutative99.7%
fma-def99.7%
add-sqr-sqrt99.6%
pow299.6%
sqrt-div99.7%
unpow299.7%
sqrt-prod50.2%
add-sqr-sqrt99.7%
unpow299.7%
sqrt-prod75.0%
add-sqr-sqrt99.7%
tan-quot99.7%
Applied egg-rr99.7%
if 5.50000000000000001e-17 < eps Initial program 58.1%
tan-sum98.9%
div-inv98.8%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.8%
associate-*r/98.9%
*-rgt-identity98.9%
Simplified98.9%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -8.6e-9) (not (<= eps 5.5e-17))) (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)) (fma (pow (tan x) 2.0) eps eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -8.6e-9) || !(eps <= 5.5e-17)) {
tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
} else {
tmp = fma(pow(tan(x), 2.0), eps, eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -8.6e-9) || !(eps <= 5.5e-17)) tmp = Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)); else tmp = fma((tan(x) ^ 2.0), eps, eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -8.6e-9], N[Not[LessEqual[eps, 5.5e-17]], $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[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] * eps + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -8.6 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 5.5 \cdot 10^{-17}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\tan x}^{2}, \varepsilon, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -8.59999999999999925e-9 or 5.50000000000000001e-17 < eps Initial program 58.5%
tan-sum99.3%
div-inv99.2%
fma-neg99.2%
Applied egg-rr99.2%
fma-neg99.2%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
if -8.59999999999999925e-9 < eps < 5.50000000000000001e-17Initial program 34.1%
add-cube-cbrt33.6%
pow333.6%
Applied egg-rr33.6%
Taylor expanded in eps around 0 97.9%
cancel-sign-sub-inv97.9%
metadata-eval97.9%
*-lft-identity97.9%
distribute-lft-in97.7%
*-rgt-identity97.7%
Simplified97.7%
rem-cube-cbrt99.7%
+-commutative99.7%
*-commutative99.7%
fma-def99.7%
add-sqr-sqrt99.6%
pow299.6%
sqrt-div99.7%
unpow299.7%
sqrt-prod50.2%
add-sqr-sqrt99.7%
unpow299.7%
sqrt-prod75.0%
add-sqr-sqrt99.7%
tan-quot99.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (<= eps -3.2e-6) (tan eps) (if (<= eps 1.8) (fma (pow (tan x) 2.0) eps eps) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -3.2e-6) {
tmp = tan(eps);
} else if (eps <= 1.8) {
tmp = fma(pow(tan(x), 2.0), eps, eps);
} else {
tmp = tan(eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -3.2e-6) tmp = tan(eps); elseif (eps <= 1.8) tmp = fma((tan(x) ^ 2.0), eps, eps); else tmp = tan(eps); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -3.2e-6], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1.8], N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] * eps + eps), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.2 \cdot 10^{-6}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left({\tan x}^{2}, \varepsilon, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -3.1999999999999999e-6 or 1.80000000000000004 < eps Initial program 58.0%
Taylor expanded in x around 0 60.3%
tan-quot60.6%
expm1-log1p-u45.2%
expm1-udef44.9%
Applied egg-rr44.9%
expm1-def45.2%
expm1-log1p60.6%
Simplified60.6%
if -3.1999999999999999e-6 < eps < 1.80000000000000004Initial program 35.7%
add-cube-cbrt35.1%
pow335.1%
Applied egg-rr35.1%
Taylor expanded in eps around 0 97.0%
cancel-sign-sub-inv97.0%
metadata-eval97.0%
*-lft-identity97.0%
distribute-lft-in96.8%
*-rgt-identity96.8%
Simplified96.8%
rem-cube-cbrt98.8%
+-commutative98.8%
*-commutative98.8%
fma-def98.7%
add-sqr-sqrt98.7%
pow298.7%
sqrt-div98.8%
unpow298.8%
sqrt-prod51.5%
add-sqr-sqrt98.8%
unpow298.8%
sqrt-prod75.1%
add-sqr-sqrt98.8%
tan-quot98.8%
Applied egg-rr98.8%
Final simplification80.2%
(FPCore (x eps) :precision binary64 (if (<= eps -8.5e-6) (tan eps) (if (<= eps 1.8) (* eps (+ (pow (tan x) 2.0) 1.0)) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -8.5e-6) {
tmp = tan(eps);
} else if (eps <= 1.8) {
tmp = eps * (pow(tan(x), 2.0) + 1.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 <= (-8.5d-6)) then
tmp = tan(eps)
else if (eps <= 1.8d0) then
tmp = eps * ((tan(x) ** 2.0d0) + 1.0d0)
else
tmp = tan(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -8.5e-6) {
tmp = Math.tan(eps);
} else if (eps <= 1.8) {
tmp = eps * (Math.pow(Math.tan(x), 2.0) + 1.0);
} else {
tmp = Math.tan(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -8.5e-6: tmp = math.tan(eps) elif eps <= 1.8: tmp = eps * (math.pow(math.tan(x), 2.0) + 1.0) else: tmp = math.tan(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -8.5e-6) tmp = tan(eps); elseif (eps <= 1.8) tmp = Float64(eps * Float64((tan(x) ^ 2.0) + 1.0)); else tmp = tan(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -8.5e-6) tmp = tan(eps); elseif (eps <= 1.8) tmp = eps * ((tan(x) ^ 2.0) + 1.0); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -8.5e-6], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1.8], N[(eps * N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -8.5 \cdot 10^{-6}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 1.8:\\
\;\;\;\;\varepsilon \cdot \left({\tan x}^{2} + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -8.4999999999999999e-6 or 1.80000000000000004 < eps Initial program 58.0%
Taylor expanded in x around 0 60.3%
tan-quot60.6%
expm1-log1p-u45.2%
expm1-udef44.9%
Applied egg-rr44.9%
expm1-def45.2%
expm1-log1p60.6%
Simplified60.6%
if -8.4999999999999999e-6 < eps < 1.80000000000000004Initial program 35.7%
add-cube-cbrt35.1%
pow335.1%
Applied egg-rr35.1%
Taylor expanded in eps around 0 97.0%
cancel-sign-sub-inv97.0%
metadata-eval97.0%
*-lft-identity97.0%
distribute-lft-in96.8%
*-rgt-identity96.8%
Simplified96.8%
rem-cube-cbrt98.8%
add-cube-cbrt97.3%
fma-def97.2%
pow297.2%
add-sqr-sqrt97.1%
pow297.1%
sqrt-div97.2%
unpow297.2%
sqrt-prod50.8%
add-sqr-sqrt97.2%
unpow297.2%
sqrt-prod73.8%
add-sqr-sqrt97.2%
tan-quot97.2%
Applied egg-rr97.2%
fma-udef97.3%
unpow297.3%
add-cube-cbrt98.8%
*-commutative98.8%
distribute-rgt1-in98.7%
Applied egg-rr98.7%
Final simplification80.1%
(FPCore (x eps) :precision binary64 (if (<= eps -1.8e-5) (tan eps) (if (<= eps 1.8) (+ eps (* eps (pow (tan x) 2.0))) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.8e-5) {
tmp = tan(eps);
} else if (eps <= 1.8) {
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 <= (-1.8d-5)) then
tmp = tan(eps)
else if (eps <= 1.8d0) 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 <= -1.8e-5) {
tmp = Math.tan(eps);
} else if (eps <= 1.8) {
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 <= -1.8e-5: tmp = math.tan(eps) elif eps <= 1.8: 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 <= -1.8e-5) tmp = tan(eps); elseif (eps <= 1.8) 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 <= -1.8e-5) tmp = tan(eps); elseif (eps <= 1.8) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.8e-5], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 1.8], 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 -1.8 \cdot 10^{-5}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 1.8:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -1.80000000000000005e-5 or 1.80000000000000004 < eps Initial program 58.0%
Taylor expanded in x around 0 60.3%
tan-quot60.6%
expm1-log1p-u45.2%
expm1-udef44.9%
Applied egg-rr44.9%
expm1-def45.2%
expm1-log1p60.6%
Simplified60.6%
if -1.80000000000000005e-5 < eps < 1.80000000000000004Initial program 35.7%
add-cube-cbrt35.1%
pow335.1%
Applied egg-rr35.1%
Taylor expanded in eps around 0 97.0%
cancel-sign-sub-inv97.0%
metadata-eval97.0%
*-lft-identity97.0%
distribute-lft-in96.8%
*-rgt-identity96.8%
Simplified96.8%
rem-cube-cbrt98.8%
+-commutative98.8%
add-sqr-sqrt98.7%
pow298.7%
sqrt-div98.7%
unpow298.7%
sqrt-prod51.5%
add-sqr-sqrt98.7%
unpow298.7%
sqrt-prod75.0%
add-sqr-sqrt98.7%
tan-quot98.8%
Applied egg-rr98.8%
Final simplification80.1%
(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 46.6%
Taylor expanded in x around 0 61.4%
tan-quot61.5%
expm1-log1p-u54.0%
expm1-udef25.5%
Applied egg-rr25.5%
expm1-def54.0%
expm1-log1p61.5%
Simplified61.5%
Final simplification61.5%
(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 46.6%
Taylor expanded in x around 0 61.4%
Taylor expanded in eps around 0 33.4%
Final simplification33.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 2023275
(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)))