
(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 13 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 (pow (tan x) 2.0))
(t_1 (* (sin x) (fma (tan x) (tan x) 1.0)))
(t_2
(+
(+
(pow (tan x) 4.0)
(- 0.3333333333333333 (* t_0 -0.3333333333333333)))
t_0)))
(fma
(fma
(fma
(fma (fma t_2 (tan x) (* (/ 0.3333333333333333 (cos x)) t_1)) eps t_2)
eps
(/ t_1 (cos x)))
eps
(* (* (pow (cos x) -1.0) (tan x)) (sin x)))
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(tan(x), 2.0);
double t_1 = sin(x) * fma(tan(x), tan(x), 1.0);
double t_2 = (pow(tan(x), 4.0) + (0.3333333333333333 - (t_0 * -0.3333333333333333))) + t_0;
return fma(fma(fma(fma(fma(t_2, tan(x), ((0.3333333333333333 / cos(x)) * t_1)), eps, t_2), eps, (t_1 / cos(x))), eps, ((pow(cos(x), -1.0) * tan(x)) * sin(x))), eps, eps);
}
function code(x, eps) t_0 = tan(x) ^ 2.0 t_1 = Float64(sin(x) * fma(tan(x), tan(x), 1.0)) t_2 = Float64(Float64((tan(x) ^ 4.0) + Float64(0.3333333333333333 - Float64(t_0 * -0.3333333333333333))) + t_0) return fma(fma(fma(fma(fma(t_2, tan(x), Float64(Float64(0.3333333333333333 / cos(x)) * t_1)), eps, t_2), eps, Float64(t_1 / cos(x))), eps, Float64(Float64((cos(x) ^ -1.0) * tan(x)) * sin(x))), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[Tan[x], $MachinePrecision], 4.0], $MachinePrecision] + N[(0.3333333333333333 - N[(t$95$0 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]}, N[(N[(N[(N[(N[(t$95$2 * N[Tan[x], $MachinePrecision] + N[(N[(0.3333333333333333 / N[Cos[x], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] * eps + t$95$2), $MachinePrecision] * eps + N[(t$95$1 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + N[(N[(N[Power[N[Cos[x], $MachinePrecision], -1.0], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
t_1 := \sin x \cdot \mathsf{fma}\left(\tan x, \tan x, 1\right)\\
t_2 := \left({\tan x}^{4} + \left(0.3333333333333333 - t\_0 \cdot -0.3333333333333333\right)\right) + t\_0\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(t\_2, \tan x, \frac{0.3333333333333333}{\cos x} \cdot t\_1\right), \varepsilon, t\_2\right), \varepsilon, \frac{t\_1}{\cos x}\right), \varepsilon, \left({\cos x}^{-1} \cdot \tan x\right) \cdot \sin x\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (tan x) 2.0))
(t_1 (* (fma (tan x) (tan x) 1.0) (tan x)))
(t_2
(+
(fma t_0 0.3333333333333333 (pow (tan x) 4.0))
0.3333333333333333)))
(fma
(fma
(fma
(fma
eps
(fma t_1 0.3333333333333333 (fma t_2 (tan x) (pow (tan x) 3.0)))
(fma (tan x) (tan x) t_2))
eps
t_1)
eps
t_0)
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(tan(x), 2.0);
double t_1 = fma(tan(x), tan(x), 1.0) * tan(x);
double t_2 = fma(t_0, 0.3333333333333333, pow(tan(x), 4.0)) + 0.3333333333333333;
return fma(fma(fma(fma(eps, fma(t_1, 0.3333333333333333, fma(t_2, tan(x), pow(tan(x), 3.0))), fma(tan(x), tan(x), t_2)), eps, t_1), eps, t_0), eps, eps);
}
function code(x, eps) t_0 = tan(x) ^ 2.0 t_1 = Float64(fma(tan(x), tan(x), 1.0) * tan(x)) t_2 = Float64(fma(t_0, 0.3333333333333333, (tan(x) ^ 4.0)) + 0.3333333333333333) return fma(fma(fma(fma(eps, fma(t_1, 0.3333333333333333, fma(t_2, tan(x), (tan(x) ^ 3.0))), fma(tan(x), tan(x), t_2)), eps, t_1), eps, t_0), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * 0.3333333333333333 + N[Power[N[Tan[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]}, N[(N[(N[(N[(eps * N[(t$95$1 * 0.3333333333333333 + N[(t$95$2 * N[Tan[x], $MachinePrecision] + N[Power[N[Tan[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision] * eps + t$95$1), $MachinePrecision] * eps + t$95$0), $MachinePrecision] * eps + eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
t_1 := \mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \tan x\\
t_2 := \mathsf{fma}\left(t\_0, 0.3333333333333333, {\tan x}^{4}\right) + 0.3333333333333333\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(t\_1, 0.3333333333333333, \mathsf{fma}\left(t\_2, \tan x, {\tan x}^{3}\right)\right), \mathsf{fma}\left(\tan x, \tan x, t\_2\right)\right), \varepsilon, t\_1\right), \varepsilon, t\_0\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (tan x) 2.0)))
(fma
(fma
(fma
(fma
(* 0.6666666666666666 x)
eps
(+
(+
(pow (tan x) 4.0)
(- 0.3333333333333333 (* t_0 -0.3333333333333333)))
t_0))
eps
(/ (* (sin x) (fma (tan x) (tan x) 1.0)) (cos x)))
eps
t_0)
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(tan(x), 2.0);
return fma(fma(fma(fma((0.6666666666666666 * x), eps, ((pow(tan(x), 4.0) + (0.3333333333333333 - (t_0 * -0.3333333333333333))) + t_0)), eps, ((sin(x) * fma(tan(x), tan(x), 1.0)) / cos(x))), eps, t_0), eps, eps);
}
function code(x, eps) t_0 = tan(x) ^ 2.0 return fma(fma(fma(fma(Float64(0.6666666666666666 * x), eps, Float64(Float64((tan(x) ^ 4.0) + Float64(0.3333333333333333 - Float64(t_0 * -0.3333333333333333))) + t_0)), eps, Float64(Float64(sin(x) * fma(tan(x), tan(x), 1.0)) / cos(x))), eps, t_0), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(N[(N[(N[(0.6666666666666666 * x), $MachinePrecision] * eps + N[(N[(N[Power[N[Tan[x], $MachinePrecision], 4.0], $MachinePrecision] + N[(0.3333333333333333 - N[(t$95$0 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] * eps + N[(N[(N[Sin[x], $MachinePrecision] * N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + t$95$0), $MachinePrecision] * eps + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.6666666666666666 \cdot x, \varepsilon, \left({\tan x}^{4} + \left(0.3333333333333333 - t\_0 \cdot -0.3333333333333333\right)\right) + t\_0\right), \varepsilon, \frac{\sin x \cdot \mathsf{fma}\left(\tan x, \tan x, 1\right)}{\cos x}\right), \varepsilon, t\_0\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x eps) :precision binary64 (fma (fma (pow (sin x) 2.0) (pow (cos x) -2.0) (* (fma 0.3333333333333333 eps (* (fma (tan x) (tan x) 1.0) (tan x))) eps)) eps eps))
double code(double x, double eps) {
return fma(fma(pow(sin(x), 2.0), pow(cos(x), -2.0), (fma(0.3333333333333333, eps, (fma(tan(x), tan(x), 1.0) * tan(x))) * eps)), eps, eps);
}
function code(x, eps) return fma(fma((sin(x) ^ 2.0), (cos(x) ^ -2.0), Float64(fma(0.3333333333333333, eps, Float64(fma(tan(x), tan(x), 1.0) * tan(x))) * eps)), eps, eps) end
code[x_, eps_] := N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[Cos[x], $MachinePrecision], -2.0], $MachinePrecision] + N[(N[(0.3333333333333333 * eps + N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left({\sin x}^{2}, {\cos x}^{-2}, \mathsf{fma}\left(0.3333333333333333, \varepsilon, \mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \tan x\right) \cdot \varepsilon\right), \varepsilon, \varepsilon\right)
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.8%
(FPCore (x eps)
:precision binary64
(+
(*
(fma
(fma 0.3333333333333333 eps (* (fma (tan x) (tan x) 1.0) (tan x)))
eps
(pow (tan x) 2.0))
eps)
eps))
double code(double x, double eps) {
return (fma(fma(0.3333333333333333, eps, (fma(tan(x), tan(x), 1.0) * tan(x))), eps, pow(tan(x), 2.0)) * eps) + eps;
}
function code(x, eps) return Float64(Float64(fma(fma(0.3333333333333333, eps, Float64(fma(tan(x), tan(x), 1.0) * tan(x))), eps, (tan(x) ^ 2.0)) * eps) + eps) end
code[x_, eps_] := N[(N[(N[(N[(0.3333333333333333 * eps + N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, \varepsilon, \mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \tan x\right), \varepsilon, {\tan x}^{2}\right) \cdot \varepsilon + \varepsilon
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.7%
(FPCore (x eps) :precision binary64 (fma (fma (fma 0.3333333333333333 eps (* (fma (tan x) (tan x) 1.0) (tan x))) eps (pow (tan x) 2.0)) eps eps))
double code(double x, double eps) {
return fma(fma(fma(0.3333333333333333, eps, (fma(tan(x), tan(x), 1.0) * tan(x))), eps, pow(tan(x), 2.0)), eps, eps);
}
function code(x, eps) return fma(fma(fma(0.3333333333333333, eps, Float64(fma(tan(x), tan(x), 1.0) * tan(x))), eps, (tan(x) ^ 2.0)), eps, eps) end
code[x_, eps_] := N[(N[(N[(0.3333333333333333 * eps + N[(N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, \varepsilon, \mathsf{fma}\left(\tan x, \tan x, 1\right) \cdot \tan x\right), \varepsilon, {\tan x}^{2}\right), \varepsilon, \varepsilon\right)
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.7%
(FPCore (x eps) :precision binary64 (fma (/ (pow (sin x) 2.0) (pow (cos x) 2.0)) eps eps))
double code(double x, double eps) {
return fma((pow(sin(x), 2.0) / pow(cos(x), 2.0)), eps, eps);
}
function code(x, eps) return fma(Float64((sin(x) ^ 2.0) / (cos(x) ^ 2.0)), eps, eps) end
code[x_, eps_] := N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{{\sin x}^{2}}{{\cos x}^{2}}, \varepsilon, \varepsilon\right)
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
mul-1-negN/A
remove-double-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6499.1
Applied rewrites99.1%
(FPCore (x eps)
:precision binary64
(fma
(fma
(fma
0.3333333333333333
eps
(/ (* (fma 0.8333333333333334 (* x x) 1.0) x) (cos x)))
eps
(pow (tan x) 2.0))
eps
eps))
double code(double x, double eps) {
return fma(fma(fma(0.3333333333333333, eps, ((fma(0.8333333333333334, (x * x), 1.0) * x) / cos(x))), eps, pow(tan(x), 2.0)), eps, eps);
}
function code(x, eps) return fma(fma(fma(0.3333333333333333, eps, Float64(Float64(fma(0.8333333333333334, Float64(x * x), 1.0) * x) / cos(x))), eps, (tan(x) ^ 2.0)), eps, eps) end
code[x_, eps_] := N[(N[(N[(0.3333333333333333 * eps + N[(N[(N[(0.8333333333333334 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, \varepsilon, \frac{\mathsf{fma}\left(0.8333333333333334, x \cdot x, 1\right) \cdot x}{\cos x}\right), \varepsilon, {\tan x}^{2}\right), \varepsilon, \varepsilon\right)
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.0%
(FPCore (x eps)
:precision binary64
(fma
(fma
(fma
(fma 1.3333333333333333 (* eps eps) 1.0)
x
(fma 0.6666666666666666 (pow eps 3.0) eps))
x
(* (* eps eps) 0.3333333333333333))
eps
eps))
double code(double x, double eps) {
return fma(fma(fma(fma(1.3333333333333333, (eps * eps), 1.0), x, fma(0.6666666666666666, pow(eps, 3.0), eps)), x, ((eps * eps) * 0.3333333333333333)), eps, eps);
}
function code(x, eps) return fma(fma(fma(fma(1.3333333333333333, Float64(eps * eps), 1.0), x, fma(0.6666666666666666, (eps ^ 3.0), eps)), x, Float64(Float64(eps * eps) * 0.3333333333333333)), eps, eps) end
code[x_, eps_] := N[(N[(N[(N[(1.3333333333333333 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision] * x + N[(0.6666666666666666 * N[Power[eps, 3.0], $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] * x + N[(N[(eps * eps), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(1.3333333333333333, \varepsilon \cdot \varepsilon, 1\right), x, \mathsf{fma}\left(0.6666666666666666, {\varepsilon}^{3}, \varepsilon\right)\right), x, \left(\varepsilon \cdot \varepsilon\right) \cdot 0.3333333333333333\right), \varepsilon, \varepsilon\right)
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites98.3%
(FPCore (x eps) :precision binary64 (/ (sin eps) (fma (* eps eps) -0.5 1.0)))
double code(double x, double eps) {
return sin(eps) / fma((eps * eps), -0.5, 1.0);
}
function code(x, eps) return Float64(sin(eps) / fma(Float64(eps * eps), -0.5, 1.0)) end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[(eps * eps), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\mathsf{fma}\left(\varepsilon \cdot \varepsilon, -0.5, 1\right)}
\end{array}
Initial program 62.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in eps around 0
Applied rewrites97.6%
(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 62.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6497.6
Applied rewrites97.6%
Applied rewrites97.6%
(FPCore (x eps) :precision binary64 (fma (* (* eps eps) 0.3333333333333333) eps eps))
double code(double x, double eps) {
return fma(((eps * eps) * 0.3333333333333333), eps, eps);
}
function code(x, eps) return fma(Float64(Float64(eps * eps) * 0.3333333333333333), eps, eps) end
code[x_, eps_] := N[(N[(N[(eps * eps), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\varepsilon \cdot \varepsilon\right) \cdot 0.3333333333333333, \varepsilon, \varepsilon\right)
\end{array}
Initial program 62.4%
Taylor expanded in eps around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites97.6%
(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 62.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-tan.f64N/A
tan-quotN/A
distribute-neg-frac2N/A
div-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-neg.f64N/A
lower-cos.f6462.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6462.4
Applied rewrites62.4%
Taylor expanded in eps around 0
distribute-lft1-inN/A
metadata-evalN/A
mul0-lft5.4
Applied rewrites5.4%
(FPCore (x eps) :precision binary64 (+ eps (* (* eps (tan x)) (tan x))))
double code(double x, double eps) {
return eps + ((eps * tan(x)) * tan(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps + ((eps * tan(x)) * tan(x))
end function
public static double code(double x, double eps) {
return eps + ((eps * Math.tan(x)) * Math.tan(x));
}
def code(x, eps): return eps + ((eps * math.tan(x)) * math.tan(x))
function code(x, eps) return Float64(eps + Float64(Float64(eps * tan(x)) * tan(x))) end
function tmp = code(x, eps) tmp = eps + ((eps * tan(x)) * tan(x)); end
code[x_, eps_] := N[(eps + N[(N[(eps * N[Tan[x], $MachinePrecision]), $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon + \left(\varepsilon \cdot \tan x\right) \cdot \tan x
\end{array}
herbie shell --seed 2024255
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:precision binary64
:pre (and (and (and (<= -10000.0 x) (<= x 10000.0)) (< (* 1e-16 (fabs x)) eps)) (< eps (fabs x)))
:alt
(! :herbie-platform default (+ eps (* eps (tan x) (tan x))))
(- (tan (+ x eps)) (tan x)))