
(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 17 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)))
(t_1 (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0)))))
(if (<= eps -1.4e-7)
(-
(/
(- t_0 (tan eps))
(+ -1.0 (/ (* (sin eps) (sin x)) (* (cos eps) (cos x)))))
(tan x))
(if (<= eps 8e-13)
(fma eps t_1 (/ (pow eps 2.0) (/ (/ (cos x) (sin x)) t_1)))
(+
(fma -1.0 (tan x) (tan x))
(fma
(+ (tan x) (tan eps))
(/ 1.0 (- 1.0 (/ (* (sin eps) (tan x)) (cos eps))))
t_0))))))
double code(double x, double eps) {
double t_0 = -tan(x);
double t_1 = 1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0));
double tmp;
if (eps <= -1.4e-7) {
tmp = ((t_0 - tan(eps)) / (-1.0 + ((sin(eps) * sin(x)) / (cos(eps) * cos(x))))) - tan(x);
} else if (eps <= 8e-13) {
tmp = fma(eps, t_1, (pow(eps, 2.0) / ((cos(x) / sin(x)) / t_1)));
} else {
tmp = fma(-1.0, tan(x), tan(x)) + fma((tan(x) + tan(eps)), (1.0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) t_1 = Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0))) tmp = 0.0 if (eps <= -1.4e-7) tmp = Float64(Float64(Float64(t_0 - tan(eps)) / Float64(-1.0 + Float64(Float64(sin(eps) * sin(x)) / Float64(cos(eps) * cos(x))))) - tan(x)); elseif (eps <= 8e-13) tmp = fma(eps, t_1, Float64((eps ^ 2.0) / Float64(Float64(cos(x) / sin(x)) / t_1))); else tmp = Float64(fma(-1.0, tan(x), tan(x)) + fma(Float64(tan(x) + tan(eps)), Float64(1.0 / Float64(1.0 - Float64(Float64(sin(eps) * tan(x)) / cos(eps)))), t_0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, Block[{t$95$1 = N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.4e-7], N[(N[(N[(t$95$0 - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-13], N[(eps * t$95$1 + N[(N[Power[eps, 2.0], $MachinePrecision] / N[(N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
t_1 := 1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\\
\mathbf{if}\;\varepsilon \leq -1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_0 - \tan \varepsilon}{-1 + \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, t_1, \frac{{\varepsilon}^{2}}{\frac{\frac{\cos x}{\sin x}}{t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \tan x, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}}, t_0\right)\\
\end{array}
\end{array}
if eps < -1.4000000000000001e-7Initial program 61.1%
tan-quot61.0%
clear-num60.9%
Applied egg-rr60.9%
clear-num61.0%
tan-quot61.0%
tan-sum99.2%
clear-num99.1%
associate-/r/99.4%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.4%
associate-*l/99.4%
mul-1-neg99.4%
+-commutative99.4%
metadata-eval99.4%
sub-neg99.4%
fma-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 99.5%
if -1.4000000000000001e-7 < eps < 8.0000000000000002e-13Initial program 31.5%
Taylor expanded in eps around 0 99.6%
fma-def99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
associate-/l*99.6%
associate-/r*99.6%
cancel-sign-sub-inv99.6%
metadata-eval99.6%
*-lft-identity99.6%
Simplified99.6%
if 8.0000000000000002e-13 < eps Initial program 56.9%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
*-commutative99.6%
prod-diff99.6%
*-un-lft-identity99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin eps) (cos eps))))
(+
(+
(/ t_0 (- 1.0 (* t_0 (/ (sin x) (cos x)))))
(/ (* (tan x) (tan eps)) (- (/ 1.0 (tan x)) (tan eps))))
(fma -1.0 (tan x) (tan x)))))
double code(double x, double eps) {
double t_0 = sin(eps) / cos(eps);
return ((t_0 / (1.0 - (t_0 * (sin(x) / cos(x))))) + ((tan(x) * tan(eps)) / ((1.0 / tan(x)) - tan(eps)))) + fma(-1.0, tan(x), tan(x));
}
function code(x, eps) t_0 = Float64(sin(eps) / cos(eps)) return Float64(Float64(Float64(t_0 / Float64(1.0 - Float64(t_0 * Float64(sin(x) / cos(x))))) + Float64(Float64(tan(x) * tan(eps)) / Float64(Float64(1.0 / tan(x)) - tan(eps)))) + fma(-1.0, tan(x), tan(x))) end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 / N[(1.0 - N[(t$95$0 * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision] - N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin \varepsilon}{\cos \varepsilon}\\
\left(\frac{t_0}{1 - t_0 \cdot \frac{\sin x}{\cos x}} + \frac{\tan x \cdot \tan \varepsilon}{\frac{1}{\tan x} - \tan \varepsilon}\right) + \mathsf{fma}\left(-1, \tan x, \tan x\right)
\end{array}
\end{array}
Initial program 45.9%
tan-sum67.9%
div-inv67.9%
*-un-lft-identity67.9%
*-commutative67.9%
prod-diff67.9%
*-un-lft-identity67.9%
metadata-eval67.9%
*-un-lft-identity67.9%
Applied egg-rr67.9%
Taylor expanded in x around inf 67.7%
associate--l+82.1%
associate-/r*82.1%
times-frac82.1%
Simplified82.2%
tan-quot81.2%
add-log-exp81.5%
tan-quot82.2%
tan-quot82.2%
tan-quot82.2%
*-commutative82.2%
Applied egg-rr82.2%
rem-log-exp82.2%
tan-quot81.3%
clear-num80.2%
frac-sub79.3%
clear-num79.6%
tan-quot80.2%
clear-num80.2%
tan-quot80.2%
div-inv80.2%
Applied egg-rr80.2%
rgt-mult-inverse82.2%
*-rgt-identity82.2%
cancel-sign-sub-inv82.2%
*-commutative82.2%
associate--r+99.5%
metadata-eval99.5%
neg-sub099.5%
distribute-rgt-neg-out99.5%
*-commutative99.5%
remove-double-neg99.5%
div-sub99.6%
*-rgt-identity99.6%
times-frac99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x))))
(if (<= eps -1.7e-7)
(-
(/
(- t_0 (tan eps))
(+ -1.0 (/ (* (sin eps) (sin x)) (* (cos eps) (cos x)))))
(tan x))
(if (<= eps 8e-13)
(+
(* eps (+ 1.0 (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(*
(pow eps 2.0)
(+ (/ (sin x) (cos x)) (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(+
(fma -1.0 (tan x) (tan x))
(fma
(+ (tan x) (tan eps))
(/ 1.0 (- 1.0 (/ (* (sin eps) (tan x)) (cos eps))))
t_0))))))
double code(double x, double eps) {
double t_0 = -tan(x);
double tmp;
if (eps <= -1.7e-7) {
tmp = ((t_0 - tan(eps)) / (-1.0 + ((sin(eps) * sin(x)) / (cos(eps) * cos(x))))) - tan(x);
} else if (eps <= 8e-13) {
tmp = (eps * (1.0 + (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + (pow(eps, 2.0) * ((sin(x) / cos(x)) + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = fma(-1.0, tan(x), tan(x)) + fma((tan(x) + tan(eps)), (1.0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) tmp = 0.0 if (eps <= -1.7e-7) tmp = Float64(Float64(Float64(t_0 - tan(eps)) / Float64(-1.0 + Float64(Float64(sin(eps) * sin(x)) / Float64(cos(eps) * cos(x))))) - tan(x)); elseif (eps <= 8e-13) tmp = Float64(Float64(eps * Float64(1.0 + Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64((eps ^ 2.0) * Float64(Float64(sin(x) / cos(x)) + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(fma(-1.0, tan(x), tan(x)) + fma(Float64(tan(x) + tan(eps)), Float64(1.0 / Float64(1.0 - Float64(Float64(sin(eps) * tan(x)) / cos(eps)))), t_0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, If[LessEqual[eps, -1.7e-7], N[(N[(N[(t$95$0 - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-13], N[(N[(eps * N[(1.0 + N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
\mathbf{if}\;\varepsilon \leq -1.7 \cdot 10^{-7}:\\
\;\;\;\;\frac{t_0 - \tan \varepsilon}{-1 + \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\varepsilon \cdot \left(1 + \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + {\varepsilon}^{2} \cdot \left(\frac{\sin x}{\cos x} + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \tan x, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}}, t_0\right)\\
\end{array}
\end{array}
if eps < -1.69999999999999987e-7Initial program 61.1%
tan-quot61.0%
clear-num60.9%
Applied egg-rr60.9%
clear-num61.0%
tan-quot61.0%
tan-sum99.2%
clear-num99.1%
associate-/r/99.4%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.4%
associate-*l/99.4%
mul-1-neg99.4%
+-commutative99.4%
metadata-eval99.4%
sub-neg99.4%
fma-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 99.5%
if -1.69999999999999987e-7 < eps < 8.0000000000000002e-13Initial program 31.5%
tan-sum32.6%
clear-num32.5%
Applied egg-rr32.5%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
sub-neg99.6%
mul-1-neg99.6%
remove-double-neg99.6%
Simplified99.6%
if 8.0000000000000002e-13 < eps Initial program 56.9%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
*-commutative99.6%
prod-diff99.6%
*-un-lft-identity99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan x))))
(if (<= eps -3.6e-9)
(-
(/
(- t_0 (tan eps))
(+ -1.0 (/ (* (sin eps) (sin x)) (* (cos eps) (cos x)))))
(tan x))
(if (<= eps 8e-13)
(fma eps (pow (tan x) 2.0) eps)
(+
(fma -1.0 (tan x) (tan x))
(fma
(+ (tan x) (tan eps))
(/ 1.0 (- 1.0 (/ (* (sin eps) (tan x)) (cos eps))))
t_0))))))
double code(double x, double eps) {
double t_0 = -tan(x);
double tmp;
if (eps <= -3.6e-9) {
tmp = ((t_0 - tan(eps)) / (-1.0 + ((sin(eps) * sin(x)) / (cos(eps) * cos(x))))) - tan(x);
} else if (eps <= 8e-13) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = fma(-1.0, tan(x), tan(x)) + fma((tan(x) + tan(eps)), (1.0 / (1.0 - ((sin(eps) * tan(x)) / cos(eps)))), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(-tan(x)) tmp = 0.0 if (eps <= -3.6e-9) tmp = Float64(Float64(Float64(t_0 - tan(eps)) / Float64(-1.0 + Float64(Float64(sin(eps) * sin(x)) / Float64(cos(eps) * cos(x))))) - tan(x)); elseif (eps <= 8e-13) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(fma(-1.0, tan(x), tan(x)) + fma(Float64(tan(x) + tan(eps)), Float64(1.0 / Float64(1.0 - Float64(Float64(sin(eps) * tan(x)) / cos(eps)))), t_0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Tan[x], $MachinePrecision])}, If[LessEqual[eps, -3.6e-9], N[(N[(N[(t$95$0 - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-13], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(-1.0 * N[Tan[x], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\tan x\\
\mathbf{if}\;\varepsilon \leq -3.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0 - \tan \varepsilon}{-1 + \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \tan x, \tan x\right) + \mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{1}{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}}, t_0\right)\\
\end{array}
\end{array}
if eps < -3.6e-9Initial program 61.1%
tan-quot61.0%
clear-num60.9%
Applied egg-rr60.9%
clear-num61.0%
tan-quot61.0%
tan-sum99.2%
clear-num99.1%
associate-/r/99.4%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.4%
associate-*l/99.4%
mul-1-neg99.4%
+-commutative99.4%
metadata-eval99.4%
sub-neg99.4%
fma-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 99.5%
if -3.6e-9 < eps < 8.0000000000000002e-13Initial program 31.5%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
Simplified99.1%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.2%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
*-commutative99.2%
fma-def99.2%
Simplified99.2%
if 8.0000000000000002e-13 < eps Initial program 56.9%
tan-sum99.6%
div-inv99.6%
*-un-lft-identity99.6%
*-commutative99.6%
prod-diff99.6%
*-un-lft-identity99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(if (<= eps -4.2e-9)
(-
(/
(- (- (tan x)) (tan eps))
(+ -1.0 (/ (* (sin eps) (sin x)) (* (cos eps) (cos x)))))
(tan x))
(if (<= eps 8e-13)
(fma eps (pow (tan x) 2.0) eps)
(-
(* (+ (tan x) (tan eps)) (/ 1.0 (- 1.0 (* (tan x) (tan eps)))))
(tan x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -4.2e-9) {
tmp = ((-tan(x) - tan(eps)) / (-1.0 + ((sin(eps) * sin(x)) / (cos(eps) * cos(x))))) - tan(x);
} else if (eps <= 8e-13) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = ((tan(x) + tan(eps)) * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -4.2e-9) tmp = Float64(Float64(Float64(Float64(-tan(x)) - tan(eps)) / Float64(-1.0 + Float64(Float64(sin(eps) * sin(x)) / Float64(cos(eps) * cos(x))))) - tan(x)); elseif (eps <= 8e-13) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(Float64(tan(x) + tan(eps)) * Float64(1.0 / Float64(1.0 - Float64(tan(x) * tan(eps))))) - tan(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -4.2e-9], N[(N[(N[((-N[Tan[x], $MachinePrecision]) - N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-13], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -4.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\left(-\tan x\right) - \tan \varepsilon}{-1 + \frac{\sin \varepsilon \cdot \sin x}{\cos \varepsilon \cdot \cos x}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\end{array}
\end{array}
if eps < -4.20000000000000039e-9Initial program 61.1%
tan-quot61.0%
clear-num60.9%
Applied egg-rr60.9%
clear-num61.0%
tan-quot61.0%
tan-sum99.2%
clear-num99.1%
associate-/r/99.4%
distribute-lft-in99.4%
Applied egg-rr99.4%
distribute-lft-in99.4%
associate-*l/99.4%
mul-1-neg99.4%
+-commutative99.4%
metadata-eval99.4%
sub-neg99.4%
fma-neg99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 99.5%
if -4.20000000000000039e-9 < eps < 8.0000000000000002e-13Initial program 31.5%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
Simplified99.1%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.2%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
*-commutative99.2%
fma-def99.2%
Simplified99.2%
if 8.0000000000000002e-13 < eps Initial program 56.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps)))
(t_1 (/ 1.0 (- 1.0 (* (tan x) (tan eps))))))
(if (<= eps -5.8e-9)
(fma t_0 t_1 (- (tan x)))
(if (<= eps 8e-13)
(fma eps (pow (tan x) 2.0) 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 / (1.0 - (tan(x) * tan(eps)));
double tmp;
if (eps <= -5.8e-9) {
tmp = fma(t_0, t_1, -tan(x));
} else if (eps <= 8e-13) {
tmp = fma(eps, pow(tan(x), 2.0), 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(1.0 - Float64(tan(x) * tan(eps)))) tmp = 0.0 if (eps <= -5.8e-9) tmp = fma(t_0, t_1, Float64(-tan(x))); elseif (eps <= 8e-13) tmp = fma(eps, (tan(x) ^ 2.0), 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[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.8e-9], N[(t$95$0 * t$95$1 + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 8e-13], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + 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 := \frac{1}{1 - \tan x \cdot \tan \varepsilon}\\
\mathbf{if}\;\varepsilon \leq -5.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot t_1 - \tan x\\
\end{array}
\end{array}
if eps < -5.79999999999999982e-9Initial program 61.1%
tan-sum99.4%
div-inv99.4%
tan-quot99.3%
div-inv99.2%
prod-diff99.2%
Applied egg-rr99.2%
Simplified99.3%
div-inv99.3%
tan-quot99.4%
fma-neg99.5%
Applied egg-rr99.5%
if -5.79999999999999982e-9 < eps < 8.0000000000000002e-13Initial program 31.5%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
Simplified99.1%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.2%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
*-commutative99.2%
fma-def99.2%
Simplified99.2%
if 8.0000000000000002e-13 < eps Initial program 56.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan x) (tan eps))) (t_1 (- 1.0 (* (tan x) (tan eps)))))
(if (<= eps -4.2e-9)
(- (/ t_0 t_1) (tan x))
(if (<= eps 8e-13)
(fma eps (pow (tan x) 2.0) eps)
(- (* t_0 (/ 1.0 t_1)) (tan x))))))
double code(double x, double eps) {
double t_0 = tan(x) + tan(eps);
double t_1 = 1.0 - (tan(x) * tan(eps));
double tmp;
if (eps <= -4.2e-9) {
tmp = (t_0 / t_1) - tan(x);
} else if (eps <= 8e-13) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_0 * (1.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 <= -4.2e-9) tmp = Float64(Float64(t_0 / t_1) - tan(x)); elseif (eps <= 8e-13) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_0 * Float64(1.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, -4.2e-9], N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-13], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x + \tan \varepsilon\\
t_1 := 1 - \tan x \cdot \tan \varepsilon\\
\mathbf{if}\;\varepsilon \leq -4.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{1}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -4.20000000000000039e-9Initial program 61.1%
tan-sum99.4%
div-inv99.4%
*-un-lft-identity99.4%
prod-diff99.5%
*-commutative99.5%
*-un-lft-identity99.5%
*-commutative99.5%
*-un-lft-identity99.5%
Applied egg-rr99.5%
Simplified99.4%
if -4.20000000000000039e-9 < eps < 8.0000000000000002e-13Initial program 31.5%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
Simplified99.1%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.2%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
*-commutative99.2%
fma-def99.2%
Simplified99.2%
if 8.0000000000000002e-13 < eps Initial program 56.9%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.8e-9) (not (<= eps 8e-13))) (- (/ (+ (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.8e-9) || !(eps <= 8e-13)) {
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.8e-9) || !(eps <= 8e-13)) 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.8e-9], N[Not[LessEqual[eps, 8e-13]], $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.8 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-13}\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.80000000000000011e-9 or 8.0000000000000002e-13 < eps Initial program 58.8%
tan-sum99.5%
div-inv99.5%
*-un-lft-identity99.5%
prod-diff99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
Simplified99.5%
if -3.80000000000000011e-9 < eps < 8.0000000000000002e-13Initial program 31.5%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
Simplified99.1%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
unpow299.2%
unpow299.2%
frac-times99.1%
tan-quot99.2%
tan-quot99.2%
pow299.2%
Applied egg-rr99.2%
+-commutative99.2%
*-commutative99.2%
fma-def99.2%
Simplified99.2%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.025) (not (<= eps 8e-13))) (- (- (tan x)) (/ (+ (tan x) (tan eps)) -1.0)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.025) || !(eps <= 8e-13)) {
tmp = -tan(x) - ((tan(x) + tan(eps)) / -1.0);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.025) || !(eps <= 8e-13)) tmp = Float64(Float64(-tan(x)) - Float64(Float64(tan(x) + tan(eps)) / -1.0)); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.025], N[Not[LessEqual[eps, 8e-13]], $MachinePrecision]], N[((-N[Tan[x], $MachinePrecision]) - N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / -1.0), $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 -0.025 \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-13}\right):\\
\;\;\;\;\left(-\tan x\right) - \frac{\tan x + \tan \varepsilon}{-1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.025000000000000001 or 8.0000000000000002e-13 < eps Initial program 59.2%
tan-quot59.4%
clear-num59.1%
Applied egg-rr59.1%
clear-num59.2%
tan-quot59.1%
tan-sum99.3%
clear-num99.3%
associate-/r/99.6%
distribute-lft-in99.5%
Applied egg-rr99.5%
distribute-lft-in99.6%
associate-*l/99.6%
mul-1-neg99.6%
+-commutative99.6%
metadata-eval99.6%
sub-neg99.6%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 61.1%
if -0.025000000000000001 < eps < 8.0000000000000002e-13Initial program 31.3%
Taylor expanded in eps around 0 98.5%
cancel-sign-sub-inv98.5%
metadata-eval98.5%
*-lft-identity98.5%
Simplified98.5%
distribute-rgt-in98.6%
*-un-lft-identity98.6%
unpow298.6%
unpow298.6%
frac-times98.5%
tan-quot98.6%
tan-quot98.6%
pow298.6%
Applied egg-rr98.6%
+-commutative98.6%
*-commutative98.6%
fma-def98.6%
Simplified98.6%
Final simplification79.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.025) (not (<= eps 8e-13))) (/ (sin eps) (cos eps)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.025) || !(eps <= 8e-13)) {
tmp = sin(eps) / cos(eps);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.025) || !(eps <= 8e-13)) tmp = Float64(sin(eps) / cos(eps)); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.025], N[Not[LessEqual[eps, 8e-13]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $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 -0.025 \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-13}\right):\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.025000000000000001 or 8.0000000000000002e-13 < eps Initial program 59.2%
Taylor expanded in x around 0 60.9%
if -0.025000000000000001 < eps < 8.0000000000000002e-13Initial program 31.3%
Taylor expanded in eps around 0 98.5%
cancel-sign-sub-inv98.5%
metadata-eval98.5%
*-lft-identity98.5%
Simplified98.5%
distribute-rgt-in98.6%
*-un-lft-identity98.6%
unpow298.6%
unpow298.6%
frac-times98.5%
tan-quot98.6%
tan-quot98.6%
pow298.6%
Applied egg-rr98.6%
+-commutative98.6%
*-commutative98.6%
fma-def98.6%
Simplified98.6%
Final simplification78.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.025) (not (<= eps 8e-13))) (/ (sin eps) (cos eps)) (* eps (+ 1.0 (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.025) || !(eps <= 8e-13)) {
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 <= (-0.025d0)) .or. (.not. (eps <= 8d-13))) 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 <= -0.025) || !(eps <= 8e-13)) {
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 <= -0.025) or not (eps <= 8e-13): 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 <= -0.025) || !(eps <= 8e-13)) 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 <= -0.025) || ~((eps <= 8e-13))) 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, -0.025], N[Not[LessEqual[eps, 8e-13]], $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 -0.025 \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-13}\right):\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(1 + {\tan x}^{2}\right)\\
\end{array}
\end{array}
if eps < -0.025000000000000001 or 8.0000000000000002e-13 < eps Initial program 59.2%
Taylor expanded in x around 0 60.9%
if -0.025000000000000001 < eps < 8.0000000000000002e-13Initial program 31.3%
Taylor expanded in eps around 0 98.5%
cancel-sign-sub-inv98.5%
metadata-eval98.5%
*-lft-identity98.5%
Simplified98.5%
distribute-rgt-in98.6%
*-un-lft-identity98.6%
unpow298.6%
unpow298.6%
frac-times98.5%
tan-quot98.6%
tan-quot98.6%
pow298.6%
Applied egg-rr98.6%
*-rgt-identity98.6%
*-commutative98.6%
distribute-lft-in98.5%
Simplified98.5%
Final simplification78.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.025) (not (<= eps 8e-13))) (/ (sin eps) (cos eps)) (+ eps (* eps (pow (tan x) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.025) || !(eps <= 8e-13)) {
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 <= (-0.025d0)) .or. (.not. (eps <= 8d-13))) 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 <= -0.025) || !(eps <= 8e-13)) {
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 <= -0.025) or not (eps <= 8e-13): 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 <= -0.025) || !(eps <= 8e-13)) 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 <= -0.025) || ~((eps <= 8e-13))) 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, -0.025], N[Not[LessEqual[eps, 8e-13]], $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 -0.025 \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-13}\right):\\
\;\;\;\;\frac{\sin \varepsilon}{\cos \varepsilon}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\end{array}
\end{array}
if eps < -0.025000000000000001 or 8.0000000000000002e-13 < eps Initial program 59.2%
Taylor expanded in x around 0 60.9%
if -0.025000000000000001 < eps < 8.0000000000000002e-13Initial program 31.3%
Taylor expanded in eps around 0 98.5%
cancel-sign-sub-inv98.5%
metadata-eval98.5%
*-lft-identity98.5%
Simplified98.5%
distribute-rgt-in98.6%
*-un-lft-identity98.6%
unpow298.6%
unpow298.6%
frac-times98.5%
tan-quot98.6%
tan-quot98.6%
pow298.6%
Applied egg-rr98.6%
Final simplification78.9%
(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 45.9%
Taylor expanded in x around 0 61.5%
Final simplification61.5%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2800.0) (not (<= eps 8e-13))) (- (tan (+ eps x)) x) (+ eps (* eps (pow x 2.0)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2800.0) || !(eps <= 8e-13)) {
tmp = tan((eps + x)) - x;
} else {
tmp = eps + (eps * pow(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 <= (-2800.0d0)) .or. (.not. (eps <= 8d-13))) then
tmp = tan((eps + x)) - x
else
tmp = eps + (eps * (x ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2800.0) || !(eps <= 8e-13)) {
tmp = Math.tan((eps + x)) - x;
} else {
tmp = eps + (eps * Math.pow(x, 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2800.0) or not (eps <= 8e-13): tmp = math.tan((eps + x)) - x else: tmp = eps + (eps * math.pow(x, 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2800.0) || !(eps <= 8e-13)) tmp = Float64(tan(Float64(eps + x)) - x); else tmp = Float64(eps + Float64(eps * (x ^ 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2800.0) || ~((eps <= 8e-13))) tmp = tan((eps + x)) - x; else tmp = eps + (eps * (x ^ 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2800.0], N[Not[LessEqual[eps, 8e-13]], $MachinePrecision]], N[(N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision], N[(eps + N[(eps * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2800 \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-13}\right):\\
\;\;\;\;\tan \left(\varepsilon + x\right) - x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {x}^{2}\\
\end{array}
\end{array}
if eps < -2800 or 8.0000000000000002e-13 < eps Initial program 59.6%
Taylor expanded in x around 0 55.8%
if -2800 < eps < 8.0000000000000002e-13Initial program 31.0%
Taylor expanded in eps around 0 97.8%
cancel-sign-sub-inv97.8%
metadata-eval97.8%
*-lft-identity97.8%
Simplified97.8%
Taylor expanded in x around 0 53.9%
*-commutative53.9%
Simplified53.9%
Final simplification54.9%
(FPCore (x eps) :precision binary64 (- (tan (+ eps x)) x))
double code(double x, double eps) {
return tan((eps + x)) - x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = tan((eps + x)) - x
end function
public static double code(double x, double eps) {
return Math.tan((eps + x)) - x;
}
def code(x, eps): return math.tan((eps + x)) - x
function code(x, eps) return Float64(tan(Float64(eps + x)) - x) end
function tmp = code(x, eps) tmp = tan((eps + x)) - x; end
code[x_, eps_] := N[(N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(\varepsilon + x\right) - x
\end{array}
Initial program 45.9%
Taylor expanded in x around 0 43.2%
Final simplification43.2%
(FPCore (x eps) :precision binary64 (- eps (tan x)))
double code(double x, double eps) {
return eps - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps - tan(x)
end function
public static double code(double x, double eps) {
return eps - Math.tan(x);
}
def code(x, eps): return eps - math.tan(x)
function code(x, eps) return Float64(eps - tan(x)) end
function tmp = code(x, eps) tmp = eps - tan(x); end
code[x_, eps_] := N[(eps - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon - \tan x
\end{array}
Initial program 45.9%
tan-sum67.9%
clear-num67.7%
Applied egg-rr67.7%
Taylor expanded in x around 0 43.7%
Taylor expanded in eps around 0 14.9%
Final simplification14.9%
(FPCore (x eps) :precision binary64 (- x))
double code(double x, double eps) {
return -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = -x
end function
public static double code(double x, double eps) {
return -x;
}
def code(x, eps): return -x
function code(x, eps) return Float64(-x) end
function tmp = code(x, eps) tmp = -x; end
code[x_, eps_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 45.9%
Taylor expanded in x around 0 43.2%
Taylor expanded in x around inf 3.7%
neg-mul-13.7%
Simplified3.7%
Final simplification3.7%
(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 2024017
(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)))