
(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 14 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 (- 1.0 (* (tan eps) (tan x)))))
(t_1 (/ -1.0 (cos x)))
(t_2 (/ (sin x) (cos x)))
(t_3 (/ (tan eps) (- 1.0 (* (/ (sin eps) (cos eps)) t_2)))))
(if (<= eps -5.8e-8)
(+ t_3 (* (tan x) (+ t_0 -1.0)))
(if (<= eps 2e-7)
(+
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(* (* eps eps) (+ t_2 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(+
t_3
(+
(fma t_1 (sin x) (* (sin x) (/ 1.0 (cos x))))
(fma (tan x) t_0 (* (sin x) t_1))))))))
double code(double x, double eps) {
double t_0 = 1.0 / (1.0 - (tan(eps) * tan(x)));
double t_1 = -1.0 / cos(x);
double t_2 = sin(x) / cos(x);
double t_3 = tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * t_2));
double tmp;
if (eps <= -5.8e-8) {
tmp = t_3 + (tan(x) * (t_0 + -1.0));
} else if (eps <= 2e-7) {
tmp = (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + ((eps * eps) * (t_2 + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = t_3 + (fma(t_1, sin(x), (sin(x) * (1.0 / cos(x)))) + fma(tan(x), t_0, (sin(x) * t_1)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 / Float64(1.0 - Float64(tan(eps) * tan(x)))) t_1 = Float64(-1.0 / cos(x)) t_2 = Float64(sin(x) / cos(x)) t_3 = Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * t_2))) tmp = 0.0 if (eps <= -5.8e-8) tmp = Float64(t_3 + Float64(tan(x) * Float64(t_0 + -1.0))); elseif (eps <= 2e-7) tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64(Float64(eps * eps) * Float64(t_2 + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(t_3 + Float64(fma(t_1, sin(x), Float64(sin(x) * Float64(1.0 / cos(x)))) + fma(tan(x), t_0, Float64(sin(x) * t_1)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.8e-8], N[(t$95$3 + N[(N[Tan[x], $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2e-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[(t$95$2 + N[(N[Power[N[Sin[x], $MachinePrecision], 3.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 + N[(N[(t$95$1 * N[Sin[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(1.0 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * t$95$0 + N[(N[Sin[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{1 - \tan \varepsilon \cdot \tan x}\\
t_1 := \frac{-1}{\cos x}\\
t_2 := \frac{\sin x}{\cos x}\\
t_3 := \frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot t_2}\\
\mathbf{if}\;\varepsilon \leq -5.8 \cdot 10^{-8}:\\
\;\;\;\;t_3 + \tan x \cdot \left(t_0 + -1\right)\\
\mathbf{elif}\;\varepsilon \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(t_2 + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_3 + \left(\mathsf{fma}\left(t_1, \sin x, \sin x \cdot \frac{1}{\cos x}\right) + \mathsf{fma}\left(\tan x, t_0, \sin x \cdot t_1\right)\right)\\
\end{array}
\end{array}
if eps < -5.8000000000000003e-8Initial program 47.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.4%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
Simplified99.1%
tan-quot99.3%
expm1-log1p-u75.3%
expm1-udef74.8%
Applied egg-rr74.8%
expm1-def75.3%
expm1-log1p99.3%
Simplified99.3%
tan-quot99.3%
tan-quot99.4%
div-inv99.4%
fma-neg99.4%
tan-quot99.5%
tan-quot99.5%
*-commutative99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
*-commutative99.5%
Simplified99.5%
if -5.8000000000000003e-8 < eps < 1.9999999999999999e-7Initial program 31.1%
tan-sum32.4%
div-inv32.4%
fma-neg32.4%
Applied egg-rr32.4%
fma-neg32.4%
associate-*r/32.4%
*-rgt-identity32.4%
Simplified32.4%
Taylor expanded in eps around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
Simplified99.8%
if 1.9999999999999999e-7 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Taylor expanded in x around inf 99.2%
associate--l+99.3%
Simplified99.3%
tan-quot99.6%
expm1-log1p-u69.4%
expm1-udef69.1%
Applied egg-rr69.1%
expm1-def69.4%
expm1-log1p99.6%
Simplified99.6%
tan-quot99.5%
div-inv99.5%
div-inv99.6%
prod-diff99.6%
Applied egg-rr99.7%
+-commutative99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
distribute-lft-neg-in99.7%
distribute-neg-frac99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (sin x) (cos x)))
(t_1 (- 1.0 (* (/ (sin eps) (cos eps)) t_0))))
(if (<= eps -5.8e-8)
(+
(/ (tan eps) t_1)
(* (tan x) (+ (/ 1.0 (- 1.0 (* (tan eps) (tan x)))) -1.0)))
(if (<= eps 3.05e-7)
(+
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(* (* eps eps) (+ t_0 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(-
(/ (tan eps) (- 1.0 (/ (tan eps) (/ (cos x) (sin x)))))
(- t_0 (/ t_0 t_1)))))))
double code(double x, double eps) {
double t_0 = sin(x) / cos(x);
double t_1 = 1.0 - ((sin(eps) / cos(eps)) * t_0);
double tmp;
if (eps <= -5.8e-8) {
tmp = (tan(eps) / t_1) + (tan(x) * ((1.0 / (1.0 - (tan(eps) * tan(x)))) + -1.0));
} else if (eps <= 3.05e-7) {
tmp = (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + ((eps * eps) * (t_0 + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = (tan(eps) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - (t_0 - (t_0 / t_1));
}
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 = sin(x) / cos(x)
t_1 = 1.0d0 - ((sin(eps) / cos(eps)) * t_0)
if (eps <= (-5.8d-8)) then
tmp = (tan(eps) / t_1) + (tan(x) * ((1.0d0 / (1.0d0 - (tan(eps) * tan(x)))) + (-1.0d0)))
else if (eps <= 3.05d-7) then
tmp = (eps + (eps * ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))) + ((eps * eps) * (t_0 + ((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0))))
else
tmp = (tan(eps) / (1.0d0 - (tan(eps) / (cos(x) / sin(x))))) - (t_0 - (t_0 / t_1))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) / Math.cos(x);
double t_1 = 1.0 - ((Math.sin(eps) / Math.cos(eps)) * t_0);
double tmp;
if (eps <= -5.8e-8) {
tmp = (Math.tan(eps) / t_1) + (Math.tan(x) * ((1.0 / (1.0 - (Math.tan(eps) * Math.tan(x)))) + -1.0));
} else if (eps <= 3.05e-7) {
tmp = (eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)))) + ((eps * eps) * (t_0 + (Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = (Math.tan(eps) / (1.0 - (Math.tan(eps) / (Math.cos(x) / Math.sin(x))))) - (t_0 - (t_0 / t_1));
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) / math.cos(x) t_1 = 1.0 - ((math.sin(eps) / math.cos(eps)) * t_0) tmp = 0 if eps <= -5.8e-8: tmp = (math.tan(eps) / t_1) + (math.tan(x) * ((1.0 / (1.0 - (math.tan(eps) * math.tan(x)))) + -1.0)) elif eps <= 3.05e-7: tmp = (eps + (eps * (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)))) + ((eps * eps) * (t_0 + (math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)))) else: tmp = (math.tan(eps) / (1.0 - (math.tan(eps) / (math.cos(x) / math.sin(x))))) - (t_0 - (t_0 / t_1)) return tmp
function code(x, eps) t_0 = Float64(sin(x) / cos(x)) t_1 = Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * t_0)) tmp = 0.0 if (eps <= -5.8e-8) tmp = Float64(Float64(tan(eps) / t_1) + Float64(tan(x) * Float64(Float64(1.0 / Float64(1.0 - Float64(tan(eps) * tan(x)))) + -1.0))); elseif (eps <= 3.05e-7) tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64(Float64(eps * eps) * Float64(t_0 + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(tan(eps) / Float64(1.0 - Float64(tan(eps) / Float64(cos(x) / sin(x))))) - Float64(t_0 - Float64(t_0 / t_1))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) / cos(x); t_1 = 1.0 - ((sin(eps) / cos(eps)) * t_0); tmp = 0.0; if (eps <= -5.8e-8) tmp = (tan(eps) / t_1) + (tan(x) * ((1.0 / (1.0 - (tan(eps) * tan(x)))) + -1.0)); elseif (eps <= 3.05e-7) tmp = (eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + ((eps * eps) * (t_0 + ((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))); else tmp = (tan(eps) / (1.0 - (tan(eps) / (cos(x) / sin(x))))) - (t_0 - (t_0 / t_1)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.8e-8], N[(N[(N[Tan[eps], $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.05e-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[(t$95$0 + 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[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 - N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin x}{\cos x}\\
t_1 := 1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot t_0\\
\mathbf{if}\;\varepsilon \leq -5.8 \cdot 10^{-8}:\\
\;\;\;\;\frac{\tan \varepsilon}{t_1} + \tan x \cdot \left(\frac{1}{1 - \tan \varepsilon \cdot \tan x} + -1\right)\\
\mathbf{elif}\;\varepsilon \leq 3.05 \cdot 10^{-7}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(t_0 + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon}{1 - \frac{\tan \varepsilon}{\frac{\cos x}{\sin x}}} - \left(t_0 - \frac{t_0}{t_1}\right)\\
\end{array}
\end{array}
if eps < -5.8000000000000003e-8Initial program 47.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.4%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
Simplified99.1%
tan-quot99.3%
expm1-log1p-u75.3%
expm1-udef74.8%
Applied egg-rr74.8%
expm1-def75.3%
expm1-log1p99.3%
Simplified99.3%
tan-quot99.3%
tan-quot99.4%
div-inv99.4%
fma-neg99.4%
tan-quot99.5%
tan-quot99.5%
*-commutative99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
*-commutative99.5%
Simplified99.5%
if -5.8000000000000003e-8 < eps < 3.04999999999999991e-7Initial program 31.1%
tan-sum32.4%
div-inv32.4%
fma-neg32.4%
Applied egg-rr32.4%
fma-neg32.4%
associate-*r/32.4%
*-rgt-identity32.4%
Simplified32.4%
Taylor expanded in eps around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
Simplified99.8%
if 3.04999999999999991e-7 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Taylor expanded in x around inf 99.2%
associate--l+99.3%
Simplified99.3%
tan-quot99.6%
expm1-log1p-u69.4%
expm1-udef69.1%
Applied egg-rr69.1%
expm1-def69.4%
expm1-log1p99.6%
Simplified99.6%
tan-quot99.6%
associate-*r/99.6%
Applied egg-rr99.6%
associate-/l*99.6%
Simplified99.6%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (/ (sin x) (cos x))))
(if (<= eps -5.8e-8)
(+
(/ (tan eps) (- 1.0 (* (/ (sin eps) (cos eps)) t_1)))
(* (tan x) (+ (/ 1.0 t_0) -1.0)))
(if (<= eps 3e-7)
(+
(+ eps (* eps (/ (pow (sin x) 2.0) (pow (cos x) 2.0))))
(* (* eps eps) (+ t_1 (/ (pow (sin x) 3.0) (pow (cos x) 3.0)))))
(- (/ (+ (tan eps) (tan x)) t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double t_1 = sin(x) / cos(x);
double tmp;
if (eps <= -5.8e-8) {
tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * t_1))) + (tan(x) * ((1.0 / t_0) + -1.0));
} else if (eps <= 3e-7) {
tmp = (eps + (eps * (pow(sin(x), 2.0) / pow(cos(x), 2.0)))) + ((eps * eps) * (t_1 + (pow(sin(x), 3.0) / pow(cos(x), 3.0))));
} else {
tmp = ((tan(eps) + tan(x)) / t_0) - 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 = 1.0d0 - (tan(eps) * tan(x))
t_1 = sin(x) / cos(x)
if (eps <= (-5.8d-8)) then
tmp = (tan(eps) / (1.0d0 - ((sin(eps) / cos(eps)) * t_1))) + (tan(x) * ((1.0d0 / t_0) + (-1.0d0)))
else if (eps <= 3d-7) then
tmp = (eps + (eps * ((sin(x) ** 2.0d0) / (cos(x) ** 2.0d0)))) + ((eps * eps) * (t_1 + ((sin(x) ** 3.0d0) / (cos(x) ** 3.0d0))))
else
tmp = ((tan(eps) + tan(x)) / t_0) - tan(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 - (Math.tan(eps) * Math.tan(x));
double t_1 = Math.sin(x) / Math.cos(x);
double tmp;
if (eps <= -5.8e-8) {
tmp = (Math.tan(eps) / (1.0 - ((Math.sin(eps) / Math.cos(eps)) * t_1))) + (Math.tan(x) * ((1.0 / t_0) + -1.0));
} else if (eps <= 3e-7) {
tmp = (eps + (eps * (Math.pow(Math.sin(x), 2.0) / Math.pow(Math.cos(x), 2.0)))) + ((eps * eps) * (t_1 + (Math.pow(Math.sin(x), 3.0) / Math.pow(Math.cos(x), 3.0))));
} else {
tmp = ((Math.tan(eps) + Math.tan(x)) / t_0) - Math.tan(x);
}
return tmp;
}
def code(x, eps): t_0 = 1.0 - (math.tan(eps) * math.tan(x)) t_1 = math.sin(x) / math.cos(x) tmp = 0 if eps <= -5.8e-8: tmp = (math.tan(eps) / (1.0 - ((math.sin(eps) / math.cos(eps)) * t_1))) + (math.tan(x) * ((1.0 / t_0) + -1.0)) elif eps <= 3e-7: tmp = (eps + (eps * (math.pow(math.sin(x), 2.0) / math.pow(math.cos(x), 2.0)))) + ((eps * eps) * (t_1 + (math.pow(math.sin(x), 3.0) / math.pow(math.cos(x), 3.0)))) else: tmp = ((math.tan(eps) + math.tan(x)) / t_0) - math.tan(x) return tmp
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) t_1 = Float64(sin(x) / cos(x)) tmp = 0.0 if (eps <= -5.8e-8) tmp = Float64(Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * t_1))) + Float64(tan(x) * Float64(Float64(1.0 / t_0) + -1.0))); elseif (eps <= 3e-7) tmp = Float64(Float64(eps + Float64(eps * Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + Float64(Float64(eps * eps) * Float64(t_1 + Float64((sin(x) ^ 3.0) / (cos(x) ^ 3.0))))); else tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / t_0) - tan(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 - (tan(eps) * tan(x)); t_1 = sin(x) / cos(x); tmp = 0.0; if (eps <= -5.8e-8) tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * t_1))) + (tan(x) * ((1.0 / t_0) + -1.0)); elseif (eps <= 3e-7) tmp = (eps + (eps * ((sin(x) ^ 2.0) / (cos(x) ^ 2.0)))) + ((eps * eps) * (t_1 + ((sin(x) ^ 3.0) / (cos(x) ^ 3.0)))); else tmp = ((tan(eps) + tan(x)) / t_0) - tan(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.8e-8], N[(N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 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[(t$95$1 + 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[(N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
t_1 := \frac{\sin x}{\cos x}\\
\mathbf{if}\;\varepsilon \leq -5.8 \cdot 10^{-8}:\\
\;\;\;\;\frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot t_1} + \tan x \cdot \left(\frac{1}{t_0} + -1\right)\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-7}:\\
\;\;\;\;\left(\varepsilon + \varepsilon \cdot \frac{{\sin x}^{2}}{{\cos x}^{2}}\right) + \left(\varepsilon \cdot \varepsilon\right) \cdot \left(t_1 + \frac{{\sin x}^{3}}{{\cos x}^{3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -5.8000000000000003e-8Initial program 47.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.4%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
Simplified99.1%
tan-quot99.3%
expm1-log1p-u75.3%
expm1-udef74.8%
Applied egg-rr74.8%
expm1-def75.3%
expm1-log1p99.3%
Simplified99.3%
tan-quot99.3%
tan-quot99.4%
div-inv99.4%
fma-neg99.4%
tan-quot99.5%
tan-quot99.5%
*-commutative99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
*-commutative99.5%
Simplified99.5%
if -5.8000000000000003e-8 < eps < 2.9999999999999999e-7Initial program 31.1%
tan-sum32.4%
div-inv32.4%
fma-neg32.4%
Applied egg-rr32.4%
fma-neg32.4%
associate-*r/32.4%
*-rgt-identity32.4%
Simplified32.4%
Taylor expanded in eps around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
Simplified99.8%
if 2.9999999999999999e-7 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))))
(if (<= eps -2.6e-9)
(+
(/ (tan eps) (- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x)))))
(- (/ (tan x) t_0) (tan x)))
(if (<= eps 4.6e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ (+ (tan eps) (tan x)) t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double tmp;
if (eps <= -2.6e-9) {
tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))))) + ((tan(x) / t_0) - tan(x));
} else if (eps <= 4.6e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = ((tan(eps) + tan(x)) / t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) tmp = 0.0 if (eps <= -2.6e-9) tmp = Float64(Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x))))) + Float64(Float64(tan(x) / t_0) - tan(x))); elseif (eps <= 4.6e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / t_0) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.6e-9], N[(N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.6e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
\mathbf{if}\;\varepsilon \leq -2.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \left(\frac{\tan x}{t_0} - \tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 4.6 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -2.6000000000000001e-9Initial program 47.0%
tan-sum98.8%
div-inv98.8%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg98.8%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
Taylor expanded in x around inf 98.4%
associate--l+98.4%
Simplified98.6%
tan-quot98.8%
expm1-log1p-u75.2%
expm1-udef74.6%
Applied egg-rr74.6%
expm1-def75.2%
expm1-log1p98.8%
Simplified98.8%
tan-quot98.8%
sub-neg98.8%
tan-quot98.9%
tan-quot99.0%
tan-quot99.0%
Applied egg-rr99.0%
sub-neg99.0%
*-commutative99.0%
Simplified99.0%
if -2.6000000000000001e-9 < eps < 4.5999999999999998e-9Initial program 31.3%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
Simplified99.5%
add-sqr-sqrt61.5%
sqrt-unprod69.5%
pow269.5%
add-sqr-sqrt69.5%
pow269.5%
sqrt-div69.5%
unpow269.5%
sqrt-prod39.7%
add-sqr-sqrt69.5%
unpow269.5%
sqrt-prod63.1%
add-sqr-sqrt69.5%
tan-quot69.5%
Applied egg-rr69.5%
unpow269.5%
rem-sqrt-square74.1%
Simplified74.1%
Taylor expanded in eps around 0 74.1%
rem-cbrt-cube67.3%
unpow1/365.6%
sqr-pow65.6%
fabs-sqr65.6%
sqr-pow65.6%
unpow1/375.9%
rem-cbrt-cube99.5%
fma-udef99.6%
Simplified99.6%
if 4.5999999999999998e-9 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))))
(if (<= eps -4.6e-9)
(+
(/ (tan eps) (- 1.0 (* (/ (sin eps) (cos eps)) (/ (sin x) (cos x)))))
(* (tan x) (+ (/ 1.0 t_0) -1.0)))
(if (<= eps 2.6e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ (+ (tan eps) (tan x)) t_0) (tan x))))))
double code(double x, double eps) {
double t_0 = 1.0 - (tan(eps) * tan(x));
double tmp;
if (eps <= -4.6e-9) {
tmp = (tan(eps) / (1.0 - ((sin(eps) / cos(eps)) * (sin(x) / cos(x))))) + (tan(x) * ((1.0 / t_0) + -1.0));
} else if (eps <= 2.6e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = ((tan(eps) + tan(x)) / t_0) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 - Float64(tan(eps) * tan(x))) tmp = 0.0 if (eps <= -4.6e-9) tmp = Float64(Float64(tan(eps) / Float64(1.0 - Float64(Float64(sin(eps) / cos(eps)) * Float64(sin(x) / cos(x))))) + Float64(tan(x) * Float64(Float64(1.0 / t_0) + -1.0))); elseif (eps <= 2.6e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / t_0) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -4.6e-9], N[(N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[(N[Sin[eps], $MachinePrecision] / N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[(N[(1.0 / t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.6e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \tan \varepsilon \cdot \tan x\\
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{\tan \varepsilon}{1 - \frac{\sin \varepsilon}{\cos \varepsilon} \cdot \frac{\sin x}{\cos x}} + \tan x \cdot \left(\frac{1}{t_0} + -1\right)\\
\mathbf{elif}\;\varepsilon \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{t_0} - \tan x\\
\end{array}
\end{array}
if eps < -4.5999999999999998e-9Initial program 47.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.4%
associate-*r/99.3%
*-rgt-identity99.3%
Simplified99.3%
Taylor expanded in x around inf 98.9%
associate--l+99.0%
Simplified99.1%
tan-quot99.3%
expm1-log1p-u75.3%
expm1-udef74.8%
Applied egg-rr74.8%
expm1-def75.3%
expm1-log1p99.3%
Simplified99.3%
tan-quot99.3%
tan-quot99.4%
div-inv99.4%
fma-neg99.4%
tan-quot99.5%
tan-quot99.5%
*-commutative99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
distribute-lft-out99.5%
*-commutative99.5%
Simplified99.5%
if -4.5999999999999998e-9 < eps < 2.6000000000000001e-9Initial program 31.1%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
distribute-lft-in99.2%
*-rgt-identity99.2%
Simplified99.2%
add-sqr-sqrt61.0%
sqrt-unprod69.1%
pow269.1%
add-sqr-sqrt69.1%
pow269.1%
sqrt-div69.1%
unpow269.1%
sqrt-prod39.5%
add-sqr-sqrt69.1%
unpow269.1%
sqrt-prod62.6%
add-sqr-sqrt69.1%
tan-quot69.1%
Applied egg-rr69.1%
unpow269.1%
rem-sqrt-square73.6%
Simplified73.6%
Taylor expanded in eps around 0 73.6%
rem-cbrt-cube66.9%
unpow1/365.0%
sqr-pow65.0%
fabs-sqr65.0%
sqr-pow65.0%
unpow1/375.8%
rem-cbrt-cube99.2%
fma-udef99.3%
Simplified99.3%
if 2.6000000000000001e-9 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))) (t_1 (- 1.0 (* (tan eps) (tan x)))))
(if (<= eps -4.6e-9)
(fma t_0 (/ 1.0 t_1) (- (tan x)))
(if (<= eps 2.05e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_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 <= -4.6e-9) {
tmp = fma(t_0, (1.0 / t_1), -tan(x));
} else if (eps <= 2.05e-9) {
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(eps) + tan(x)) t_1 = Float64(1.0 - Float64(tan(eps) * tan(x))) tmp = 0.0 if (eps <= -4.6e-9) tmp = fma(t_0, Float64(1.0 / t_1), Float64(-tan(x))); elseif (eps <= 2.05e-9) 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[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, -4.6e-9], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision] + (-N[Tan[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.05e-9], 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 \varepsilon + \tan x\\
t_1 := 1 - \tan \varepsilon \cdot \tan x\\
\mathbf{if}\;\varepsilon \leq -4.6 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \frac{1}{t_1}, -\tan x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.05 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{t_1} - \tan x\\
\end{array}
\end{array}
if eps < -4.5999999999999998e-9Initial program 47.7%
tan-sum99.3%
div-inv99.4%
fma-neg99.5%
Applied egg-rr99.5%
if -4.5999999999999998e-9 < eps < 2.0500000000000002e-9Initial program 31.1%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
distribute-lft-in99.2%
*-rgt-identity99.2%
Simplified99.2%
add-sqr-sqrt61.0%
sqrt-unprod69.1%
pow269.1%
add-sqr-sqrt69.1%
pow269.1%
sqrt-div69.1%
unpow269.1%
sqrt-prod39.5%
add-sqr-sqrt69.1%
unpow269.1%
sqrt-prod62.6%
add-sqr-sqrt69.1%
tan-quot69.1%
Applied egg-rr69.1%
unpow269.1%
rem-sqrt-square73.6%
Simplified73.6%
Taylor expanded in eps around 0 73.6%
rem-cbrt-cube66.9%
unpow1/365.0%
sqr-pow65.0%
fabs-sqr65.0%
sqr-pow65.0%
unpow1/375.8%
rem-cbrt-cube99.2%
fma-udef99.3%
Simplified99.3%
if 2.0500000000000002e-9 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.4e-9) (not (<= eps 1.8e-9))) (- (/ (+ (tan eps) (tan x)) (- 1.0 (* (tan eps) (tan x)))) (tan x)) (fma eps (pow (tan x) 2.0) eps)))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.4e-9) || !(eps <= 1.8e-9)) {
tmp = ((tan(eps) + tan(x)) / (1.0 - (tan(eps) * tan(x)))) - tan(x);
} else {
tmp = fma(eps, pow(tan(x), 2.0), eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.4e-9) || !(eps <= 1.8e-9)) tmp = Float64(Float64(Float64(tan(eps) + tan(x)) / Float64(1.0 - Float64(tan(eps) * tan(x)))) - tan(x)); else tmp = fma(eps, (tan(x) ^ 2.0), eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.4e-9], N[Not[LessEqual[eps, 1.8e-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[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-9} \lor \neg \left(\varepsilon \leq 1.8 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\end{array}
\end{array}
if eps < -3.3999999999999998e-9 or 1.8e-9 < eps Initial program 52.3%
tan-sum99.2%
div-inv99.1%
fma-neg99.2%
Applied egg-rr99.2%
fma-neg99.1%
associate-*r/99.2%
*-rgt-identity99.2%
Simplified99.2%
if -3.3999999999999998e-9 < eps < 1.8e-9Initial program 31.3%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
Simplified99.5%
add-sqr-sqrt61.5%
sqrt-unprod69.5%
pow269.5%
add-sqr-sqrt69.5%
pow269.5%
sqrt-div69.5%
unpow269.5%
sqrt-prod39.7%
add-sqr-sqrt69.5%
unpow269.5%
sqrt-prod63.1%
add-sqr-sqrt69.5%
tan-quot69.5%
Applied egg-rr69.5%
unpow269.5%
rem-sqrt-square74.1%
Simplified74.1%
Taylor expanded in eps around 0 74.1%
rem-cbrt-cube67.3%
unpow1/365.6%
sqr-pow65.6%
fabs-sqr65.6%
sqr-pow65.6%
unpow1/375.9%
rem-cbrt-cube99.5%
fma-udef99.6%
Simplified99.6%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- 1.0 (* (tan eps) (tan x)))) (t_1 (+ (tan eps) (tan x))))
(if (<= eps -5.2e-9)
(- (* (/ 1.0 t_0) t_1) (tan x))
(if (<= eps 2.4e-9)
(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(eps) * tan(x));
double t_1 = tan(eps) + tan(x);
double tmp;
if (eps <= -5.2e-9) {
tmp = ((1.0 / t_0) * t_1) - tan(x);
} else if (eps <= 2.4e-9) {
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(eps) * tan(x))) t_1 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -5.2e-9) tmp = Float64(Float64(Float64(1.0 / t_0) * t_1) - tan(x)); elseif (eps <= 2.4e-9) 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[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.2e-9], N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.4e-9], 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 \varepsilon \cdot \tan x\\
t_1 := \tan \varepsilon + \tan x\\
\mathbf{if}\;\varepsilon \leq -5.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{t_0} \cdot t_1 - \tan x\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-9}:\\
\;\;\;\;\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.2000000000000002e-9Initial program 47.7%
tan-sum99.3%
div-inv99.4%
Applied egg-rr99.4%
if -5.2000000000000002e-9 < eps < 2.4e-9Initial program 31.1%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
distribute-lft-in99.2%
*-rgt-identity99.2%
Simplified99.2%
add-sqr-sqrt61.0%
sqrt-unprod69.1%
pow269.1%
add-sqr-sqrt69.1%
pow269.1%
sqrt-div69.1%
unpow269.1%
sqrt-prod39.5%
add-sqr-sqrt69.1%
unpow269.1%
sqrt-prod62.6%
add-sqr-sqrt69.1%
tan-quot69.1%
Applied egg-rr69.1%
unpow269.1%
rem-sqrt-square73.6%
Simplified73.6%
Taylor expanded in eps around 0 73.6%
rem-cbrt-cube66.9%
unpow1/365.0%
sqr-pow65.0%
fabs-sqr65.0%
sqr-pow65.0%
unpow1/375.8%
rem-cbrt-cube99.2%
fma-udef99.3%
Simplified99.3%
if 2.4e-9 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (tan eps) (tan x))))
(if (<= eps -2.1e-9)
(- (/ t_0 (- 1.0 (/ (tan x) (/ 1.0 (tan eps))))) (tan x))
(if (<= eps 3e-9)
(fma eps (pow (tan x) 2.0) eps)
(- (/ t_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 <= -2.1e-9) {
tmp = (t_0 / (1.0 - (tan(x) / (1.0 / tan(eps))))) - tan(x);
} else if (eps <= 3e-9) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = (t_0 / (1.0 - (tan(eps) * tan(x)))) - tan(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(eps) + tan(x)) tmp = 0.0 if (eps <= -2.1e-9) tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(x) / Float64(1.0 / tan(eps))))) - tan(x)); elseif (eps <= 3e-9) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = Float64(Float64(t_0 / Float64(1.0 - Float64(tan(eps) * tan(x)))) - tan(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[eps], $MachinePrecision] + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.1e-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, 3e-9], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[(N[(t$95$0 / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $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 -2.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{t_0}{1 - \frac{\tan x}{\frac{1}{\tan \varepsilon}}} - \tan x\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\
\end{array}
\end{array}
if eps < -2.10000000000000019e-9Initial program 47.0%
tan-sum98.8%
div-inv98.8%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg98.8%
associate-*r/98.8%
*-rgt-identity98.8%
Simplified98.8%
tan-quot98.7%
clear-num98.7%
un-div-inv98.7%
clear-num98.7%
tan-quot98.8%
Applied egg-rr98.8%
if -2.10000000000000019e-9 < eps < 2.99999999999999998e-9Initial program 31.3%
Taylor expanded in eps around 0 99.5%
cancel-sign-sub-inv99.5%
metadata-eval99.5%
*-lft-identity99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
Simplified99.5%
add-sqr-sqrt61.5%
sqrt-unprod69.5%
pow269.5%
add-sqr-sqrt69.5%
pow269.5%
sqrt-div69.5%
unpow269.5%
sqrt-prod39.7%
add-sqr-sqrt69.5%
unpow269.5%
sqrt-prod63.1%
add-sqr-sqrt69.5%
tan-quot69.5%
Applied egg-rr69.5%
unpow269.5%
rem-sqrt-square74.1%
Simplified74.1%
Taylor expanded in eps around 0 74.1%
rem-cbrt-cube67.3%
unpow1/365.6%
sqr-pow65.6%
fabs-sqr65.6%
sqr-pow65.6%
unpow1/375.9%
rem-cbrt-cube99.5%
fma-udef99.6%
Simplified99.6%
if 2.99999999999999998e-9 < eps Initial program 57.4%
tan-sum99.5%
div-inv99.5%
fma-neg99.4%
Applied egg-rr99.4%
fma-neg99.5%
associate-*r/99.5%
*-rgt-identity99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (<= eps -5.8e-8) (tan eps) (if (<= eps 3.75e-6) (fma eps (pow (tan x) 2.0) eps) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -5.8e-8) {
tmp = tan(eps);
} else if (eps <= 3.75e-6) {
tmp = fma(eps, pow(tan(x), 2.0), eps);
} else {
tmp = tan(eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -5.8e-8) tmp = tan(eps); elseif (eps <= 3.75e-6) tmp = fma(eps, (tan(x) ^ 2.0), eps); else tmp = tan(eps); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -5.8e-8], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 3.75e-6], N[(eps * N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] + eps), $MachinePrecision], N[Tan[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -5.8 \cdot 10^{-8}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 3.75 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, {\tan x}^{2}, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -5.8000000000000003e-8 or 3.7500000000000001e-6 < eps Initial program 52.6%
Taylor expanded in x around 0 53.4%
tan-quot99.4%
expm1-log1p-u72.3%
expm1-udef71.9%
Applied egg-rr38.7%
expm1-def72.3%
expm1-log1p99.4%
Simplified53.5%
if -5.8000000000000003e-8 < eps < 3.7500000000000001e-6Initial program 31.1%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
distribute-lft-in99.2%
*-rgt-identity99.2%
Simplified99.2%
add-sqr-sqrt61.0%
sqrt-unprod69.1%
pow269.1%
add-sqr-sqrt69.1%
pow269.1%
sqrt-div69.1%
unpow269.1%
sqrt-prod39.5%
add-sqr-sqrt69.1%
unpow269.1%
sqrt-prod62.6%
add-sqr-sqrt69.1%
tan-quot69.1%
Applied egg-rr69.1%
unpow269.1%
rem-sqrt-square73.6%
Simplified73.6%
Taylor expanded in eps around 0 73.6%
rem-cbrt-cube66.9%
unpow1/365.0%
sqr-pow65.0%
fabs-sqr65.0%
sqr-pow65.0%
unpow1/375.8%
rem-cbrt-cube99.2%
fma-udef99.3%
Simplified99.3%
Final simplification74.8%
(FPCore (x eps) :precision binary64 (if (<= eps -5.8e-8) (tan eps) (if (<= eps 3.7e-6) (+ eps (* eps (pow (tan x) 2.0))) (tan eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -5.8e-8) {
tmp = tan(eps);
} else if (eps <= 3.7e-6) {
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 <= (-5.8d-8)) then
tmp = tan(eps)
else if (eps <= 3.7d-6) 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 <= -5.8e-8) {
tmp = Math.tan(eps);
} else if (eps <= 3.7e-6) {
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 <= -5.8e-8: tmp = math.tan(eps) elif eps <= 3.7e-6: 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 <= -5.8e-8) tmp = tan(eps); elseif (eps <= 3.7e-6) 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 <= -5.8e-8) tmp = tan(eps); elseif (eps <= 3.7e-6) tmp = eps + (eps * (tan(x) ^ 2.0)); else tmp = tan(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -5.8e-8], N[Tan[eps], $MachinePrecision], If[LessEqual[eps, 3.7e-6], 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 -5.8 \cdot 10^{-8}:\\
\;\;\;\;\tan \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 3.7 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot {\tan x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\tan \varepsilon\\
\end{array}
\end{array}
if eps < -5.8000000000000003e-8 or 3.7000000000000002e-6 < eps Initial program 52.6%
Taylor expanded in x around 0 53.4%
tan-quot99.4%
expm1-log1p-u72.3%
expm1-udef71.9%
Applied egg-rr38.7%
expm1-def72.3%
expm1-log1p99.4%
Simplified53.5%
if -5.8000000000000003e-8 < eps < 3.7000000000000002e-6Initial program 31.1%
Taylor expanded in eps around 0 99.1%
cancel-sign-sub-inv99.1%
metadata-eval99.1%
*-lft-identity99.1%
distribute-lft-in99.2%
*-rgt-identity99.2%
Simplified99.2%
expm1-log1p-u99.2%
expm1-udef63.6%
Applied egg-rr63.6%
expm1-def99.2%
expm1-log1p99.2%
Simplified99.2%
Final simplification74.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 42.6%
Taylor expanded in x around 0 57.8%
tan-quot82.8%
expm1-log1p-u68.2%
expm1-udef42.0%
Applied egg-rr23.9%
expm1-def68.2%
expm1-log1p82.8%
Simplified57.9%
Final simplification57.9%
(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 42.6%
add-cube-cbrt41.7%
pow341.7%
add-exp-log18.4%
pow-exp18.3%
Applied egg-rr18.3%
Taylor expanded in eps around 0 4.2%
pow-base-14.2%
*-rgt-identity4.2%
+-inverses4.2%
Simplified4.2%
Final simplification4.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 42.6%
Taylor expanded in x around 0 57.8%
Taylor expanded in eps around 0 31.3%
Final simplification31.3%
(FPCore (x eps) :precision binary64 (/ (sin eps) (* (cos x) (cos (+ x eps)))))
double code(double x, double eps) {
return sin(eps) / (cos(x) * cos((x + eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / (cos(x) * cos((x + eps)))
end function
public static double code(double x, double eps) {
return Math.sin(eps) / (Math.cos(x) * Math.cos((x + eps)));
}
def code(x, eps): return math.sin(eps) / (math.cos(x) * math.cos((x + eps)))
function code(x, eps) return Float64(sin(eps) / Float64(cos(x) * cos(Float64(x + eps)))) end
function tmp = code(x, eps) tmp = sin(eps) / (cos(x) * cos((x + eps))); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}
\end{array}
herbie shell --seed 2023240
(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)))