
(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 10 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 eps) (tan x)))) (+ (/ (tan eps) (- 1.0 t_0)) (/ t_0 (- (/ 1.0 (tan x)) (tan eps))))))
double code(double x, double eps) {
double t_0 = tan(eps) * tan(x);
return (tan(eps) / (1.0 - t_0)) + (t_0 / ((1.0 / tan(x)) - tan(eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = tan(eps) * tan(x)
code = (tan(eps) / (1.0d0 - t_0)) + (t_0 / ((1.0d0 / tan(x)) - tan(eps)))
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) * Math.tan(x);
return (Math.tan(eps) / (1.0 - t_0)) + (t_0 / ((1.0 / Math.tan(x)) - Math.tan(eps)));
}
def code(x, eps): t_0 = math.tan(eps) * math.tan(x) return (math.tan(eps) / (1.0 - t_0)) + (t_0 / ((1.0 / math.tan(x)) - math.tan(eps)))
function code(x, eps) t_0 = Float64(tan(eps) * tan(x)) return Float64(Float64(tan(eps) / Float64(1.0 - t_0)) + Float64(t_0 / Float64(Float64(1.0 / tan(x)) - tan(eps)))) end
function tmp = code(x, eps) t_0 = tan(eps) * tan(x); tmp = (tan(eps) / (1.0 - t_0)) + (t_0 / ((1.0 / tan(x)) - tan(eps))); end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / N[(N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision] - N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon \cdot \tan x\\
\frac{\tan \varepsilon}{1 - t_0} + \frac{t_0}{\frac{1}{\tan x} - \tan \varepsilon}
\end{array}
\end{array}
Initial program 43.5%
tan-sum64.1%
div-inv64.0%
Applied egg-rr64.0%
associate-*r/64.1%
*-rgt-identity64.1%
Simplified64.1%
Taylor expanded in x around inf 63.9%
associate--l+79.1%
*-commutative79.1%
associate-/r*79.1%
*-commutative79.1%
associate-/l*79.1%
Simplified79.1%
clear-num76.4%
frac-sub76.7%
Applied egg-rr77.1%
associate--r-94.3%
rgt-mult-inverse99.5%
metadata-eval99.5%
metadata-eval99.5%
+-commutative99.5%
metadata-eval99.5%
div-sub99.5%
*-commutative99.5%
associate-/l*99.5%
*-rgt-identity99.5%
associate-*r/99.5%
rgt-mult-inverse99.5%
Simplified99.5%
*-un-lft-identity99.5%
associate-/r*99.5%
tan-quot99.6%
associate-/r/99.6%
associate-*r/99.6%
tan-quot99.7%
tan-quot99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -3.5e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 2.4e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(-
(/ t_0 (- 1.0 (/ (sin eps) (* (/ 1.0 (tan x)) (cos eps)))))
(tan x))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double tmp;
if (eps <= -3.5e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 2.4e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = (t_0 / (1.0 - (sin(eps) / ((1.0 / tan(x)) * cos(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(eps) + tan(x)
if (eps <= (-3.5d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 2.4d-9) then
tmp = eps + (eps * (tan(x) ** 2.0d0))
else
tmp = (t_0 / (1.0d0 - (sin(eps) / ((1.0d0 / tan(x)) * cos(eps))))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -3.5e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 2.4e-9) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = (t_0 / (1.0 - (Math.sin(eps) / ((1.0 / Math.tan(x)) * Math.cos(eps))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -3.5e-9: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 2.4e-9: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = (t_0 / (1.0 - (math.sin(eps) / ((1.0 / math.tan(x)) * math.cos(eps))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -3.5e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 2.4e-9) tmp = Float64(eps + Float64(eps * (tan(x) ^ 2.0))); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(sin(eps) / Float64(Float64(1.0 / tan(x)) * cos(eps))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -3.5e-9) tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 2.4e-9) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = (t_0 / (1.0 - (sin(eps) / ((1.0 / tan(x)) * cos(eps))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.5e-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, 2.4e-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[(N[Sin[eps], $MachinePrecision] / N[(N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -3.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\sin \varepsilon}{\frac{1}{\tan x} \cdot \cos \varepsilon}} - \tan x\\
\end{array}
\end{array}
if eps < -3.4999999999999999e-9Initial program 58.3%
tan-sum99.5%
div-inv99.4%
Applied egg-rr99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
log1p-expm1-u99.0%
Applied egg-rr99.0%
log1p-expm199.5%
remove-double-div99.5%
un-div-inv99.6%
Applied egg-rr99.6%
if -3.4999999999999999e-9 < eps < 2.4e-9Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
distribute-rgt-in99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-commutative99.5%
unpow299.5%
unpow299.5%
times-frac99.5%
tan-quot99.6%
tan-quot99.6%
unpow299.6%
Applied egg-rr99.6%
if 2.4e-9 < eps Initial program 54.8%
tan-sum99.5%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
log1p-expm1-u98.3%
Applied egg-rr98.3%
log1p-expm199.5%
/-rgt-identity99.5%
clear-num99.5%
tan-quot99.4%
frac-times99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))) (t_1 (- 1.0 (* (tan eps) (tan x)))))
(if (<= eps -3.5e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 2.8e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(- (* t_0 (/ 1.0 t_1)) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double t_1 = 1.0 - (tan(eps) * tan(x));
double tmp;
if (eps <= -3.5e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 2.8e-9) {
tmp = eps + (eps * pow(tan(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(eps) + tan(x)
t_1 = 1.0d0 - (tan(eps) * tan(x))
if (eps <= (-3.5d-9)) then
tmp = (t_0 / t_1) - tan(x)
else if (eps <= 2.8d-9) then
tmp = eps + (eps * (tan(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(eps) + Math.tan(x);
double t_1 = 1.0 - (Math.tan(eps) * Math.tan(x));
double tmp;
if (eps <= -3.5e-9) {
tmp = (t_0 / t_1) - Math.tan(x);
} else if (eps <= 2.8e-9) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = (t_0 * (1.0 / t_1)) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) + math.tan(x) t_1 = 1.0 - (math.tan(eps) * math.tan(x)) tmp = 0 if eps <= -3.5e-9: tmp = (t_0 / t_1) - math.tan(x) elif eps <= 2.8e-9: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = (t_0 * (1.0 / t_1)) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) t_1 = Float64(1.0 - Float64(tan(eps) * tan(x))) tmp = 0.0 if (eps <= -3.5e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 2.8e-9) tmp = Float64(eps + Float64(eps * (tan(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(eps) + tan(x); t_1 = 1.0 - (tan(eps) * tan(x)); tmp = 0.0; if (eps <= -3.5e-9) tmp = (t_0 / t_1) - tan(x); elseif (eps <= 2.8e-9) tmp = eps + (eps * (tan(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[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3.5e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.8e-9], N[(eps + N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $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 \varepsilon + \tan x\\
t_1 := 1 - \tan \varepsilon \cdot \tan x\\
\mathbf{if}\;\varepsilon \leq -3.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -3.4999999999999999e-9Initial program 58.3%
tan-sum99.5%
div-inv99.4%
Applied egg-rr99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
if -3.4999999999999999e-9 < eps < 2.79999999999999984e-9Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
distribute-rgt-in99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-commutative99.5%
unpow299.5%
unpow299.5%
times-frac99.5%
tan-quot99.6%
tan-quot99.6%
unpow299.6%
Applied egg-rr99.6%
if 2.79999999999999984e-9 < eps Initial program 54.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -1.75e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 3.2e-9)
(+ eps (* eps (pow (tan x) 2.0)))
(- (* t_0 (/ 1.0 (- 1.0 (* (tan eps) (tan x))))) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(eps) + tan(x);
double tmp;
if (eps <= -1.75e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 3.2e-9) {
tmp = eps + (eps * pow(tan(x), 2.0));
} else {
tmp = (t_0 * (1.0 / (1.0 - (tan(eps) * tan(x))))) - 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(eps) + tan(x)
if (eps <= (-1.75d-9)) then
tmp = (t_0 / (1.0d0 - (tan(x) / (1.0d0 / tan(eps))))) - tan(x)
else if (eps <= 3.2d-9) then
tmp = eps + (eps * (tan(x) ** 2.0d0))
else
tmp = (t_0 * (1.0d0 / (1.0d0 - (tan(eps) * tan(x))))) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.tan(eps) + Math.tan(x);
double tmp;
if (eps <= -1.75e-9) {
tmp = (t_0 / (1.0 - (Math.tan(x) / (1.0 / Math.tan(eps))))) - Math.tan(x);
} else if (eps <= 3.2e-9) {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
} else {
tmp = (t_0 * (1.0 / (1.0 - (Math.tan(eps) * Math.tan(x))))) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = math.tan(eps) + math.tan(x) tmp = 0 if eps <= -1.75e-9: tmp = (t_0 / (1.0 - (math.tan(x) / (1.0 / math.tan(eps))))) - math.tan(x) elif eps <= 3.2e-9: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) else: tmp = (t_0 * (1.0 / (1.0 - (math.tan(eps) * math.tan(x))))) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -1.75e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 3.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(eps) * tan(x))))) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = tan(eps) + tan(x); tmp = 0.0; if (eps <= -1.75e-9) tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x); elseif (eps <= 3.2e-9) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = (t_0 * (1.0 / (1.0 - (tan(eps) * tan(x))))) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.75e-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, 3.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[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -1.75 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\end{array}
\end{array}
if eps < -1.75e-9Initial program 58.3%
tan-sum99.5%
div-inv99.4%
Applied egg-rr99.4%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
log1p-expm1-u99.0%
Applied egg-rr99.0%
log1p-expm199.5%
remove-double-div99.5%
un-div-inv99.6%
Applied egg-rr99.6%
if -1.75e-9 < eps < 3.20000000000000012e-9Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
distribute-rgt-in99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-commutative99.5%
unpow299.5%
unpow299.5%
times-frac99.5%
tan-quot99.6%
tan-quot99.6%
unpow299.6%
Applied egg-rr99.6%
if 3.20000000000000012e-9 < eps Initial program 54.8%
tan-sum99.5%
div-inv99.6%
*-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.45e-9) (not (<= eps 3.4e-9))) (- (/ (+ (tan eps) (tan x)) (- 1.0 (* (tan eps) (tan x)))) (tan x)) (+ eps (* eps (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.45e-9) || !(eps <= 3.4e-9)) {
tmp = ((tan(eps) + tan(x)) / (1.0 - (tan(eps) * tan(x)))) - 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.4d-9))) then
tmp = ((tan(eps) + tan(x)) / (1.0d0 - (tan(eps) * tan(x)))) - 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.4e-9)) {
tmp = ((Math.tan(eps) + Math.tan(x)) / (1.0 - (Math.tan(eps) * Math.tan(x)))) - 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.4e-9): tmp = ((math.tan(eps) + math.tan(x)) / (1.0 - (math.tan(eps) * math.tan(x)))) - 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.4e-9)) tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / Float64(1.0 - Float64(tan(eps) * tan(x)))) - 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.4e-9))) tmp = ((tan(eps) + tan(x)) / (1.0 - (tan(eps) * tan(x)))) - 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.4e-9]], $MachinePrecision]], N[(N[(N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $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.4 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\end{array}
if eps < -3.44999999999999987e-9 or 3.3999999999999998e-9 < eps Initial program 56.4%
tan-sum99.5%
div-inv99.5%
Applied egg-rr99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
if -3.44999999999999987e-9 < eps < 3.3999999999999998e-9Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
distribute-rgt-in99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-commutative99.5%
unpow299.5%
unpow299.5%
times-frac99.5%
tan-quot99.6%
tan-quot99.6%
unpow299.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.35e-8) (not (<= eps 2.5e-6))) (/ (sin eps) (cos eps)) (* eps (+ 1.0 (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.35e-8) || !(eps <= 2.5e-6)) {
tmp = sin(eps) / cos(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 <= (-1.35d-8)) .or. (.not. (eps <= 2.5d-6))) then
tmp = sin(eps) / cos(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 <= -1.35e-8) || !(eps <= 2.5e-6)) {
tmp = Math.sin(eps) / Math.cos(eps);
} else {
tmp = eps * (1.0 + Math.pow(Math.tan(x), 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.35e-8) or not (eps <= 2.5e-6): tmp = math.sin(eps) / math.cos(eps) else: tmp = eps * (1.0 + math.pow(math.tan(x), 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.35e-8) || !(eps <= 2.5e-6)) tmp = Float64(sin(eps) / cos(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 <= -1.35e-8) || ~((eps <= 2.5e-6))) tmp = sin(eps) / cos(eps); else tmp = eps * (1.0 + (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.35e-8], N[Not[LessEqual[eps, 2.5e-6]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $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 -1.35 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 2.5 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + {\tan x}^{2}\right)\\
\end{array}
\end{array}
if eps < -1.35000000000000001e-8 or 2.5000000000000002e-6 < eps Initial program 56.4%
Taylor expanded in x around 0 58.4%
if -1.35000000000000001e-8 < eps < 2.5000000000000002e-6Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
pow199.3%
unpow299.3%
unpow299.3%
times-frac99.3%
tan-quot99.4%
tan-quot99.4%
unpow299.4%
Applied egg-rr99.4%
unpow199.4%
Simplified99.4%
Final simplification80.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.35e-8) (not (<= eps 3.7e-6))) (/ (sin eps) (cos eps)) (+ eps (* eps (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.35e-8) || !(eps <= 3.7e-6)) {
tmp = sin(eps) / cos(eps);
} 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.35d-8)) .or. (.not. (eps <= 3.7d-6))) then
tmp = sin(eps) / cos(eps)
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.35e-8) || !(eps <= 3.7e-6)) {
tmp = Math.sin(eps) / Math.cos(eps);
} else {
tmp = eps + (eps * Math.pow(Math.tan(x), 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.35e-8) or not (eps <= 3.7e-6): tmp = math.sin(eps) / math.cos(eps) else: tmp = eps + (eps * math.pow(math.tan(x), 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.35e-8) || !(eps <= 3.7e-6)) tmp = Float64(sin(eps) / cos(eps)); 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.35e-8) || ~((eps <= 3.7e-6))) tmp = sin(eps) / cos(eps); else tmp = eps + (eps * (tan(x) ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.35e-8], N[Not[LessEqual[eps, 3.7e-6]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $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.35 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 3.7 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\end{array}
if eps < -1.35000000000000001e-8 or 3.7000000000000002e-6 < eps Initial program 56.4%
Taylor expanded in x around 0 58.4%
if -1.35000000000000001e-8 < eps < 3.7000000000000002e-6Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
distribute-rgt-in99.5%
*-un-lft-identity99.5%
+-commutative99.5%
*-commutative99.5%
unpow299.5%
unpow299.5%
times-frac99.5%
tan-quot99.6%
tan-quot99.6%
unpow299.6%
Applied egg-rr99.6%
Final simplification80.1%
(FPCore (x eps) :precision binary64 (/ (sin eps) (cos eps)))
double code(double x, double eps) {
return sin(eps) / cos(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / cos(eps)
end function
public static double code(double x, double eps) {
return Math.sin(eps) / Math.cos(eps);
}
def code(x, eps): return math.sin(eps) / math.cos(eps)
function code(x, eps) return Float64(sin(eps) / cos(eps)) end
function tmp = code(x, eps) tmp = sin(eps) / cos(eps); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos \varepsilon}
\end{array}
Initial program 43.5%
Taylor expanded in x around 0 59.7%
Final simplification59.7%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.35e-8) (not (<= eps 6.6e-7))) (- (tan (+ eps x)) x) eps))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.35e-8) || !(eps <= 6.6e-7)) {
tmp = tan((eps + x)) - x;
} else {
tmp = 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.35d-8)) .or. (.not. (eps <= 6.6d-7))) then
tmp = tan((eps + x)) - x
else
tmp = eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.35e-8) || !(eps <= 6.6e-7)) {
tmp = Math.tan((eps + x)) - x;
} else {
tmp = eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.35e-8) or not (eps <= 6.6e-7): tmp = math.tan((eps + x)) - x else: tmp = eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.35e-8) || !(eps <= 6.6e-7)) tmp = Float64(tan(Float64(eps + x)) - x); else tmp = eps; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.35e-8) || ~((eps <= 6.6e-7))) tmp = tan((eps + x)) - x; else tmp = eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.35e-8], N[Not[LessEqual[eps, 6.6e-7]], $MachinePrecision]], N[(N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision], eps]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.35 \cdot 10^{-8} \lor \neg \left(\varepsilon \leq 6.6 \cdot 10^{-7}\right):\\
\;\;\;\;\tan \left(\varepsilon + x\right) - x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon\\
\end{array}
\end{array}
if eps < -1.35000000000000001e-8 or 6.6000000000000003e-7 < eps Initial program 56.4%
Taylor expanded in x around 0 53.0%
if -1.35000000000000001e-8 < eps < 6.6000000000000003e-7Initial program 32.0%
Taylor expanded in eps around 0 99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 60.9%
Final simplification57.2%
(FPCore (x eps) :precision binary64 eps)
double code(double x, double eps) {
return eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps
end function
public static double code(double x, double eps) {
return eps;
}
def code(x, eps): return eps
function code(x, eps) return eps end
function tmp = code(x, eps) tmp = eps; end
code[x_, eps_] := eps
\begin{array}{l}
\\
\varepsilon
\end{array}
Initial program 43.5%
Taylor expanded in eps around 0 55.1%
sub-neg55.1%
mul-1-neg55.1%
remove-double-neg55.1%
Simplified55.1%
Taylor expanded in x around 0 34.9%
Final simplification34.9%
(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 2023336
(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)))