
(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 (/ (sin eps) (* (cos x) (fma (cos x) (cos eps) (* (sin x) (- 0.0 (sin eps)))))))
double code(double x, double eps) {
return sin(eps) / (cos(x) * fma(cos(x), cos(eps), (sin(x) * (0.0 - sin(eps)))));
}
function code(x, eps) return Float64(sin(eps) / Float64(cos(x) * fma(cos(x), cos(eps), Float64(sin(x) * Float64(0.0 - sin(eps)))))) end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(0.0 - N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos x \cdot \mathsf{fma}\left(\cos x, \cos \varepsilon, \sin x \cdot \left(0 - \sin \varepsilon\right)\right)}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in x around 0
Simplified99.8%
cos-sumN/A
cancel-sign-sub-invN/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64100.0
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (tan (+ eps x)) (tan x))))
(if (<= t_0 2e-11)
(fma
eps
(fma
0.3333333333333333
(* eps eps)
(* x (fma eps (fma 0.6666666666666666 (* eps eps) 1.0) x)))
eps)
t_0)))
double code(double x, double eps) {
double t_0 = tan((eps + x)) - tan(x);
double tmp;
if (t_0 <= 2e-11) {
tmp = fma(eps, fma(0.3333333333333333, (eps * eps), (x * fma(eps, fma(0.6666666666666666, (eps * eps), 1.0), x))), eps);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(tan(Float64(eps + x)) - tan(x)) tmp = 0.0 if (t_0 <= 2e-11) tmp = fma(eps, fma(0.3333333333333333, Float64(eps * eps), Float64(x * fma(eps, fma(0.6666666666666666, Float64(eps * eps), 1.0), x))), eps); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Tan[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-11], N[(eps * N[(0.3333333333333333 * N[(eps * eps), $MachinePrecision] + N[(x * N[(eps * N[(0.6666666666666666 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(\varepsilon + x\right) - \tan x\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(0.3333333333333333, \varepsilon \cdot \varepsilon, x \cdot \mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(0.6666666666666666, \varepsilon \cdot \varepsilon, 1\right), x\right)\right), \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (tan.f64 (+.f64 x eps)) (tan.f64 x)) < 1.99999999999999988e-11Initial program 60.4%
Taylor expanded in eps around 0
Simplified100.0%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in x around 0
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
if 1.99999999999999988e-11 < (-.f64 (tan.f64 (+.f64 x eps)) (tan.f64 x)) Initial program 76.6%
Final simplification98.9%
(FPCore (x eps) :precision binary64 (/ (sin eps) (* (cos x) (cos (+ eps x)))))
double code(double x, double eps) {
return sin(eps) / (cos(x) * cos((eps + x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps) / (cos(x) * cos((eps + x)))
end function
public static double code(double x, double eps) {
return Math.sin(eps) / (Math.cos(x) * Math.cos((eps + x)));
}
def code(x, eps): return math.sin(eps) / (math.cos(x) * math.cos((eps + x)))
function code(x, eps) return Float64(sin(eps) / Float64(cos(x) * cos(Float64(eps + x)))) end
function tmp = code(x, eps) tmp = sin(eps) / (cos(x) * cos((eps + x))); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin \varepsilon}{\cos x \cdot \cos \left(\varepsilon + x\right)}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in x around 0
Simplified99.8%
Final simplification99.8%
(FPCore (x eps)
:precision binary64
(/
(*
eps
(fma
(* eps eps)
(fma
(* eps eps)
(fma (* eps eps) -0.0001984126984126984 0.008333333333333333)
-0.16666666666666666)
1.0))
(* (cos x) (cos (+ eps x)))))
double code(double x, double eps) {
return (eps * fma((eps * eps), fma((eps * eps), fma((eps * eps), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0)) / (cos(x) * cos((eps + x)));
}
function code(x, eps) return Float64(Float64(eps * fma(Float64(eps * eps), fma(Float64(eps * eps), fma(Float64(eps * eps), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), 1.0)) / Float64(cos(x) * cos(Float64(eps + x)))) end
code[x_, eps_] := N[(N[(eps * N[(N[(eps * eps), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon \cdot \mathsf{fma}\left(\varepsilon \cdot \varepsilon, \mathsf{fma}\left(\varepsilon \cdot \varepsilon, \mathsf{fma}\left(\varepsilon \cdot \varepsilon, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), 1\right)}{\cos x \cdot \cos \left(\varepsilon + x\right)}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.8
Simplified99.8%
Final simplification99.8%
(FPCore (x eps)
:precision binary64
(/
(*
eps
(fma
eps
(* eps (fma (* eps eps) 0.008333333333333333 -0.16666666666666666))
1.0))
(* (cos x) (cos (+ eps x)))))
double code(double x, double eps) {
return (eps * fma(eps, (eps * fma((eps * eps), 0.008333333333333333, -0.16666666666666666)), 1.0)) / (cos(x) * cos((eps + x)));
}
function code(x, eps) return Float64(Float64(eps * fma(eps, Float64(eps * fma(Float64(eps * eps), 0.008333333333333333, -0.16666666666666666)), 1.0)) / Float64(cos(x) * cos(Float64(eps + x)))) end
code[x_, eps_] := N[(N[(eps * N[(eps * N[(eps * N[(N[(eps * eps), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon \cdot \mathsf{fma}\left(\varepsilon, \varepsilon \cdot \mathsf{fma}\left(\varepsilon \cdot \varepsilon, 0.008333333333333333, -0.16666666666666666\right), 1\right)}{\cos x \cdot \cos \left(\varepsilon + x\right)}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6499.7
Simplified99.7%
Final simplification99.7%
(FPCore (x eps) :precision binary64 (/ (* eps (fma eps (* eps -0.16666666666666666) 1.0)) (* (cos x) (cos (+ eps x)))))
double code(double x, double eps) {
return (eps * fma(eps, (eps * -0.16666666666666666), 1.0)) / (cos(x) * cos((eps + x)));
}
function code(x, eps) return Float64(Float64(eps * fma(eps, Float64(eps * -0.16666666666666666), 1.0)) / Float64(cos(x) * cos(Float64(eps + x)))) end
code[x_, eps_] := N[(N[(eps * N[(eps * N[(eps * -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon \cdot \mathsf{fma}\left(\varepsilon, \varepsilon \cdot -0.16666666666666666, 1\right)}{\cos x \cdot \cos \left(\varepsilon + x\right)}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6499.4
Simplified99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (/ eps (* (cos x) (cos (+ eps x)))))
double code(double x, double eps) {
return eps / (cos(x) * cos((eps + x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps / (cos(x) * cos((eps + x)))
end function
public static double code(double x, double eps) {
return eps / (Math.cos(x) * Math.cos((eps + x)));
}
def code(x, eps): return eps / (math.cos(x) * math.cos((eps + x)))
function code(x, eps) return Float64(eps / Float64(cos(x) * cos(Float64(eps + x)))) end
function tmp = code(x, eps) tmp = eps / (cos(x) * cos((eps + x))); end
code[x_, eps_] := N[(eps / N[(N[Cos[x], $MachinePrecision] * N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon}{\cos x \cdot \cos \left(\varepsilon + x\right)}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in eps around 0
Simplified98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (/ eps (pow (cos x) 2.0)))
double code(double x, double eps) {
return eps / pow(cos(x), 2.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps / (cos(x) ** 2.0d0)
end function
public static double code(double x, double eps) {
return eps / Math.pow(Math.cos(x), 2.0);
}
def code(x, eps): return eps / math.pow(math.cos(x), 2.0)
function code(x, eps) return Float64(eps / (cos(x) ^ 2.0)) end
function tmp = code(x, eps) tmp = eps / (cos(x) ^ 2.0); end
code[x_, eps_] := N[(eps / N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\varepsilon}{{\cos x}^{2}}
\end{array}
Initial program 61.2%
tan-quotN/A
tan-quotN/A
frac-subN/A
/-lowering-/.f64N/A
sin-diffN/A
sin-lowering-sin.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
cos-lowering-cos.f64N/A
+-lowering-+.f6461.1
Applied egg-rr61.1%
Taylor expanded in eps around 0
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
cos-lowering-cos.f6497.7
Simplified97.7%
(FPCore (x eps) :precision binary64 (fma x (fma x (fma eps (* 0.6666666666666666 (* x x)) eps) (* eps (* eps (fma 0.6666666666666666 (* eps eps) 1.0)))) (* eps (fma 0.3333333333333333 (* eps eps) 1.0))))
double code(double x, double eps) {
return fma(x, fma(x, fma(eps, (0.6666666666666666 * (x * x)), eps), (eps * (eps * fma(0.6666666666666666, (eps * eps), 1.0)))), (eps * fma(0.3333333333333333, (eps * eps), 1.0)));
}
function code(x, eps) return fma(x, fma(x, fma(eps, Float64(0.6666666666666666 * Float64(x * x)), eps), Float64(eps * Float64(eps * fma(0.6666666666666666, Float64(eps * eps), 1.0)))), Float64(eps * fma(0.3333333333333333, Float64(eps * eps), 1.0))) end
code[x_, eps_] := N[(x * N[(x * N[(eps * N[(0.6666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] + N[(eps * N[(eps * N[(0.6666666666666666 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(0.3333333333333333 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(\varepsilon, 0.6666666666666666 \cdot \left(x \cdot x\right), \varepsilon\right), \varepsilon \cdot \left(\varepsilon \cdot \mathsf{fma}\left(0.6666666666666666, \varepsilon \cdot \varepsilon, 1\right)\right)\right), \varepsilon \cdot \mathsf{fma}\left(0.3333333333333333, \varepsilon \cdot \varepsilon, 1\right)\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
Simplified97.2%
(FPCore (x eps)
:precision binary64
(fma
eps
(fma
0.3333333333333333
(* eps eps)
(*
x
(fma
x
(fma x (* x 0.6666666666666666) 1.0)
(* eps (fma 0.6666666666666666 (* eps eps) 1.0)))))
eps))
double code(double x, double eps) {
return fma(eps, fma(0.3333333333333333, (eps * eps), (x * fma(x, fma(x, (x * 0.6666666666666666), 1.0), (eps * fma(0.6666666666666666, (eps * eps), 1.0))))), eps);
}
function code(x, eps) return fma(eps, fma(0.3333333333333333, Float64(eps * eps), Float64(x * fma(x, fma(x, Float64(x * 0.6666666666666666), 1.0), Float64(eps * fma(0.6666666666666666, Float64(eps * eps), 1.0))))), eps) end
code[x_, eps_] := N[(eps * N[(0.3333333333333333 * N[(eps * eps), $MachinePrecision] + N[(x * N[(x * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 1.0), $MachinePrecision] + N[(eps * N[(0.6666666666666666 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(0.3333333333333333, \varepsilon \cdot \varepsilon, x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 1\right), \varepsilon \cdot \mathsf{fma}\left(0.6666666666666666, \varepsilon \cdot \varepsilon, 1\right)\right)\right), \varepsilon\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6497.2
Simplified97.2%
(FPCore (x eps) :precision binary64 (fma x (* eps (fma x (fma x (* x 0.6666666666666666) 1.0) eps)) (* eps (fma 0.3333333333333333 (* eps eps) 1.0))))
double code(double x, double eps) {
return fma(x, (eps * fma(x, fma(x, (x * 0.6666666666666666), 1.0), eps)), (eps * fma(0.3333333333333333, (eps * eps), 1.0)));
}
function code(x, eps) return fma(x, Float64(eps * fma(x, fma(x, Float64(x * 0.6666666666666666), 1.0), eps)), Float64(eps * fma(0.3333333333333333, Float64(eps * eps), 1.0))) end
code[x_, eps_] := N[(x * N[(eps * N[(x * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 1.0), $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(0.3333333333333333 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \varepsilon \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 1\right), \varepsilon\right), \varepsilon \cdot \mathsf{fma}\left(0.3333333333333333, \varepsilon \cdot \varepsilon, 1\right)\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
Simplified97.2%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6497.2
Simplified97.2%
(FPCore (x eps) :precision binary64 (* eps (fma eps (fma eps 0.3333333333333333 x) (fma x (* x (fma x (* x 0.6666666666666666) 1.0)) 1.0))))
double code(double x, double eps) {
return eps * fma(eps, fma(eps, 0.3333333333333333, x), fma(x, (x * fma(x, (x * 0.6666666666666666), 1.0)), 1.0));
}
function code(x, eps) return Float64(eps * fma(eps, fma(eps, 0.3333333333333333, x), fma(x, Float64(x * fma(x, Float64(x * 0.6666666666666666), 1.0)), 1.0))) end
code[x_, eps_] := N[(eps * N[(eps * N[(eps * 0.3333333333333333 + x), $MachinePrecision] + N[(x * N[(x * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(\varepsilon, 0.3333333333333333, x\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 1\right), 1\right)\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
Simplified97.2%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
Simplified97.2%
(FPCore (x eps) :precision binary64 (* eps (fma eps x (fma x (* x (fma x (* x 0.6666666666666666) 1.0)) 1.0))))
double code(double x, double eps) {
return eps * fma(eps, x, fma(x, (x * fma(x, (x * 0.6666666666666666), 1.0)), 1.0));
}
function code(x, eps) return Float64(eps * fma(eps, x, fma(x, Float64(x * fma(x, Float64(x * 0.6666666666666666), 1.0)), 1.0))) end
code[x_, eps_] := N[(eps * N[(eps * x + N[(x * N[(x * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \mathsf{fma}\left(\varepsilon, x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 1\right), 1\right)\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
Simplified97.2%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6497.0
Simplified97.0%
(FPCore (x eps) :precision binary64 (* eps (fma x (* x (fma x (* x 0.6666666666666666) 1.0)) 1.0)))
double code(double x, double eps) {
return eps * fma(x, (x * fma(x, (x * 0.6666666666666666), 1.0)), 1.0);
}
function code(x, eps) return Float64(eps * fma(x, Float64(x * fma(x, Float64(x * 0.6666666666666666), 1.0)), 1.0)) end
code[x_, eps_] := N[(eps * N[(x * N[(x * N[(x * N[(x * 0.6666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 1\right), 1\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
Simplified97.2%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f6496.8
Simplified96.8%
(FPCore (x eps) :precision binary64 (fma eps (* (* eps eps) 0.3333333333333333) eps))
double code(double x, double eps) {
return fma(eps, ((eps * eps) * 0.3333333333333333), eps);
}
function code(x, eps) return fma(eps, Float64(Float64(eps * eps) * 0.3333333333333333), eps) end
code[x_, eps_] := N[(eps * N[(N[(eps * eps), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\varepsilon, \left(\varepsilon \cdot \varepsilon\right) \cdot 0.3333333333333333, \varepsilon\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6496.5
Simplified96.5%
Final simplification96.5%
(FPCore (x eps) :precision binary64 (* eps (fma 0.3333333333333333 (* eps eps) 1.0)))
double code(double x, double eps) {
return eps * fma(0.3333333333333333, (eps * eps), 1.0);
}
function code(x, eps) return Float64(eps * fma(0.3333333333333333, Float64(eps * eps), 1.0)) end
code[x_, eps_] := N[(eps * N[(0.3333333333333333 * N[(eps * eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \mathsf{fma}\left(0.3333333333333333, \varepsilon \cdot \varepsilon, 1\right)
\end{array}
Initial program 61.2%
Taylor expanded in eps around 0
Simplified99.4%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9
Simplified97.9%
Taylor expanded in x around 0
*-rgt-identityN/A
cube-multN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6496.5
Simplified96.5%
(FPCore (x eps) :precision binary64 (- 0.0 x))
double code(double x, double eps) {
return 0.0 - x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0 - x
end function
public static double code(double x, double eps) {
return 0.0 - x;
}
def code(x, eps): return 0.0 - x
function code(x, eps) return Float64(0.0 - x) end
function tmp = code(x, eps) tmp = 0.0 - x; end
code[x_, eps_] := N[(0.0 - x), $MachinePrecision]
\begin{array}{l}
\\
0 - x
\end{array}
Initial program 61.2%
Taylor expanded in x around 0
Simplified58.3%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f648.0
Simplified8.0%
sub0-negN/A
neg-lowering-neg.f648.0
Applied egg-rr8.0%
Final simplification8.0%
(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}
(FPCore (x eps) :precision binary64 (- (/ (+ (tan x) (tan eps)) (- 1.0 (* (tan x) (tan eps)))) (tan x)))
double code(double x, double eps) {
return ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((tan(x) + tan(eps)) / (1.0d0 - (tan(x) * tan(eps)))) - tan(x)
end function
public static double code(double x, double eps) {
return ((Math.tan(x) + Math.tan(eps)) / (1.0 - (Math.tan(x) * Math.tan(eps)))) - Math.tan(x);
}
def code(x, eps): return ((math.tan(x) + math.tan(eps)) / (1.0 - (math.tan(x) * math.tan(eps)))) - math.tan(x)
function code(x, eps) return Float64(Float64(Float64(tan(x) + tan(eps)) / Float64(1.0 - Float64(tan(x) * tan(eps)))) - tan(x)) end
function tmp = code(x, eps) tmp = ((tan(x) + tan(eps)) / (1.0 - (tan(x) * tan(eps)))) - tan(x); end
code[x_, eps_] := N[(N[(N[(N[Tan[x], $MachinePrecision] + N[Tan[eps], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[x], $MachinePrecision] * N[Tan[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x
\end{array}
(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 2024194
(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 (/ (sin eps) (* (cos x) (cos (+ x eps)))))
:alt
(! :herbie-platform default (- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x)))
:alt
(! :herbie-platform default (+ eps (* eps (tan x) (tan x))))
(- (tan (+ x eps)) (tan x)))