
(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 (pow (tan x) 2.0)) (t_1 (- t_0)) (t_2 (fma (tan x) (tan x) 1.0)))
(fma
(fma
(*
(fma
(/ (* t_2 (fma (sin x) -0.6666666666666666 (* t_1 (sin x)))) (cos x))
(- eps)
(-
-0.16666666666666666
(fma 0.16666666666666666 t_0 (fma t_1 t_2 (fma t_0 -0.5 -0.5)))))
eps)
eps
(/ (fma (fma eps t_0 eps) (sin x) (* (sin x) (tan x))) (cos x)))
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(tan(x), 2.0);
double t_1 = -t_0;
double t_2 = fma(tan(x), tan(x), 1.0);
return fma(fma((fma(((t_2 * fma(sin(x), -0.6666666666666666, (t_1 * sin(x)))) / cos(x)), -eps, (-0.16666666666666666 - fma(0.16666666666666666, t_0, fma(t_1, t_2, fma(t_0, -0.5, -0.5))))) * eps), eps, (fma(fma(eps, t_0, eps), sin(x), (sin(x) * tan(x))) / cos(x))), eps, eps);
}
function code(x, eps) t_0 = tan(x) ^ 2.0 t_1 = Float64(-t_0) t_2 = fma(tan(x), tan(x), 1.0) return fma(fma(Float64(fma(Float64(Float64(t_2 * fma(sin(x), -0.6666666666666666, Float64(t_1 * sin(x)))) / cos(x)), Float64(-eps), Float64(-0.16666666666666666 - fma(0.16666666666666666, t_0, fma(t_1, t_2, fma(t_0, -0.5, -0.5))))) * eps), eps, Float64(fma(fma(eps, t_0, eps), sin(x), Float64(sin(x) * tan(x))) / cos(x))), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = (-t$95$0)}, Block[{t$95$2 = N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision]}, N[(N[(N[(N[(N[(N[(t$95$2 * N[(N[Sin[x], $MachinePrecision] * -0.6666666666666666 + N[(t$95$1 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * (-eps) + N[(-0.16666666666666666 - N[(0.16666666666666666 * t$95$0 + N[(t$95$1 * t$95$2 + N[(t$95$0 * -0.5 + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps + N[(N[(N[(eps * t$95$0 + eps), $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
t_1 := -t\_0\\
t_2 := \mathsf{fma}\left(\tan x, \tan x, 1\right)\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{t\_2 \cdot \mathsf{fma}\left(\sin x, -0.6666666666666666, t\_1 \cdot \sin x\right)}{\cos x}, -\varepsilon, -0.16666666666666666 - \mathsf{fma}\left(0.16666666666666666, t\_0, \mathsf{fma}\left(t\_1, t\_2, \mathsf{fma}\left(t\_0, -0.5, -0.5\right)\right)\right)\right) \cdot \varepsilon, \varepsilon, \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, t\_0, \varepsilon\right), \sin x, \sin x \cdot \tan x\right)}{\cos x}\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 63.7%
Taylor expanded in eps around 0
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (cos x) 2.0)) (t_1 (pow (sin x) 2.0)) (t_2 (/ t_1 t_0)))
(fma
(fma
(*
(-
0.3333333333333333
(/ (fma -0.3333333333333333 t_1 (* (+ t_2 1.0) (- t_1))) t_0))
eps)
eps
(/ (fma (fma t_2 eps eps) (sin x) (/ t_1 (cos x))) (cos x)))
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(cos(x), 2.0);
double t_1 = pow(sin(x), 2.0);
double t_2 = t_1 / t_0;
return fma(fma(((0.3333333333333333 - (fma(-0.3333333333333333, t_1, ((t_2 + 1.0) * -t_1)) / t_0)) * eps), eps, (fma(fma(t_2, eps, eps), sin(x), (t_1 / cos(x))) / cos(x))), eps, eps);
}
function code(x, eps) t_0 = cos(x) ^ 2.0 t_1 = sin(x) ^ 2.0 t_2 = Float64(t_1 / t_0) return fma(fma(Float64(Float64(0.3333333333333333 - Float64(fma(-0.3333333333333333, t_1, Float64(Float64(t_2 + 1.0) * Float64(-t_1))) / t_0)) * eps), eps, Float64(fma(fma(t_2, eps, eps), sin(x), Float64(t_1 / cos(x))) / cos(x))), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / t$95$0), $MachinePrecision]}, N[(N[(N[(N[(0.3333333333333333 - N[(N[(-0.3333333333333333 * t$95$1 + N[(N[(t$95$2 + 1.0), $MachinePrecision] * (-t$95$1)), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps + N[(N[(N[(t$95$2 * eps + eps), $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[(t$95$1 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\cos x}^{2}\\
t_1 := {\sin x}^{2}\\
t_2 := \frac{t\_1}{t\_0}\\
\mathsf{fma}\left(\mathsf{fma}\left(\left(0.3333333333333333 - \frac{\mathsf{fma}\left(-0.3333333333333333, t\_1, \left(t\_2 + 1\right) \cdot \left(-t\_1\right)\right)}{t\_0}\right) \cdot \varepsilon, \varepsilon, \frac{\mathsf{fma}\left(\mathsf{fma}\left(t\_2, \varepsilon, \varepsilon\right), \sin x, \frac{t\_1}{\cos x}\right)}{\cos x}\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 63.7%
Taylor expanded in eps around 0
Applied rewrites99.9%
Applied rewrites99.9%
Taylor expanded in eps around 0
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (tan x) 2.0)) (t_1 (pow (sin x) 2.0)))
(fma
(fma
(*
(fma
(/ (* -0.6666666666666666 x) (cos x))
(- eps)
(-
-0.16666666666666666
(fma
0.16666666666666666
t_0
(fma (- t_0) (fma (tan x) (tan x) 1.0) (fma t_0 -0.5 -0.5)))))
eps)
eps
(/
(fma (fma (/ t_1 (pow (cos x) 2.0)) eps eps) (sin x) (/ t_1 (cos x)))
(cos x)))
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(tan(x), 2.0);
double t_1 = pow(sin(x), 2.0);
return fma(fma((fma(((-0.6666666666666666 * x) / cos(x)), -eps, (-0.16666666666666666 - fma(0.16666666666666666, t_0, fma(-t_0, fma(tan(x), tan(x), 1.0), fma(t_0, -0.5, -0.5))))) * eps), eps, (fma(fma((t_1 / pow(cos(x), 2.0)), eps, eps), sin(x), (t_1 / cos(x))) / cos(x))), eps, eps);
}
function code(x, eps) t_0 = tan(x) ^ 2.0 t_1 = sin(x) ^ 2.0 return fma(fma(Float64(fma(Float64(Float64(-0.6666666666666666 * x) / cos(x)), Float64(-eps), Float64(-0.16666666666666666 - fma(0.16666666666666666, t_0, fma(Float64(-t_0), fma(tan(x), tan(x), 1.0), fma(t_0, -0.5, -0.5))))) * eps), eps, Float64(fma(fma(Float64(t_1 / (cos(x) ^ 2.0)), eps, eps), sin(x), Float64(t_1 / cos(x))) / cos(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[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(N[(N[(N[(N[(-0.6666666666666666 * x), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * (-eps) + N[(-0.16666666666666666 - N[(0.16666666666666666 * t$95$0 + N[((-t$95$0) * N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision] + 1.0), $MachinePrecision] + N[(t$95$0 * -0.5 + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps + N[(N[(N[(N[(t$95$1 / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[(t$95$1 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
t_1 := {\sin x}^{2}\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-0.6666666666666666 \cdot x}{\cos x}, -\varepsilon, -0.16666666666666666 - \mathsf{fma}\left(0.16666666666666666, t\_0, \mathsf{fma}\left(-t\_0, \mathsf{fma}\left(\tan x, \tan x, 1\right), \mathsf{fma}\left(t\_0, -0.5, -0.5\right)\right)\right)\right) \cdot \varepsilon, \varepsilon, \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{t\_1}{{\cos x}^{2}}, \varepsilon, \varepsilon\right), \sin x, \frac{t\_1}{\cos x}\right)}{\cos x}\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 63.7%
Taylor expanded in eps around 0
Applied rewrites99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (sin x) 2.0)))
(fma
(fma
(* 0.3333333333333333 eps)
eps
(/
(fma (fma (/ t_0 (pow (cos x) 2.0)) eps eps) (sin x) (/ t_0 (cos x)))
(cos x)))
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0);
return fma(fma((0.3333333333333333 * eps), eps, (fma(fma((t_0 / pow(cos(x), 2.0)), eps, eps), sin(x), (t_0 / cos(x))) / cos(x))), eps, eps);
}
function code(x, eps) t_0 = sin(x) ^ 2.0 return fma(fma(Float64(0.3333333333333333 * eps), eps, Float64(fma(fma(Float64(t_0 / (cos(x) ^ 2.0)), eps, eps), sin(x), Float64(t_0 / cos(x))) / cos(x))), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(N[(0.3333333333333333 * eps), $MachinePrecision] * eps + N[(N[(N[(N[(t$95$0 / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[(t$95$0 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333 \cdot \varepsilon, \varepsilon, \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{t\_0}{{\cos x}^{2}}, \varepsilon, \varepsilon\right), \sin x, \frac{t\_0}{\cos x}\right)}{\cos x}\right), \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 63.7%
Taylor expanded in eps around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (sin x) 2.0)))
(fma
(/
(fma (fma (/ t_0 (pow (cos x) 2.0)) eps eps) (sin x) (/ t_0 (cos x)))
(cos x))
eps
eps)))
double code(double x, double eps) {
double t_0 = pow(sin(x), 2.0);
return fma((fma(fma((t_0 / pow(cos(x), 2.0)), eps, eps), sin(x), (t_0 / cos(x))) / cos(x)), eps, eps);
}
function code(x, eps) t_0 = sin(x) ^ 2.0 return fma(Float64(fma(fma(Float64(t_0 / (cos(x) ^ 2.0)), eps, eps), sin(x), Float64(t_0 / cos(x))) / cos(x)), eps, eps) end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(N[(N[(N[(t$95$0 / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[(t$95$0 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] * eps + eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin x}^{2}\\
\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{t\_0}{{\cos x}^{2}}, \varepsilon, \varepsilon\right), \sin x, \frac{t\_0}{\cos x}\right)}{\cos x}, \varepsilon, \varepsilon\right)
\end{array}
\end{array}
Initial program 63.7%
Taylor expanded in eps around 0
associate--l+N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites99.6%
(FPCore (x eps) :precision binary64 (+ (/ (* (pow (sin x) 2.0) eps) (pow (cos x) 2.0)) (/ (tan eps) (- 1.0 (* (tan eps) (tan x))))))
double code(double x, double eps) {
return ((pow(sin(x), 2.0) * eps) / pow(cos(x), 2.0)) + (tan(eps) / (1.0 - (tan(eps) * tan(x))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((sin(x) ** 2.0d0) * eps) / (cos(x) ** 2.0d0)) + (tan(eps) / (1.0d0 - (tan(eps) * tan(x))))
end function
public static double code(double x, double eps) {
return ((Math.pow(Math.sin(x), 2.0) * eps) / Math.pow(Math.cos(x), 2.0)) + (Math.tan(eps) / (1.0 - (Math.tan(eps) * Math.tan(x))));
}
def code(x, eps): return ((math.pow(math.sin(x), 2.0) * eps) / math.pow(math.cos(x), 2.0)) + (math.tan(eps) / (1.0 - (math.tan(eps) * math.tan(x))))
function code(x, eps) return Float64(Float64(Float64((sin(x) ^ 2.0) * eps) / (cos(x) ^ 2.0)) + Float64(tan(eps) / Float64(1.0 - Float64(tan(eps) * tan(x))))) end
function tmp = code(x, eps) tmp = (((sin(x) ^ 2.0) * eps) / (cos(x) ^ 2.0)) + (tan(eps) / (1.0 - (tan(eps) * tan(x)))); end
code[x_, eps_] := N[(N[(N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * eps), $MachinePrecision] / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Tan[eps], $MachinePrecision] / N[(1.0 - N[(N[Tan[eps], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\sin x}^{2} \cdot \varepsilon}{{\cos x}^{2}} + \frac{\tan \varepsilon}{1 - \tan \varepsilon \cdot \tan x}
\end{array}
Initial program 63.7%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-tan.f64N/A
lift-+.f64N/A
tan-sumN/A
lift-tan.f64N/A
div-addN/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites98.7%
Taylor expanded in eps around 0
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
sin-PIN/A
lower-+.f64N/A
sin-PIN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (fma (PI) 0.5 x)))
(fma
eps
(/ (pow (sin x) 2.0) (/ (+ (sin (- t_0 x)) (sin (+ t_0 x))) 2.0))
eps)))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, x\right)\\
\mathsf{fma}\left(\varepsilon, \frac{{\sin x}^{2}}{\frac{\sin \left(t\_0 - x\right) + \sin \left(t\_0 + x\right)}{2}}, \varepsilon\right)
\end{array}
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (fma eps (/ (pow (sin x) 2.0) (- 0.5 (* 0.5 (cos (* 2.0 (+ (fma (PI) 0.5 x) (PI))))))) eps))
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \frac{{\sin x}^{2}}{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, x\right) + \mathsf{PI}\left(\right)\right)\right)}, \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (fma eps (/ (pow (sin x) 2.0) (+ 0.5 (* 0.5 (cos (* 2.0 (+ (PI) x)))))) eps))
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \frac{{\sin x}^{2}}{0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\mathsf{PI}\left(\right) + x\right)\right)}, \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (fma eps (/ (- 0.5 (* 0.5 (cos (* 2.0 (+ (PI) x))))) (pow (cos x) 2.0)) eps))
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \frac{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\mathsf{PI}\left(\right) + x\right)\right)}{{\cos x}^{2}}, \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (fma eps (/ (* (tan x) (sin x)) (cos x)) eps))
double code(double x, double eps) {
return fma(eps, ((tan(x) * sin(x)) / cos(x)), eps);
}
function code(x, eps) return fma(eps, Float64(Float64(tan(x) * sin(x)) / cos(x)), eps) end
code[x_, eps_] := N[(eps * N[(N[(N[Tan[x], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \frac{\tan x \cdot \sin x}{\cos x}, \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (fma (pow (tan x) 2.0) eps eps))
double code(double x, double eps) {
return fma(pow(tan(x), 2.0), eps, eps);
}
function code(x, eps) return fma((tan(x) ^ 2.0), eps, eps) end
code[x_, eps_] := N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] * eps + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left({\tan x}^{2}, \varepsilon, \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (x eps)
:precision binary64
(fma
eps
(*
(fma
(fma
(fma 0.19682539682539682 (* x x) 0.37777777777777777)
(* x x)
0.6666666666666666)
(* x x)
1.0)
(* x x))
eps))
double code(double x, double eps) {
return fma(eps, (fma(fma(fma(0.19682539682539682, (x * x), 0.37777777777777777), (x * x), 0.6666666666666666), (x * x), 1.0) * (x * x)), eps);
}
function code(x, eps) return fma(eps, Float64(fma(fma(fma(0.19682539682539682, Float64(x * x), 0.37777777777777777), Float64(x * x), 0.6666666666666666), Float64(x * x), 1.0) * Float64(x * x)), eps) end
code[x_, eps_] := N[(eps * N[(N[(N[(N[(0.19682539682539682 * N[(x * x), $MachinePrecision] + 0.37777777777777777), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.19682539682539682, x \cdot x, 0.37777777777777777\right), x \cdot x, 0.6666666666666666\right), x \cdot x, 1\right) \cdot \left(x \cdot x\right), \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites97.8%
Final simplification97.8%
(FPCore (x eps) :precision binary64 (fma eps (* (fma (fma 0.37777777777777777 (* x x) 0.6666666666666666) (* x x) 1.0) (* x x)) eps))
double code(double x, double eps) {
return fma(eps, (fma(fma(0.37777777777777777, (x * x), 0.6666666666666666), (x * x), 1.0) * (x * x)), eps);
}
function code(x, eps) return fma(eps, Float64(fma(fma(0.37777777777777777, Float64(x * x), 0.6666666666666666), Float64(x * x), 1.0) * Float64(x * x)), eps) end
code[x_, eps_] := N[(eps * N[(N[(N[(0.37777777777777777 * N[(x * x), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(\mathsf{fma}\left(0.37777777777777777, x \cdot x, 0.6666666666666666\right), x \cdot x, 1\right) \cdot \left(x \cdot x\right), \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites97.8%
Final simplification97.8%
(FPCore (x eps) :precision binary64 (fma eps (* (fma 0.6666666666666666 (* x x) 1.0) (* x x)) eps))
double code(double x, double eps) {
return fma(eps, (fma(0.6666666666666666, (x * x), 1.0) * (x * x)), eps);
}
function code(x, eps) return fma(eps, Float64(fma(0.6666666666666666, Float64(x * x), 1.0) * Float64(x * x)), eps) end
code[x_, eps_] := N[(eps * N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 1\right) \cdot \left(x \cdot x\right), \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites97.8%
Final simplification97.8%
(FPCore (x eps) :precision binary64 (fma eps (* x x) eps))
double code(double x, double eps) {
return fma(eps, (x * x), eps);
}
function code(x, eps) return fma(eps, Float64(x * x), eps) end
code[x_, eps_] := N[(eps * N[(x * x), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, x \cdot x, \varepsilon\right)
\end{array}
Initial program 63.7%
lift--.f64N/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
lift-tan.f64N/A
tan-quotN/A
clear-numN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites38.0%
Taylor expanded in eps around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-/l*N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-pow.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites97.7%
Final simplification97.7%
(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 63.7%
lift-tan.f64N/A
tan-+PI-revN/A
lower-tan.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-PI.f647.6
Applied rewrites7.6%
Taylor expanded in eps around 0
sub-negN/A
neg-mul-1N/A
sin-+PIN/A
distribute-frac-negN/A
cos-+PIN/A
distribute-neg-frac2N/A
remove-double-negN/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lft5.3
Applied rewrites5.3%
Final simplification5.3%
(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 2024305
(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)))