
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= eps -0.0055)
(- (* (cos eps) (cos x)) (fma (sin eps) (sin x) (cos x)))
(if (<= eps 0.0048)
(-
(*
(cos x)
(+ (* -0.5 (pow eps 2.0)) (* 0.041666666666666664 (pow eps 4.0))))
(* (sin eps) (sin x)))
(fma (cos x) (+ -1.0 (cos eps)) (* (sin eps) (- (sin x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0055) {
tmp = (cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x));
} else if (eps <= 0.0048) {
tmp = (cos(x) * ((-0.5 * pow(eps, 2.0)) + (0.041666666666666664 * pow(eps, 4.0)))) - (sin(eps) * sin(x));
} else {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -0.0055) tmp = Float64(Float64(cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x))); elseif (eps <= 0.0048) tmp = Float64(Float64(cos(x) * Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(0.041666666666666664 * (eps ^ 4.0)))) - Float64(sin(eps) * sin(x))); else tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.0055], N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0048], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0055:\\
\;\;\;\;\cos \varepsilon \cdot \cos x - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0048:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2} + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -0.0054999999999999997Initial program 49.4%
sub-neg49.4%
cos-sum99.1%
associate-+l-99.1%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg99.1%
*-commutative99.1%
*-commutative99.1%
fma-neg99.1%
remove-double-neg99.1%
Simplified99.1%
if -0.0054999999999999997 < eps < 0.00479999999999999958Initial program 25.7%
sub-neg25.7%
cos-sum27.0%
associate-+l-27.0%
fma-neg27.0%
Applied egg-rr27.0%
fma-neg27.0%
*-commutative27.0%
*-commutative27.0%
fma-neg27.0%
remove-double-neg27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--r+79.6%
*-commutative79.6%
*-rgt-identity79.6%
distribute-lft-out--79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in eps around 0 99.9%
if 0.00479999999999999958 < eps Initial program 46.5%
sub-neg46.5%
cos-sum98.7%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in x around inf 98.9%
fma-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (- (/ (pow (sin eps) 2.0) (/ (- -1.0 (cos eps)) (cos x))) (* (sin eps) (sin x))))
double code(double x, double eps) {
return (pow(sin(eps), 2.0) / ((-1.0 - cos(eps)) / cos(x))) - (sin(eps) * sin(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((sin(eps) ** 2.0d0) / (((-1.0d0) - cos(eps)) / cos(x))) - (sin(eps) * sin(x))
end function
public static double code(double x, double eps) {
return (Math.pow(Math.sin(eps), 2.0) / ((-1.0 - Math.cos(eps)) / Math.cos(x))) - (Math.sin(eps) * Math.sin(x));
}
def code(x, eps): return (math.pow(math.sin(eps), 2.0) / ((-1.0 - math.cos(eps)) / math.cos(x))) - (math.sin(eps) * math.sin(x))
function code(x, eps) return Float64(Float64((sin(eps) ^ 2.0) / Float64(Float64(-1.0 - cos(eps)) / cos(x))) - Float64(sin(eps) * sin(x))) end
function tmp = code(x, eps) tmp = ((sin(eps) ^ 2.0) / ((-1.0 - cos(eps)) / cos(x))) - (sin(eps) * sin(x)); end
code[x_, eps_] := N[(N[(N[Power[N[Sin[eps], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(-1.0 - N[Cos[eps], $MachinePrecision]), $MachinePrecision] / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\sin \varepsilon}^{2}}{\frac{-1 - \cos \varepsilon}{\cos x}} - \sin \varepsilon \cdot \sin x
\end{array}
Initial program 37.9%
sub-neg37.9%
cos-sum66.3%
associate-+l-66.3%
fma-neg66.3%
Applied egg-rr66.3%
fma-neg66.3%
*-commutative66.3%
*-commutative66.3%
fma-neg66.3%
remove-double-neg66.3%
Simplified66.3%
Taylor expanded in eps around inf 66.3%
associate--r+90.2%
*-commutative90.2%
*-rgt-identity90.2%
distribute-lft-out--90.2%
sub-neg90.2%
metadata-eval90.2%
+-commutative90.2%
*-commutative90.2%
Simplified90.2%
flip-+89.7%
associate-*r/89.7%
metadata-eval89.7%
1-sub-cos99.0%
pow299.0%
Applied egg-rr99.0%
*-commutative99.0%
associate-/l*98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (<= eps -0.0055)
(- (- (* (cos eps) (cos x)) t_0) (cos x))
(if (<= eps 0.0048)
(-
(*
(cos x)
(+ (* -0.5 (pow eps 2.0)) (* 0.041666666666666664 (pow eps 4.0))))
t_0)
(fma (cos x) (+ -1.0 (cos eps)) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if (eps <= -0.0055) {
tmp = ((cos(eps) * cos(x)) - t_0) - cos(x);
} else if (eps <= 0.0048) {
tmp = (cos(x) * ((-0.5 * pow(eps, 2.0)) + (0.041666666666666664 * pow(eps, 4.0)))) - t_0;
} else {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -0.0055) tmp = Float64(Float64(Float64(cos(eps) * cos(x)) - t_0) - cos(x)); elseif (eps <= 0.0048) tmp = Float64(Float64(cos(x) * Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(0.041666666666666664 * (eps ^ 4.0)))) - t_0); else tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0055], N[(N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0048], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.0055:\\
\;\;\;\;\left(\cos \varepsilon \cdot \cos x - t_0\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.0048:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2} + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -0.0054999999999999997Initial program 49.4%
cos-sum99.1%
Applied egg-rr99.1%
if -0.0054999999999999997 < eps < 0.00479999999999999958Initial program 25.7%
sub-neg25.7%
cos-sum27.0%
associate-+l-27.0%
fma-neg27.0%
Applied egg-rr27.0%
fma-neg27.0%
*-commutative27.0%
*-commutative27.0%
fma-neg27.0%
remove-double-neg27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--r+79.6%
*-commutative79.6%
*-rgt-identity79.6%
distribute-lft-out--79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in eps around 0 99.9%
if 0.00479999999999999958 < eps Initial program 46.5%
sub-neg46.5%
cos-sum98.7%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in x around inf 98.9%
fma-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00016) (not (<= eps 0.00018))) (fma (cos x) (+ -1.0 (cos eps)) (* (sin eps) (- (sin x)))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* (sin eps) (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00016) || !(eps <= 0.00018)) {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(eps) * -sin(x)));
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (sin(eps) * sin(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.00016) || !(eps <= 0.00018)) tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(eps) * Float64(-sin(x)))); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(sin(eps) * sin(x))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00016], N[Not[LessEqual[eps, 0.00018]], $MachinePrecision]], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00016 \lor \neg \left(\varepsilon \leq 0.00018\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \sin \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -1.60000000000000013e-4 or 1.80000000000000011e-4 < eps Initial program 47.6%
sub-neg47.6%
cos-sum98.8%
associate-+l-98.8%
fma-neg98.8%
Applied egg-rr98.8%
fma-neg98.8%
*-commutative98.8%
*-commutative98.8%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.8%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in x around inf 98.9%
fma-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
if -1.60000000000000013e-4 < eps < 1.80000000000000011e-4Initial program 25.9%
sub-neg25.9%
cos-sum26.5%
associate-+l-26.5%
fma-neg26.5%
Applied egg-rr26.5%
fma-neg26.5%
*-commutative26.5%
*-commutative26.5%
fma-neg26.5%
remove-double-neg26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.5%
associate--r+79.6%
*-commutative79.6%
*-rgt-identity79.6%
distribute-lft-out--79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in eps around 0 99.7%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (<= eps -0.00016)
(- (* (cos eps) (cos x)) (+ (cos x) t_0))
(if (<= eps 0.00018)
(- (* (cos x) (* -0.5 (pow eps 2.0))) t_0)
(fma (cos x) (+ -1.0 (cos eps)) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if (eps <= -0.00016) {
tmp = (cos(eps) * cos(x)) - (cos(x) + t_0);
} else if (eps <= 0.00018) {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - t_0;
} else {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -0.00016) tmp = Float64(Float64(cos(eps) * cos(x)) - Float64(cos(x) + t_0)); elseif (eps <= 0.00018) tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - t_0); else tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00016], N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00018], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.00016:\\
\;\;\;\;\cos \varepsilon \cdot \cos x - \left(\cos x + t_0\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00018:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -1.60000000000000013e-4Initial program 48.7%
expm1-log1p-u29.0%
Applied egg-rr29.0%
expm1-log1p-u48.7%
cos-sum98.9%
*-commutative98.9%
associate--l-98.8%
Applied egg-rr98.8%
if -1.60000000000000013e-4 < eps < 1.80000000000000011e-4Initial program 25.9%
sub-neg25.9%
cos-sum26.5%
associate-+l-26.5%
fma-neg26.5%
Applied egg-rr26.5%
fma-neg26.5%
*-commutative26.5%
*-commutative26.5%
fma-neg26.5%
remove-double-neg26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.5%
associate--r+79.6%
*-commutative79.6%
*-rgt-identity79.6%
distribute-lft-out--79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in eps around 0 99.7%
if 1.80000000000000011e-4 < eps Initial program 46.5%
sub-neg46.5%
cos-sum98.7%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in x around inf 98.9%
fma-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (<= eps -0.00016)
(- (- (* (cos eps) (cos x)) t_0) (cos x))
(if (<= eps 0.00018)
(- (* (cos x) (* -0.5 (pow eps 2.0))) t_0)
(fma (cos x) (+ -1.0 (cos eps)) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if (eps <= -0.00016) {
tmp = ((cos(eps) * cos(x)) - t_0) - cos(x);
} else if (eps <= 0.00018) {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - t_0;
} else {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -0.00016) tmp = Float64(Float64(Float64(cos(eps) * cos(x)) - t_0) - cos(x)); elseif (eps <= 0.00018) tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - t_0); else tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00016], N[(N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00018], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.00016:\\
\;\;\;\;\left(\cos \varepsilon \cdot \cos x - t_0\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.00018:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -1.60000000000000013e-4Initial program 48.7%
cos-sum98.9%
Applied egg-rr98.9%
if -1.60000000000000013e-4 < eps < 1.80000000000000011e-4Initial program 25.9%
sub-neg25.9%
cos-sum26.5%
associate-+l-26.5%
fma-neg26.5%
Applied egg-rr26.5%
fma-neg26.5%
*-commutative26.5%
*-commutative26.5%
fma-neg26.5%
remove-double-neg26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.5%
associate--r+79.6%
*-commutative79.6%
*-rgt-identity79.6%
distribute-lft-out--79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in eps around 0 99.7%
if 1.80000000000000011e-4 < eps Initial program 46.5%
sub-neg46.5%
cos-sum98.7%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in x around inf 98.9%
fma-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (or (<= eps -0.00016) (not (<= eps 0.00018)))
(- (* (cos x) (+ -1.0 (cos eps))) t_0)
(- (* (cos x) (* -0.5 (pow eps 2.0))) t_0))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if ((eps <= -0.00016) || !(eps <= 0.00018)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - t_0;
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin(eps) * sin(x)
if ((eps <= (-0.00016d0)) .or. (.not. (eps <= 0.00018d0))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - t_0
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) * Math.sin(x);
double tmp;
if ((eps <= -0.00016) || !(eps <= 0.00018)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - t_0;
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) * math.sin(x) tmp = 0 if (eps <= -0.00016) or not (eps <= 0.00018): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - t_0 else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if ((eps <= -0.00016) || !(eps <= 0.00018)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - t_0); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) * sin(x); tmp = 0.0; if ((eps <= -0.00016) || ~((eps <= 0.00018))) tmp = (cos(x) * (-1.0 + cos(eps))) - t_0; else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.00016], N[Not[LessEqual[eps, 0.00018]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.00016 \lor \neg \left(\varepsilon \leq 0.00018\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - t_0\\
\end{array}
\end{array}
if eps < -1.60000000000000013e-4 or 1.80000000000000011e-4 < eps Initial program 47.6%
sub-neg47.6%
cos-sum98.8%
associate-+l-98.8%
fma-neg98.8%
Applied egg-rr98.8%
fma-neg98.8%
*-commutative98.8%
*-commutative98.8%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.8%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
if -1.60000000000000013e-4 < eps < 1.80000000000000011e-4Initial program 25.9%
sub-neg25.9%
cos-sum26.5%
associate-+l-26.5%
fma-neg26.5%
Applied egg-rr26.5%
fma-neg26.5%
*-commutative26.5%
*-commutative26.5%
fma-neg26.5%
remove-double-neg26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.5%
associate--r+79.6%
*-commutative79.6%
*-rgt-identity79.6%
distribute-lft-out--79.5%
sub-neg79.5%
metadata-eval79.5%
+-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in eps around 0 99.7%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.1e-13) (not (<= x 3.8e-28))) (- (* (cos x) (+ -1.0 (cos eps))) (* (sin eps) (sin x))) (* (sin (* 0.5 (fma 2.0 x eps))) (* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.1e-13) || !(x <= 3.8e-28)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x));
} else {
tmp = sin((0.5 * fma(2.0, x, eps))) * (-2.0 * sin((eps * 0.5)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((x <= -2.1e-13) || !(x <= 3.8e-28)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(eps) * sin(x))); else tmp = Float64(sin(Float64(0.5 * fma(2.0, x, eps))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, -2.1e-13], N[Not[LessEqual[x, 3.8e-28]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-13} \lor \neg \left(x \leq 3.8 \cdot 10^{-28}\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if x < -2.09999999999999989e-13 or 3.80000000000000009e-28 < x Initial program 7.9%
sub-neg7.9%
cos-sum61.9%
associate-+l-61.9%
fma-neg61.9%
Applied egg-rr61.9%
fma-neg61.9%
*-commutative61.9%
*-commutative61.9%
fma-neg61.9%
remove-double-neg61.9%
Simplified61.9%
Taylor expanded in eps around inf 61.9%
associate--r+98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
if -2.09999999999999989e-13 < x < 3.80000000000000009e-28Initial program 71.3%
diff-cos91.0%
div-inv91.0%
associate--l+91.0%
metadata-eval91.0%
div-inv91.0%
+-commutative91.0%
associate-+l+91.0%
metadata-eval91.0%
Applied egg-rr91.0%
associate-*r*91.0%
*-commutative91.0%
*-commutative91.0%
+-commutative91.0%
count-291.0%
fma-def91.0%
sub-neg91.0%
mul-1-neg91.0%
+-commutative91.0%
associate-+r+99.6%
mul-1-neg99.6%
sub-neg99.6%
+-inverses99.6%
remove-double-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
neg-sub099.6%
mul-1-neg99.6%
remove-double-neg99.6%
Simplified99.6%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (* (* -2.0 (sin (* 0.5 (+ eps (- x x))))) (sin (* 0.5 (+ x (+ eps x))))))
double code(double x, double eps) {
return (-2.0 * sin((0.5 * (eps + (x - x))))) * sin((0.5 * (x + (eps + x))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((-2.0d0) * sin((0.5d0 * (eps + (x - x))))) * sin((0.5d0 * (x + (eps + x))))
end function
public static double code(double x, double eps) {
return (-2.0 * Math.sin((0.5 * (eps + (x - x))))) * Math.sin((0.5 * (x + (eps + x))));
}
def code(x, eps): return (-2.0 * math.sin((0.5 * (eps + (x - x))))) * math.sin((0.5 * (x + (eps + x))))
function code(x, eps) return Float64(Float64(-2.0 * sin(Float64(0.5 * Float64(eps + Float64(x - x))))) * sin(Float64(0.5 * Float64(x + Float64(eps + x))))) end
function tmp = code(x, eps) tmp = (-2.0 * sin((0.5 * (eps + (x - x))))) * sin((0.5 * (x + (eps + x)))); end
code[x_, eps_] := N[(N[(-2.0 * N[Sin[N[(0.5 * N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.5 * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-2 \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon + x\right)\right)\right)
\end{array}
Initial program 37.9%
expm1-log1p-u26.1%
Applied egg-rr26.1%
expm1-log1p-u37.9%
diff-cos46.7%
associate-*r*46.7%
div-inv46.7%
+-commutative46.7%
associate--l+72.1%
metadata-eval72.1%
div-inv72.1%
associate-+l+72.1%
+-commutative72.1%
metadata-eval72.1%
Applied egg-rr72.1%
Final simplification72.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))) (t_1 (* (sin x) (* -2.0 t_0))))
(if (<= x -0.9)
t_1
(if (<= x -1.2e-91)
(- (+ -1.0 (cos eps)) (* (sin eps) x))
(if (<= x 7.5e-31) (* -2.0 (pow t_0 2.0)) t_1)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double t_1 = sin(x) * (-2.0 * t_0);
double tmp;
if (x <= -0.9) {
tmp = t_1;
} else if (x <= -1.2e-91) {
tmp = (-1.0 + cos(eps)) - (sin(eps) * x);
} else if (x <= 7.5e-31) {
tmp = -2.0 * pow(t_0, 2.0);
} else {
tmp = 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((eps * 0.5d0))
t_1 = sin(x) * ((-2.0d0) * t_0)
if (x <= (-0.9d0)) then
tmp = t_1
else if (x <= (-1.2d-91)) then
tmp = ((-1.0d0) + cos(eps)) - (sin(eps) * x)
else if (x <= 7.5d-31) then
tmp = (-2.0d0) * (t_0 ** 2.0d0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps * 0.5));
double t_1 = Math.sin(x) * (-2.0 * t_0);
double tmp;
if (x <= -0.9) {
tmp = t_1;
} else if (x <= -1.2e-91) {
tmp = (-1.0 + Math.cos(eps)) - (Math.sin(eps) * x);
} else if (x <= 7.5e-31) {
tmp = -2.0 * Math.pow(t_0, 2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) t_1 = math.sin(x) * (-2.0 * t_0) tmp = 0 if x <= -0.9: tmp = t_1 elif x <= -1.2e-91: tmp = (-1.0 + math.cos(eps)) - (math.sin(eps) * x) elif x <= 7.5e-31: tmp = -2.0 * math.pow(t_0, 2.0) else: tmp = t_1 return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) t_1 = Float64(sin(x) * Float64(-2.0 * t_0)) tmp = 0.0 if (x <= -0.9) tmp = t_1; elseif (x <= -1.2e-91) tmp = Float64(Float64(-1.0 + cos(eps)) - Float64(sin(eps) * x)); elseif (x <= 7.5e-31) tmp = Float64(-2.0 * (t_0 ^ 2.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); t_1 = sin(x) * (-2.0 * t_0); tmp = 0.0; if (x <= -0.9) tmp = t_1; elseif (x <= -1.2e-91) tmp = (-1.0 + cos(eps)) - (sin(eps) * x); elseif (x <= 7.5e-31) tmp = -2.0 * (t_0 ^ 2.0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.9], t$95$1, If[LessEqual[x, -1.2e-91], N[(N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e-31], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
t_1 := \sin x \cdot \left(-2 \cdot t_0\right)\\
\mathbf{if}\;x \leq -0.9:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-91}:\\
\;\;\;\;\left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot x\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-31}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -0.900000000000000022 or 7.49999999999999975e-31 < x Initial program 7.5%
diff-cos6.6%
div-inv6.6%
associate--l+6.6%
metadata-eval6.6%
div-inv6.6%
+-commutative6.6%
associate-+l+6.4%
metadata-eval6.4%
Applied egg-rr6.4%
associate-*r*6.4%
*-commutative6.4%
*-commutative6.4%
+-commutative6.4%
count-26.4%
fma-def6.4%
sub-neg6.4%
mul-1-neg6.4%
+-commutative6.4%
associate-+r+47.6%
mul-1-neg47.6%
sub-neg47.6%
+-inverses47.6%
remove-double-neg47.6%
mul-1-neg47.6%
sub-neg47.6%
neg-sub047.6%
mul-1-neg47.6%
remove-double-neg47.6%
Simplified47.6%
Taylor expanded in eps around 0 46.6%
if -0.900000000000000022 < x < -1.20000000000000005e-91Initial program 41.7%
Taylor expanded in x around 0 45.4%
sub-neg45.4%
metadata-eval45.4%
+-commutative45.4%
associate-+r+81.8%
+-commutative81.8%
+-commutative81.8%
mul-1-neg81.8%
unsub-neg81.8%
unpow281.8%
associate-*l*81.8%
distribute-lft-out--81.8%
+-commutative81.8%
*-commutative81.8%
fma-def81.8%
Simplified81.8%
Taylor expanded in x around 0 81.1%
mul-1-neg81.1%
distribute-rgt-neg-out81.1%
Simplified81.1%
if -1.20000000000000005e-91 < x < 7.49999999999999975e-31Initial program 75.6%
diff-cos96.2%
div-inv96.2%
associate--l+96.2%
metadata-eval96.2%
div-inv96.2%
+-commutative96.2%
associate-+l+96.2%
metadata-eval96.2%
Applied egg-rr96.2%
associate-*r*96.2%
*-commutative96.2%
*-commutative96.2%
+-commutative96.2%
count-296.2%
fma-def96.2%
sub-neg96.2%
mul-1-neg96.2%
+-commutative96.2%
associate-+r+99.6%
mul-1-neg99.6%
sub-neg99.6%
+-inverses99.6%
remove-double-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
neg-sub099.6%
mul-1-neg99.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in x around 0 95.3%
Final simplification69.1%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* eps 0.5)) (sin (* 0.5 (+ x (+ eps x)))))))
double code(double x, double eps) {
return -2.0 * (sin((eps * 0.5)) * sin((0.5 * (x + (eps + x)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((eps * 0.5d0)) * sin((0.5d0 * (x + (eps + x)))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((eps * 0.5)) * Math.sin((0.5 * (x + (eps + x)))));
}
def code(x, eps): return -2.0 * (math.sin((eps * 0.5)) * math.sin((0.5 * (x + (eps + x)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * sin(Float64(0.5 * Float64(x + Float64(eps + x)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((eps * 0.5)) * sin((0.5 * (x + (eps + x))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\right)
\end{array}
Initial program 37.9%
sub-neg37.9%
cos-sum66.3%
associate-+l-66.3%
fma-neg66.3%
Applied egg-rr66.3%
fma-neg66.3%
*-commutative66.3%
*-commutative66.3%
fma-neg66.3%
remove-double-neg66.3%
Simplified66.3%
Taylor expanded in eps around inf 66.3%
associate--r+90.2%
*-commutative90.2%
*-rgt-identity90.2%
distribute-lft-out--90.2%
sub-neg90.2%
metadata-eval90.2%
+-commutative90.2%
*-commutative90.2%
Simplified90.2%
distribute-lft-in90.2%
associate--l+66.3%
*-commutative66.3%
neg-mul-166.3%
fma-neg66.3%
distribute-lft-neg-out66.3%
+-commutative66.3%
distribute-lft-neg-out66.3%
fma-neg66.3%
cos-sum37.9%
sub-neg37.9%
diff-cos46.7%
Applied egg-rr72.0%
+-inverses72.0%
+-rgt-identity72.0%
*-commutative72.0%
Simplified72.0%
Final simplification72.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -2.7e-37) (not (<= x 1.45e-28)))
(* (sin x) (* -2.0 t_0))
(* -2.0 (pow t_0 2.0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((x <= -2.7e-37) || !(x <= 1.45e-28)) {
tmp = sin(x) * (-2.0 * t_0);
} else {
tmp = -2.0 * pow(t_0, 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin((eps * 0.5d0))
if ((x <= (-2.7d-37)) .or. (.not. (x <= 1.45d-28))) then
tmp = sin(x) * ((-2.0d0) * t_0)
else
tmp = (-2.0d0) * (t_0 ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps * 0.5));
double tmp;
if ((x <= -2.7e-37) || !(x <= 1.45e-28)) {
tmp = Math.sin(x) * (-2.0 * t_0);
} else {
tmp = -2.0 * Math.pow(t_0, 2.0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (x <= -2.7e-37) or not (x <= 1.45e-28): tmp = math.sin(x) * (-2.0 * t_0) else: tmp = -2.0 * math.pow(t_0, 2.0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if ((x <= -2.7e-37) || !(x <= 1.45e-28)) tmp = Float64(sin(x) * Float64(-2.0 * t_0)); else tmp = Float64(-2.0 * (t_0 ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); tmp = 0.0; if ((x <= -2.7e-37) || ~((x <= 1.45e-28))) tmp = sin(x) * (-2.0 * t_0); else tmp = -2.0 * (t_0 ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x, -2.7e-37], N[Not[LessEqual[x, 1.45e-28]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-37} \lor \neg \left(x \leq 1.45 \cdot 10^{-28}\right):\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -2.70000000000000016e-37 or 1.45000000000000006e-28 < x Initial program 8.5%
diff-cos7.7%
div-inv7.7%
associate--l+7.7%
metadata-eval7.7%
div-inv7.7%
+-commutative7.7%
associate-+l+7.4%
metadata-eval7.4%
Applied egg-rr7.4%
associate-*r*7.4%
*-commutative7.4%
*-commutative7.4%
+-commutative7.4%
count-27.4%
fma-def7.4%
sub-neg7.4%
mul-1-neg7.4%
+-commutative7.4%
associate-+r+48.6%
mul-1-neg48.6%
sub-neg48.6%
+-inverses48.6%
remove-double-neg48.6%
mul-1-neg48.6%
sub-neg48.6%
neg-sub048.6%
mul-1-neg48.6%
remove-double-neg48.6%
Simplified48.6%
Taylor expanded in eps around 0 46.6%
if -2.70000000000000016e-37 < x < 1.45000000000000006e-28Initial program 72.7%
diff-cos93.1%
div-inv93.1%
associate--l+93.1%
metadata-eval93.1%
div-inv93.1%
+-commutative93.1%
associate-+l+93.1%
metadata-eval93.1%
Applied egg-rr93.1%
associate-*r*93.1%
*-commutative93.1%
*-commutative93.1%
+-commutative93.1%
count-293.1%
fma-def93.1%
sub-neg93.1%
mul-1-neg93.1%
+-commutative93.1%
associate-+r+99.6%
mul-1-neg99.6%
sub-neg99.6%
+-inverses99.6%
remove-double-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
neg-sub099.6%
mul-1-neg99.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in x around 0 91.2%
Final simplification67.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.1e-65) (not (<= eps 3.8e-67))) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.1e-65) || !(eps <= 3.8e-67)) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.1d-65)) .or. (.not. (eps <= 3.8d-67))) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.1e-65) || !(eps <= 3.8e-67)) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.1e-65) or not (eps <= 3.8e-67): tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.1e-65) || !(eps <= 3.8e-67)) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.1e-65) || ~((eps <= 3.8e-67))) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.1e-65], N[Not[LessEqual[eps, 3.8e-67]], $MachinePrecision]], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.1 \cdot 10^{-65} \lor \neg \left(\varepsilon \leq 3.8 \cdot 10^{-67}\right):\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -3.10000000000000016e-65 or 3.79999999999999988e-67 < eps Initial program 41.8%
diff-cos50.1%
div-inv50.1%
associate--l+50.1%
metadata-eval50.1%
div-inv50.1%
+-commutative50.1%
associate-+l+49.9%
metadata-eval49.9%
Applied egg-rr49.9%
associate-*r*49.9%
*-commutative49.9%
*-commutative49.9%
+-commutative49.9%
count-249.9%
fma-def49.9%
sub-neg49.9%
mul-1-neg49.9%
+-commutative49.9%
associate-+r+56.2%
mul-1-neg56.2%
sub-neg56.2%
+-inverses56.2%
remove-double-neg56.2%
mul-1-neg56.2%
sub-neg56.2%
neg-sub056.2%
mul-1-neg56.2%
remove-double-neg56.2%
Simplified56.2%
Taylor expanded in x around 0 51.2%
if -3.10000000000000016e-65 < eps < 3.79999999999999988e-67Initial program 30.8%
Taylor expanded in eps around 0 90.5%
mul-1-neg90.5%
*-commutative90.5%
distribute-rgt-neg-in90.5%
Simplified90.5%
Final simplification65.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (cos eps) (cos x))))
(if (<= eps -0.0003)
t_0
(if (<= eps -3.6e-65)
(* -0.5 (pow eps 2.0))
(if (<= eps 17.0) (* (sin x) (- eps)) t_0)))))
double code(double x, double eps) {
double t_0 = cos(eps) - cos(x);
double tmp;
if (eps <= -0.0003) {
tmp = t_0;
} else if (eps <= -3.6e-65) {
tmp = -0.5 * pow(eps, 2.0);
} else if (eps <= 17.0) {
tmp = sin(x) * -eps;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = cos(eps) - cos(x)
if (eps <= (-0.0003d0)) then
tmp = t_0
else if (eps <= (-3.6d-65)) then
tmp = (-0.5d0) * (eps ** 2.0d0)
else if (eps <= 17.0d0) then
tmp = sin(x) * -eps
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(eps) - Math.cos(x);
double tmp;
if (eps <= -0.0003) {
tmp = t_0;
} else if (eps <= -3.6e-65) {
tmp = -0.5 * Math.pow(eps, 2.0);
} else if (eps <= 17.0) {
tmp = Math.sin(x) * -eps;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) - math.cos(x) tmp = 0 if eps <= -0.0003: tmp = t_0 elif eps <= -3.6e-65: tmp = -0.5 * math.pow(eps, 2.0) elif eps <= 17.0: tmp = math.sin(x) * -eps else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) - cos(x)) tmp = 0.0 if (eps <= -0.0003) tmp = t_0; elseif (eps <= -3.6e-65) tmp = Float64(-0.5 * (eps ^ 2.0)); elseif (eps <= 17.0) tmp = Float64(sin(x) * Float64(-eps)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) - cos(x); tmp = 0.0; if (eps <= -0.0003) tmp = t_0; elseif (eps <= -3.6e-65) tmp = -0.5 * (eps ^ 2.0); elseif (eps <= 17.0) tmp = sin(x) * -eps; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0003], t$95$0, If[LessEqual[eps, -3.6e-65], N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 17.0], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon - \cos x\\
\mathbf{if}\;\varepsilon \leq -0.0003:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -3.6 \cdot 10^{-65}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2}\\
\mathbf{elif}\;\varepsilon \leq 17:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -2.99999999999999974e-4 or 17 < eps Initial program 48.2%
Taylor expanded in x around 0 51.3%
if -2.99999999999999974e-4 < eps < -3.5999999999999998e-65Initial program 3.8%
Taylor expanded in x around 0 4.5%
Taylor expanded in eps around 0 67.3%
if -3.5999999999999998e-65 < eps < 17Initial program 28.5%
Taylor expanded in eps around 0 84.7%
mul-1-neg84.7%
*-commutative84.7%
distribute-rgt-neg-in84.7%
Simplified84.7%
Final simplification65.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))) (t_1 (* -0.5 (pow eps 2.0))))
(if (<= eps -0.0003)
t_0
(if (<= eps -2.7e-160)
t_1
(if (<= eps 2.4e-71) (* x (- eps)) (if (<= eps 0.00018) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double t_1 = -0.5 * pow(eps, 2.0);
double tmp;
if (eps <= -0.0003) {
tmp = t_0;
} else if (eps <= -2.7e-160) {
tmp = t_1;
} else if (eps <= 2.4e-71) {
tmp = x * -eps;
} else if (eps <= 0.00018) {
tmp = t_1;
} else {
tmp = t_0;
}
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) + cos(eps)
t_1 = (-0.5d0) * (eps ** 2.0d0)
if (eps <= (-0.0003d0)) then
tmp = t_0
else if (eps <= (-2.7d-160)) then
tmp = t_1
else if (eps <= 2.4d-71) then
tmp = x * -eps
else if (eps <= 0.00018d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = -1.0 + Math.cos(eps);
double t_1 = -0.5 * Math.pow(eps, 2.0);
double tmp;
if (eps <= -0.0003) {
tmp = t_0;
} else if (eps <= -2.7e-160) {
tmp = t_1;
} else if (eps <= 2.4e-71) {
tmp = x * -eps;
} else if (eps <= 0.00018) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) t_1 = -0.5 * math.pow(eps, 2.0) tmp = 0 if eps <= -0.0003: tmp = t_0 elif eps <= -2.7e-160: tmp = t_1 elif eps <= 2.4e-71: tmp = x * -eps elif eps <= 0.00018: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) t_1 = Float64(-0.5 * (eps ^ 2.0)) tmp = 0.0 if (eps <= -0.0003) tmp = t_0; elseif (eps <= -2.7e-160) tmp = t_1; elseif (eps <= 2.4e-71) tmp = Float64(x * Float64(-eps)); elseif (eps <= 0.00018) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = -1.0 + cos(eps); t_1 = -0.5 * (eps ^ 2.0); tmp = 0.0; if (eps <= -0.0003) tmp = t_0; elseif (eps <= -2.7e-160) tmp = t_1; elseif (eps <= 2.4e-71) tmp = x * -eps; elseif (eps <= 0.00018) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0003], t$95$0, If[LessEqual[eps, -2.7e-160], t$95$1, If[LessEqual[eps, 2.4e-71], N[(x * (-eps)), $MachinePrecision], If[LessEqual[eps, 0.00018], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
t_1 := -0.5 \cdot {\varepsilon}^{2}\\
\mathbf{if}\;\varepsilon \leq -0.0003:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -2.7 \cdot 10^{-160}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-71}:\\
\;\;\;\;x \cdot \left(-\varepsilon\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00018:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -2.99999999999999974e-4 or 1.80000000000000011e-4 < eps Initial program 47.9%
Taylor expanded in x around 0 48.7%
if -2.99999999999999974e-4 < eps < -2.7000000000000001e-160 or 2.4e-71 < eps < 1.80000000000000011e-4Initial program 5.4%
Taylor expanded in x around 0 5.8%
Taylor expanded in eps around 0 48.5%
if -2.7000000000000001e-160 < eps < 2.4e-71Initial program 39.1%
Taylor expanded in eps around 0 96.0%
mul-1-neg96.0%
*-commutative96.0%
distribute-rgt-neg-in96.0%
Simplified96.0%
Taylor expanded in x around 0 54.1%
mul-1-neg54.1%
distribute-rgt-neg-in54.1%
Simplified54.1%
Final simplification50.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))))
(if (<= eps -0.0003)
t_0
(if (<= eps -1.7e-65)
(* -0.5 (pow eps 2.0))
(if (<= eps 4000.0) (* (sin x) (- eps)) t_0)))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double tmp;
if (eps <= -0.0003) {
tmp = t_0;
} else if (eps <= -1.7e-65) {
tmp = -0.5 * pow(eps, 2.0);
} else if (eps <= 4000.0) {
tmp = sin(x) * -eps;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = (-1.0d0) + cos(eps)
if (eps <= (-0.0003d0)) then
tmp = t_0
else if (eps <= (-1.7d-65)) then
tmp = (-0.5d0) * (eps ** 2.0d0)
else if (eps <= 4000.0d0) then
tmp = sin(x) * -eps
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = -1.0 + Math.cos(eps);
double tmp;
if (eps <= -0.0003) {
tmp = t_0;
} else if (eps <= -1.7e-65) {
tmp = -0.5 * Math.pow(eps, 2.0);
} else if (eps <= 4000.0) {
tmp = Math.sin(x) * -eps;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) tmp = 0 if eps <= -0.0003: tmp = t_0 elif eps <= -1.7e-65: tmp = -0.5 * math.pow(eps, 2.0) elif eps <= 4000.0: tmp = math.sin(x) * -eps else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -0.0003) tmp = t_0; elseif (eps <= -1.7e-65) tmp = Float64(-0.5 * (eps ^ 2.0)); elseif (eps <= 4000.0) tmp = Float64(sin(x) * Float64(-eps)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = -1.0 + cos(eps); tmp = 0.0; if (eps <= -0.0003) tmp = t_0; elseif (eps <= -1.7e-65) tmp = -0.5 * (eps ^ 2.0); elseif (eps <= 4000.0) tmp = sin(x) * -eps; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0003], t$95$0, If[LessEqual[eps, -1.7e-65], N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4000.0], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0003:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -1.7 \cdot 10^{-65}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2}\\
\mathbf{elif}\;\varepsilon \leq 4000:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -2.99999999999999974e-4 or 4e3 < eps Initial program 48.9%
Taylor expanded in x around 0 49.7%
if -2.99999999999999974e-4 < eps < -1.69999999999999993e-65Initial program 3.8%
Taylor expanded in x around 0 4.5%
Taylor expanded in eps around 0 67.3%
if -1.69999999999999993e-65 < eps < 4e3Initial program 28.0%
Taylor expanded in eps around 0 83.2%
mul-1-neg83.2%
*-commutative83.2%
distribute-rgt-neg-in83.2%
Simplified83.2%
Final simplification64.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -48000000000.0) (not (<= eps 4.6e-10))) (+ -1.0 (cos eps)) (* x (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -48000000000.0) || !(eps <= 4.6e-10)) {
tmp = -1.0 + cos(eps);
} else {
tmp = x * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-48000000000.0d0)) .or. (.not. (eps <= 4.6d-10))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = x * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -48000000000.0) || !(eps <= 4.6e-10)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = x * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -48000000000.0) or not (eps <= 4.6e-10): tmp = -1.0 + math.cos(eps) else: tmp = x * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -48000000000.0) || !(eps <= 4.6e-10)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(x * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -48000000000.0) || ~((eps <= 4.6e-10))) tmp = -1.0 + cos(eps); else tmp = x * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -48000000000.0], N[Not[LessEqual[eps, 4.6e-10]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(x * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -48000000000 \lor \neg \left(\varepsilon \leq 4.6 \cdot 10^{-10}\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -4.8e10 or 4.60000000000000014e-10 < eps Initial program 47.6%
Taylor expanded in x around 0 48.5%
if -4.8e10 < eps < 4.60000000000000014e-10Initial program 25.7%
Taylor expanded in eps around 0 79.5%
mul-1-neg79.5%
*-commutative79.5%
distribute-rgt-neg-in79.5%
Simplified79.5%
Taylor expanded in x around 0 37.1%
mul-1-neg37.1%
distribute-rgt-neg-in37.1%
Simplified37.1%
Final simplification43.4%
(FPCore (x eps) :precision binary64 (* x (- eps)))
double code(double x, double eps) {
return x * -eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = x * -eps
end function
public static double code(double x, double eps) {
return x * -eps;
}
def code(x, eps): return x * -eps
function code(x, eps) return Float64(x * Float64(-eps)) end
function tmp = code(x, eps) tmp = x * -eps; end
code[x_, eps_] := N[(x * (-eps)), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-\varepsilon\right)
\end{array}
Initial program 37.9%
Taylor expanded in eps around 0 37.9%
mul-1-neg37.9%
*-commutative37.9%
distribute-rgt-neg-in37.9%
Simplified37.9%
Taylor expanded in x around 0 18.4%
mul-1-neg18.4%
distribute-rgt-neg-in18.4%
Simplified18.4%
Final simplification18.4%
herbie shell --seed 2023320
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))