
(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 17 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.0027)
(fma (cos x) (+ -1.0 (cos eps)) (* (sin x) (- (sin eps))))
(if (<= eps 0.00265)
(fma
0.16666666666666666
(* (sin x) (pow eps 3.0))
(-
(*
(cos x)
(fma -0.5 (* eps eps) (* (pow eps 4.0) 0.041666666666666664)))
(* eps (sin x))))
(fma (sin eps) (- (sin x)) (- (* (cos x) (cos eps)) (cos x))))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0027) {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(x) * -sin(eps)));
} else if (eps <= 0.00265) {
tmp = fma(0.16666666666666666, (sin(x) * pow(eps, 3.0)), ((cos(x) * fma(-0.5, (eps * eps), (pow(eps, 4.0) * 0.041666666666666664))) - (eps * sin(x))));
} else {
tmp = fma(sin(eps), -sin(x), ((cos(x) * cos(eps)) - cos(x)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -0.0027) tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(x) * Float64(-sin(eps)))); elseif (eps <= 0.00265) tmp = fma(0.16666666666666666, Float64(sin(x) * (eps ^ 3.0)), Float64(Float64(cos(x) * fma(-0.5, Float64(eps * eps), Float64((eps ^ 4.0) * 0.041666666666666664))) - Float64(eps * sin(x)))); else tmp = fma(sin(eps), Float64(-sin(x)), Float64(Float64(cos(x) * cos(eps)) - cos(x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.0027], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00265], N[(0.16666666666666666 * N[(N[Sin[x], $MachinePrecision] * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[(eps * eps), $MachinePrecision] + N[(N[Power[eps, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision]) + N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0027:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00265:\\
\;\;\;\;\mathsf{fma}\left(0.16666666666666666, \sin x \cdot {\varepsilon}^{3}, \cos x \cdot \mathsf{fma}\left(-0.5, \varepsilon \cdot \varepsilon, {\varepsilon}^{4} \cdot 0.041666666666666664\right) - \varepsilon \cdot \sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, -\sin x, \cos x \cdot \cos \varepsilon - \cos x\right)\\
\end{array}
\end{array}
if eps < -0.0027000000000000001Initial program 48.1%
cos-sum98.7%
sub-neg98.7%
Applied egg-rr98.7%
+-commutative98.7%
distribute-lft-neg-in98.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--l+98.8%
*-commutative98.8%
associate-*r*98.8%
neg-mul-198.8%
*-commutative98.8%
fma-def98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
associate-*r*98.9%
neg-mul-198.9%
*-commutative98.9%
fma-def99.0%
Simplified99.0%
if -0.0027000000000000001 < eps < 0.00265000000000000001Initial program 25.7%
expm1-log1p-u25.4%
Applied egg-rr25.4%
Taylor expanded in eps around 0 99.8%
associate-+r+99.8%
+-commutative99.8%
associate-+r+99.8%
fma-def99.8%
*-commutative99.8%
associate-+r+99.8%
neg-mul-199.8%
unsub-neg99.8%
Simplified99.8%
if 0.00265000000000000001 < eps Initial program 56.7%
cos-sum98.4%
sub-neg98.4%
Applied egg-rr98.4%
+-commutative98.4%
distribute-lft-neg-in98.4%
*-commutative98.4%
fma-def98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in eps around inf 98.4%
associate--l+98.6%
*-commutative98.6%
associate-*r*98.6%
neg-mul-198.6%
*-commutative98.6%
fma-def98.7%
*-commutative98.7%
*-rgt-identity98.7%
distribute-lft-out--98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
distribute-lft-in98.7%
Applied egg-rr98.7%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin x))))
(if (<= eps -0.0058)
(fma (cos x) (+ -1.0 (cos eps)) (* (sin x) (- (sin eps))))
(if (<= eps 0.0048)
(fma
(sin eps)
t_0
(*
(cos x)
(+ (* eps (* eps -0.5)) (* (pow eps 4.0) 0.041666666666666664))))
(fma (sin eps) t_0 (- (* (cos x) (cos eps)) (cos x)))))))
double code(double x, double eps) {
double t_0 = -sin(x);
double tmp;
if (eps <= -0.0058) {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(x) * -sin(eps)));
} else if (eps <= 0.0048) {
tmp = fma(sin(eps), t_0, (cos(x) * ((eps * (eps * -0.5)) + (pow(eps, 4.0) * 0.041666666666666664))));
} else {
tmp = fma(sin(eps), t_0, ((cos(x) * cos(eps)) - cos(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(-sin(x)) tmp = 0.0 if (eps <= -0.0058) tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(x) * Float64(-sin(eps)))); elseif (eps <= 0.0048) tmp = fma(sin(eps), t_0, Float64(cos(x) * Float64(Float64(eps * Float64(eps * -0.5)) + Float64((eps ^ 4.0) * 0.041666666666666664)))); else tmp = fma(sin(eps), t_0, Float64(Float64(cos(x) * cos(eps)) - cos(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Sin[x], $MachinePrecision])}, If[LessEqual[eps, -0.0058], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0048], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[Cos[x], $MachinePrecision] * N[(N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin x\\
\mathbf{if}\;\varepsilon \leq -0.0058:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0048:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos x \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot -0.5\right) + {\varepsilon}^{4} \cdot 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos x \cdot \cos \varepsilon - \cos x\right)\\
\end{array}
\end{array}
if eps < -0.0058Initial program 48.1%
cos-sum98.7%
sub-neg98.7%
Applied egg-rr98.7%
+-commutative98.7%
distribute-lft-neg-in98.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--l+98.8%
*-commutative98.8%
associate-*r*98.8%
neg-mul-198.8%
*-commutative98.8%
fma-def98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
associate-*r*98.9%
neg-mul-198.9%
*-commutative98.9%
fma-def99.0%
Simplified99.0%
if -0.0058 < eps < 0.00479999999999999958Initial program 25.7%
cos-sum27.0%
sub-neg27.0%
Applied egg-rr27.0%
+-commutative27.0%
distribute-lft-neg-in27.0%
*-commutative27.0%
fma-def27.0%
*-commutative27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--l+76.4%
*-commutative76.4%
associate-*r*76.4%
neg-mul-176.4%
*-commutative76.4%
fma-def76.4%
*-commutative76.4%
*-rgt-identity76.4%
distribute-lft-out--76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
unpow299.8%
associate-*l*99.8%
Simplified99.8%
if 0.00479999999999999958 < eps Initial program 56.7%
cos-sum98.4%
sub-neg98.4%
Applied egg-rr98.4%
+-commutative98.4%
distribute-lft-neg-in98.4%
*-commutative98.4%
fma-def98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in eps around inf 98.4%
associate--l+98.6%
*-commutative98.6%
associate-*r*98.6%
neg-mul-198.6%
*-commutative98.6%
fma-def98.7%
*-commutative98.7%
*-rgt-identity98.7%
distribute-lft-out--98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
distribute-lft-in98.7%
Applied egg-rr98.7%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin x))) (t_1 (+ -1.0 (cos eps))))
(if (<= eps -0.0058)
(fma (cos x) t_1 (* (sin x) (- (sin eps))))
(if (<= eps 0.0033)
(fma
(sin eps)
t_0
(*
(cos x)
(+ (* eps (* eps -0.5)) (* (pow eps 4.0) 0.041666666666666664))))
(fma (sin eps) t_0 (* (cos x) t_1))))))
double code(double x, double eps) {
double t_0 = -sin(x);
double t_1 = -1.0 + cos(eps);
double tmp;
if (eps <= -0.0058) {
tmp = fma(cos(x), t_1, (sin(x) * -sin(eps)));
} else if (eps <= 0.0033) {
tmp = fma(sin(eps), t_0, (cos(x) * ((eps * (eps * -0.5)) + (pow(eps, 4.0) * 0.041666666666666664))));
} else {
tmp = fma(sin(eps), t_0, (cos(x) * t_1));
}
return tmp;
}
function code(x, eps) t_0 = Float64(-sin(x)) t_1 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -0.0058) tmp = fma(cos(x), t_1, Float64(sin(x) * Float64(-sin(eps)))); elseif (eps <= 0.0033) tmp = fma(sin(eps), t_0, Float64(cos(x) * Float64(Float64(eps * Float64(eps * -0.5)) + Float64((eps ^ 4.0) * 0.041666666666666664)))); else tmp = fma(sin(eps), t_0, Float64(cos(x) * t_1)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Sin[x], $MachinePrecision])}, Block[{t$95$1 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0058], N[(N[Cos[x], $MachinePrecision] * t$95$1 + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0033], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[Cos[x], $MachinePrecision] * N[(N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Power[eps, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin x\\
t_1 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0058:\\
\;\;\;\;\mathsf{fma}\left(\cos x, t_1, \sin x \cdot \left(-\sin \varepsilon\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0033:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos x \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot -0.5\right) + {\varepsilon}^{4} \cdot 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos x \cdot t_1\right)\\
\end{array}
\end{array}
if eps < -0.0058Initial program 48.1%
cos-sum98.7%
sub-neg98.7%
Applied egg-rr98.7%
+-commutative98.7%
distribute-lft-neg-in98.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--l+98.8%
*-commutative98.8%
associate-*r*98.8%
neg-mul-198.8%
*-commutative98.8%
fma-def98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
associate-*r*98.9%
neg-mul-198.9%
*-commutative98.9%
fma-def99.0%
Simplified99.0%
if -0.0058 < eps < 0.0033Initial program 25.7%
cos-sum27.0%
sub-neg27.0%
Applied egg-rr27.0%
+-commutative27.0%
distribute-lft-neg-in27.0%
*-commutative27.0%
fma-def27.0%
*-commutative27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--l+76.4%
*-commutative76.4%
associate-*r*76.4%
neg-mul-176.4%
*-commutative76.4%
fma-def76.4%
*-commutative76.4%
*-rgt-identity76.4%
distribute-lft-out--76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
unpow299.8%
associate-*l*99.8%
Simplified99.8%
if 0.0033 < eps Initial program 56.7%
cos-sum98.4%
sub-neg98.4%
Applied egg-rr98.4%
+-commutative98.4%
distribute-lft-neg-in98.4%
*-commutative98.4%
fma-def98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in eps around inf 98.4%
associate--l+98.6%
*-commutative98.6%
associate-*r*98.6%
neg-mul-198.6%
*-commutative98.6%
fma-def98.7%
*-commutative98.7%
*-rgt-identity98.7%
distribute-lft-out--98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00015) (not (<= eps 0.000135))) (fma (cos x) (+ -1.0 (cos eps)) (* (sin x) (- (sin eps)))) (fma (sin eps) (- (sin x)) (* -0.5 (* (cos x) (* eps eps))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = fma(cos(x), (-1.0 + cos(eps)), (sin(x) * -sin(eps)));
} else {
tmp = fma(sin(eps), -sin(x), (-0.5 * (cos(x) * (eps * eps))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.00015) || !(eps <= 0.000135)) tmp = fma(cos(x), Float64(-1.0 + cos(eps)), Float64(sin(x) * Float64(-sin(eps)))); else tmp = fma(sin(eps), Float64(-sin(x)), Float64(-0.5 * Float64(cos(x) * Float64(eps * eps)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00015], N[Not[LessEqual[eps, 0.000135]], $MachinePrecision]], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision]) + N[(-0.5 * N[(N[Cos[x], $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00015 \lor \neg \left(\varepsilon \leq 0.000135\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, -\sin x, -0.5 \cdot \left(\cos x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\
\end{array}
\end{array}
if eps < -1.49999999999999987e-4 or 1.35000000000000002e-4 < eps Initial program 52.4%
cos-sum98.6%
sub-neg98.6%
Applied egg-rr98.6%
+-commutative98.6%
distribute-lft-neg-in98.6%
*-commutative98.6%
fma-def98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.6%
associate--l+98.7%
*-commutative98.7%
associate-*r*98.7%
neg-mul-198.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in eps around inf 98.7%
+-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
associate-*r*98.7%
neg-mul-198.7%
*-commutative98.7%
fma-def98.7%
Simplified98.7%
if -1.49999999999999987e-4 < eps < 1.35000000000000002e-4Initial program 25.7%
cos-sum27.0%
sub-neg27.0%
Applied egg-rr27.0%
+-commutative27.0%
distribute-lft-neg-in27.0%
*-commutative27.0%
fma-def27.0%
*-commutative27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--l+76.4%
*-commutative76.4%
associate-*r*76.4%
neg-mul-176.4%
*-commutative76.4%
fma-def76.4%
*-commutative76.4%
*-rgt-identity76.4%
distribute-lft-out--76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in eps around 0 99.8%
unpow299.8%
Simplified99.8%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin x))) (t_1 (+ -1.0 (cos eps))))
(if (<= eps -0.00015)
(fma (cos x) t_1 (* (sin x) (- (sin eps))))
(if (<= eps 0.000135)
(fma (sin eps) t_0 (* -0.5 (* (cos x) (* eps eps))))
(fma (sin eps) t_0 (* (cos x) t_1))))))
double code(double x, double eps) {
double t_0 = -sin(x);
double t_1 = -1.0 + cos(eps);
double tmp;
if (eps <= -0.00015) {
tmp = fma(cos(x), t_1, (sin(x) * -sin(eps)));
} else if (eps <= 0.000135) {
tmp = fma(sin(eps), t_0, (-0.5 * (cos(x) * (eps * eps))));
} else {
tmp = fma(sin(eps), t_0, (cos(x) * t_1));
}
return tmp;
}
function code(x, eps) t_0 = Float64(-sin(x)) t_1 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -0.00015) tmp = fma(cos(x), t_1, Float64(sin(x) * Float64(-sin(eps)))); elseif (eps <= 0.000135) tmp = fma(sin(eps), t_0, Float64(-0.5 * Float64(cos(x) * Float64(eps * eps)))); else tmp = fma(sin(eps), t_0, Float64(cos(x) * t_1)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = (-N[Sin[x], $MachinePrecision])}, Block[{t$95$1 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00015], N[(N[Cos[x], $MachinePrecision] * t$95$1 + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.000135], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(-0.5 * N[(N[Cos[x], $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * t$95$0 + N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin x\\
t_1 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.00015:\\
\;\;\;\;\mathsf{fma}\left(\cos x, t_1, \sin x \cdot \left(-\sin \varepsilon\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 0.000135:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, -0.5 \cdot \left(\cos x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, t_0, \cos x \cdot t_1\right)\\
\end{array}
\end{array}
if eps < -1.49999999999999987e-4Initial program 48.1%
cos-sum98.7%
sub-neg98.7%
Applied egg-rr98.7%
+-commutative98.7%
distribute-lft-neg-in98.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.7%
associate--l+98.8%
*-commutative98.8%
associate-*r*98.8%
neg-mul-198.8%
*-commutative98.8%
fma-def98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
associate-*r*98.9%
neg-mul-198.9%
*-commutative98.9%
fma-def99.0%
Simplified99.0%
if -1.49999999999999987e-4 < eps < 1.35000000000000002e-4Initial program 25.7%
cos-sum27.0%
sub-neg27.0%
Applied egg-rr27.0%
+-commutative27.0%
distribute-lft-neg-in27.0%
*-commutative27.0%
fma-def27.0%
*-commutative27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--l+76.4%
*-commutative76.4%
associate-*r*76.4%
neg-mul-176.4%
*-commutative76.4%
fma-def76.4%
*-commutative76.4%
*-rgt-identity76.4%
distribute-lft-out--76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in eps around 0 99.8%
unpow299.8%
Simplified99.8%
if 1.35000000000000002e-4 < eps Initial program 56.7%
cos-sum98.4%
sub-neg98.4%
Applied egg-rr98.4%
+-commutative98.4%
distribute-lft-neg-in98.4%
*-commutative98.4%
fma-def98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in eps around inf 98.4%
associate--l+98.6%
*-commutative98.6%
associate-*r*98.6%
neg-mul-198.6%
*-commutative98.6%
fma-def98.7%
*-commutative98.7%
*-rgt-identity98.7%
distribute-lft-out--98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00015) (not (<= eps 0.000135))) (- (* (cos x) (+ -1.0 (cos eps))) (* (sin eps) (sin x))) (fma (sin eps) (- (sin x)) (* -0.5 (* (cos x) (* eps eps))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x));
} else {
tmp = fma(sin(eps), -sin(x), (-0.5 * (cos(x) * (eps * eps))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.00015) || !(eps <= 0.000135)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(eps) * sin(x))); else tmp = fma(sin(eps), Float64(-sin(x)), Float64(-0.5 * Float64(cos(x) * Float64(eps * eps)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00015], N[Not[LessEqual[eps, 0.000135]], $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[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision]) + N[(-0.5 * N[(N[Cos[x], $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00015 \lor \neg \left(\varepsilon \leq 0.000135\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin \varepsilon, -\sin x, -0.5 \cdot \left(\cos x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\
\end{array}
\end{array}
if eps < -1.49999999999999987e-4 or 1.35000000000000002e-4 < eps Initial program 52.4%
cos-sum98.6%
sub-neg98.6%
Applied egg-rr98.6%
+-commutative98.6%
distribute-lft-neg-in98.6%
*-commutative98.6%
fma-def98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.6%
associate--l+98.7%
*-commutative98.7%
associate-*r*98.7%
neg-mul-198.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
fma-udef98.7%
Applied egg-rr98.7%
if -1.49999999999999987e-4 < eps < 1.35000000000000002e-4Initial program 25.7%
cos-sum27.0%
sub-neg27.0%
Applied egg-rr27.0%
+-commutative27.0%
distribute-lft-neg-in27.0%
*-commutative27.0%
fma-def27.0%
*-commutative27.0%
Simplified27.0%
Taylor expanded in eps around inf 27.0%
associate--l+76.4%
*-commutative76.4%
associate-*r*76.4%
neg-mul-176.4%
*-commutative76.4%
fma-def76.4%
*-commutative76.4%
*-rgt-identity76.4%
distribute-lft-out--76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in eps around 0 99.8%
unpow299.8%
Simplified99.8%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.00015) (not (<= eps 0.000135)))
(- (* (cos x) (+ -1.0 (cos eps))) (* (sin eps) (sin x)))
(+
(* -0.5 (* eps (* eps (cos x))))
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x));
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.00015d0)) .or. (.not. (eps <= 0.000135d0))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(eps) * sin(x))
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666d0 * (eps ** 3.0d0)) - eps))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(eps) * Math.sin(x));
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) + (Math.sin(x) * ((0.16666666666666666 * Math.pow(eps, 3.0)) - eps));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00015) or not (eps <= 0.000135): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(eps) * math.sin(x)) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) + (math.sin(x) * ((0.16666666666666666 * math.pow(eps, 3.0)) - eps)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00015) || !(eps <= 0.000135)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(eps) * sin(x))); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) + Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00015) || ~((eps <= 0.000135))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(eps) * sin(x)); else tmp = (-0.5 * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666 * (eps ^ 3.0)) - eps)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00015], N[Not[LessEqual[eps, 0.000135]], $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[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00015 \lor \neg \left(\varepsilon \leq 0.000135\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) + \sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.49999999999999987e-4 or 1.35000000000000002e-4 < eps Initial program 52.4%
cos-sum98.6%
sub-neg98.6%
Applied egg-rr98.6%
+-commutative98.6%
distribute-lft-neg-in98.6%
*-commutative98.6%
fma-def98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.6%
associate--l+98.7%
*-commutative98.7%
associate-*r*98.7%
neg-mul-198.7%
*-commutative98.7%
fma-def98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
fma-udef98.7%
Applied egg-rr98.7%
if -1.49999999999999987e-4 < eps < 1.35000000000000002e-4Initial program 25.7%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-+l+99.8%
unpow299.8%
associate-*l*99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
mul-1-neg99.8%
Simplified99.8%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.0145) (not (<= eps 0.0031))) (- (cos eps) (cos x)) (- (* -0.5 (* eps (* eps (cos x)))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0145) || !(eps <= 0.0031)) {
tmp = cos(eps) - cos(x);
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.0145d0)) .or. (.not. (eps <= 0.0031d0))) then
tmp = cos(eps) - cos(x)
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0145) || !(eps <= 0.0031)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0145) or not (eps <= 0.0031): tmp = math.cos(eps) - math.cos(x) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0145) || !(eps <= 0.0031)) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0145) || ~((eps <= 0.0031))) tmp = cos(eps) - cos(x); else tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0145], N[Not[LessEqual[eps, 0.0031]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0145 \lor \neg \left(\varepsilon \leq 0.0031\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -0.0145000000000000007 or 0.00309999999999999989 < eps Initial program 52.4%
Taylor expanded in x around 0 55.2%
if -0.0145000000000000007 < eps < 0.00309999999999999989Initial program 25.7%
Taylor expanded in eps around 0 99.6%
mul-1-neg99.6%
unsub-neg99.6%
unpow299.6%
associate-*l*99.6%
Simplified99.6%
Final simplification76.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* eps (- (sin x)))) (t_1 (- (cos eps) (cos x))))
(if (<= eps -0.00023)
t_1
(if (<= eps -2.9e-41)
(* eps (* eps -0.5))
(if (<= eps 5.4e-120)
t_0
(if (<= eps 1.2e-61)
(fma -0.5 (* eps eps) (* eps (- x)))
(if (<= eps 3e-8) t_0 t_1)))))))
double code(double x, double eps) {
double t_0 = eps * -sin(x);
double t_1 = cos(eps) - cos(x);
double tmp;
if (eps <= -0.00023) {
tmp = t_1;
} else if (eps <= -2.9e-41) {
tmp = eps * (eps * -0.5);
} else if (eps <= 5.4e-120) {
tmp = t_0;
} else if (eps <= 1.2e-61) {
tmp = fma(-0.5, (eps * eps), (eps * -x));
} else if (eps <= 3e-8) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(eps * Float64(-sin(x))) t_1 = Float64(cos(eps) - cos(x)) tmp = 0.0 if (eps <= -0.00023) tmp = t_1; elseif (eps <= -2.9e-41) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 5.4e-120) tmp = t_0; elseif (eps <= 1.2e-61) tmp = fma(-0.5, Float64(eps * eps), Float64(eps * Float64(-x))); elseif (eps <= 3e-8) tmp = t_0; else tmp = t_1; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00023], t$95$1, If[LessEqual[eps, -2.9e-41], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.4e-120], t$95$0, If[LessEqual[eps, 1.2e-61], N[(-0.5 * N[(eps * eps), $MachinePrecision] + N[(eps * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3e-8], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \varepsilon \cdot \left(-\sin x\right)\\
t_1 := \cos \varepsilon - \cos x\\
\mathbf{if}\;\varepsilon \leq -0.00023:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq -2.9 \cdot 10^{-41}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 5.4 \cdot 10^{-120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \varepsilon \cdot \varepsilon, \varepsilon \cdot \left(-x\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if eps < -2.3000000000000001e-4 or 2.99999999999999973e-8 < eps Initial program 52.2%
Taylor expanded in x around 0 55.0%
if -2.3000000000000001e-4 < eps < -2.89999999999999977e-41Initial program 4.9%
Taylor expanded in x around 0 5.6%
Taylor expanded in eps around 0 73.6%
*-commutative73.6%
unpow273.6%
associate-*l*73.6%
Simplified73.6%
if -2.89999999999999977e-41 < eps < 5.3999999999999997e-120 or 1.2e-61 < eps < 2.99999999999999973e-8Initial program 31.9%
Taylor expanded in eps around 0 89.3%
associate-*r*89.3%
mul-1-neg89.3%
Simplified89.3%
if 5.3999999999999997e-120 < eps < 1.2e-61Initial program 4.8%
Taylor expanded in eps around 0 4.8%
associate-+r+4.8%
mul-1-neg4.8%
unsub-neg4.8%
associate-*r*4.8%
distribute-rgt1-in4.8%
unpow24.8%
associate-*r*4.8%
Simplified4.8%
Taylor expanded in x around 0 79.3%
+-commutative79.3%
fma-def79.3%
unpow279.3%
mul-1-neg79.3%
distribute-rgt-neg-in79.3%
Simplified79.3%
Final simplification70.0%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* 0.5 (+ x (+ eps x)))) (sin (* eps 0.5)))))
double code(double x, double eps) {
return -2.0 * (sin((0.5 * (x + (eps + x)))) * sin((eps * 0.5)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((0.5d0 * (x + (eps + x)))) * sin((eps * 0.5d0)))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((0.5 * (x + (eps + x)))) * Math.sin((eps * 0.5)));
}
def code(x, eps): return -2.0 * (math.sin((0.5 * (x + (eps + x)))) * math.sin((eps * 0.5)))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(0.5 * Float64(x + Float64(eps + x)))) * sin(Float64(eps * 0.5)))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((0.5 * (x + (eps + x)))) * sin((eps * 0.5))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(0.5 * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(0.5 \cdot \left(x + \left(\varepsilon + x\right)\right)\right) \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 39.6%
diff-cos50.1%
div-inv50.1%
metadata-eval50.1%
div-inv50.1%
+-commutative50.1%
metadata-eval50.1%
Applied egg-rr50.1%
*-commutative50.1%
+-commutative50.1%
associate--l+75.3%
+-inverses75.3%
distribute-lft-in75.3%
metadata-eval75.3%
*-commutative75.3%
+-commutative75.3%
Simplified75.3%
expm1-log1p-u75.3%
*-commutative75.3%
+-commutative75.3%
+-rgt-identity75.3%
Applied egg-rr75.3%
expm1-log1p-u75.3%
Applied egg-rr75.3%
Final simplification75.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -5.5e-14) (not (<= x 3.3e-25)))
(* -2.0 (* (sin x) 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 <= -5.5e-14) || !(x <= 3.3e-25)) {
tmp = -2.0 * (sin(x) * 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 <= (-5.5d-14)) .or. (.not. (x <= 3.3d-25))) then
tmp = (-2.0d0) * (sin(x) * 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 <= -5.5e-14) || !(x <= 3.3e-25)) {
tmp = -2.0 * (Math.sin(x) * 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 <= -5.5e-14) or not (x <= 3.3e-25): tmp = -2.0 * (math.sin(x) * 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 <= -5.5e-14) || !(x <= 3.3e-25)) tmp = Float64(-2.0 * Float64(sin(x) * 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 <= -5.5e-14) || ~((x <= 3.3e-25))) tmp = -2.0 * (sin(x) * 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, -5.5e-14], N[Not[LessEqual[x, 3.3e-25]], $MachinePrecision]], N[(-2.0 * N[(N[Sin[x], $MachinePrecision] * 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 -5.5 \cdot 10^{-14} \lor \neg \left(x \leq 3.3 \cdot 10^{-25}\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -5.49999999999999991e-14 or 3.2999999999999998e-25 < x Initial program 8.3%
diff-cos7.2%
div-inv7.2%
metadata-eval7.2%
div-inv7.2%
+-commutative7.2%
metadata-eval7.2%
Applied egg-rr7.2%
*-commutative7.2%
+-commutative7.2%
associate--l+52.2%
+-inverses52.2%
distribute-lft-in52.2%
metadata-eval52.2%
*-commutative52.2%
+-commutative52.2%
Simplified52.2%
Taylor expanded in eps around 0 51.2%
if -5.49999999999999991e-14 < x < 3.2999999999999998e-25Initial program 72.3%
diff-cos95.1%
div-inv95.1%
metadata-eval95.1%
div-inv95.1%
+-commutative95.1%
metadata-eval95.1%
Applied egg-rr95.1%
*-commutative95.1%
+-commutative95.1%
associate--l+99.5%
+-inverses99.5%
distribute-lft-in99.5%
metadata-eval99.5%
*-commutative99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in x around 0 94.6%
Final simplification72.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.6e-14) (not (<= x 1.8e-25))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -3.6e-14) || !(x <= 1.8e-25)) {
tmp = eps * -sin(x);
} else {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-3.6d-14)) .or. (.not. (x <= 1.8d-25))) then
tmp = eps * -sin(x)
else
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -3.6e-14) || !(x <= 1.8e-25)) {
tmp = eps * -Math.sin(x);
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -3.6e-14) or not (x <= 1.8e-25): tmp = eps * -math.sin(x) else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -3.6e-14) || !(x <= 1.8e-25)) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -3.6e-14) || ~((x <= 1.8e-25))) tmp = eps * -sin(x); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -3.6e-14], N[Not[LessEqual[x, 1.8e-25]], $MachinePrecision]], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{-14} \lor \neg \left(x \leq 1.8 \cdot 10^{-25}\right):\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if x < -3.5999999999999998e-14 or 1.8e-25 < x Initial program 8.3%
Taylor expanded in eps around 0 47.8%
associate-*r*47.8%
mul-1-neg47.8%
Simplified47.8%
if -3.5999999999999998e-14 < x < 1.8e-25Initial program 72.3%
diff-cos95.1%
div-inv95.1%
metadata-eval95.1%
div-inv95.1%
+-commutative95.1%
metadata-eval95.1%
Applied egg-rr95.1%
*-commutative95.1%
+-commutative95.1%
associate--l+99.5%
+-inverses99.5%
distribute-lft-in99.5%
metadata-eval99.5%
*-commutative99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in x around 0 94.6%
Final simplification70.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* eps (- (sin x)))) (t_1 (+ -1.0 (cos eps))))
(if (<= eps -1.1e-5)
t_1
(if (<= eps -2.6e-36)
(* eps (* eps -0.5))
(if (<= eps 1.4e-124)
t_0
(if (<= eps 1.02e-58)
(fma -0.5 (* eps eps) (* eps (- x)))
(if (<= eps 3e-8) t_0 t_1)))))))
double code(double x, double eps) {
double t_0 = eps * -sin(x);
double t_1 = -1.0 + cos(eps);
double tmp;
if (eps <= -1.1e-5) {
tmp = t_1;
} else if (eps <= -2.6e-36) {
tmp = eps * (eps * -0.5);
} else if (eps <= 1.4e-124) {
tmp = t_0;
} else if (eps <= 1.02e-58) {
tmp = fma(-0.5, (eps * eps), (eps * -x));
} else if (eps <= 3e-8) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(eps * Float64(-sin(x))) t_1 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -1.1e-5) tmp = t_1; elseif (eps <= -2.6e-36) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 1.4e-124) tmp = t_0; elseif (eps <= 1.02e-58) tmp = fma(-0.5, Float64(eps * eps), Float64(eps * Float64(-x))); elseif (eps <= 3e-8) tmp = t_0; else tmp = t_1; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.1e-5], t$95$1, If[LessEqual[eps, -2.6e-36], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.4e-124], t$95$0, If[LessEqual[eps, 1.02e-58], N[(-0.5 * N[(eps * eps), $MachinePrecision] + N[(eps * (-x)), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3e-8], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \varepsilon \cdot \left(-\sin x\right)\\
t_1 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq -2.6 \cdot 10^{-36}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 1.4 \cdot 10^{-124}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.02 \cdot 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \varepsilon \cdot \varepsilon, \varepsilon \cdot \left(-x\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if eps < -1.1e-5 or 2.99999999999999973e-8 < eps Initial program 51.8%
Taylor expanded in x around 0 53.7%
if -1.1e-5 < eps < -2.6e-36Initial program 5.0%
Taylor expanded in x around 0 5.0%
Taylor expanded in eps around 0 78.3%
*-commutative78.3%
unpow278.3%
associate-*l*78.3%
Simplified78.3%
if -2.6e-36 < eps < 1.39999999999999999e-124 or 1.0199999999999999e-58 < eps < 2.99999999999999973e-8Initial program 31.9%
Taylor expanded in eps around 0 89.3%
associate-*r*89.3%
mul-1-neg89.3%
Simplified89.3%
if 1.39999999999999999e-124 < eps < 1.0199999999999999e-58Initial program 4.8%
Taylor expanded in eps around 0 4.8%
associate-+r+4.8%
mul-1-neg4.8%
unsub-neg4.8%
associate-*r*4.8%
distribute-rgt1-in4.8%
unpow24.8%
associate-*r*4.8%
Simplified4.8%
Taylor expanded in x around 0 79.3%
+-commutative79.3%
fma-def79.3%
unpow279.3%
mul-1-neg79.3%
distribute-rgt-neg-in79.3%
Simplified79.3%
Final simplification69.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))) (t_1 (* eps (* eps -0.5))))
(if (<= eps -1.1e-5)
t_0
(if (<= eps -5.5e-118)
t_1
(if (<= eps 3.8e-175) (* eps (- x)) (if (<= eps 0.000135) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double t_1 = eps * (eps * -0.5);
double tmp;
if (eps <= -1.1e-5) {
tmp = t_0;
} else if (eps <= -5.5e-118) {
tmp = t_1;
} else if (eps <= 3.8e-175) {
tmp = eps * -x;
} else if (eps <= 0.000135) {
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 = eps * (eps * (-0.5d0))
if (eps <= (-1.1d-5)) then
tmp = t_0
else if (eps <= (-5.5d-118)) then
tmp = t_1
else if (eps <= 3.8d-175) then
tmp = eps * -x
else if (eps <= 0.000135d0) 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 = eps * (eps * -0.5);
double tmp;
if (eps <= -1.1e-5) {
tmp = t_0;
} else if (eps <= -5.5e-118) {
tmp = t_1;
} else if (eps <= 3.8e-175) {
tmp = eps * -x;
} else if (eps <= 0.000135) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) t_1 = eps * (eps * -0.5) tmp = 0 if eps <= -1.1e-5: tmp = t_0 elif eps <= -5.5e-118: tmp = t_1 elif eps <= 3.8e-175: tmp = eps * -x elif eps <= 0.000135: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) t_1 = Float64(eps * Float64(eps * -0.5)) tmp = 0.0 if (eps <= -1.1e-5) tmp = t_0; elseif (eps <= -5.5e-118) tmp = t_1; elseif (eps <= 3.8e-175) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.000135) 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 = eps * (eps * -0.5); tmp = 0.0; if (eps <= -1.1e-5) tmp = t_0; elseif (eps <= -5.5e-118) tmp = t_1; elseif (eps <= 3.8e-175) tmp = eps * -x; elseif (eps <= 0.000135) 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[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.1e-5], t$95$0, If[LessEqual[eps, -5.5e-118], t$95$1, If[LessEqual[eps, 3.8e-175], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.000135], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
t_1 := \varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -5.5 \cdot 10^{-118}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 3.8 \cdot 10^{-175}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.000135:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.1e-5 or 1.35000000000000002e-4 < eps Initial program 52.0%
Taylor expanded in x around 0 53.9%
if -1.1e-5 < eps < -5.5000000000000003e-118 or 3.8e-175 < eps < 1.35000000000000002e-4Initial program 8.1%
Taylor expanded in x around 0 8.1%
Taylor expanded in eps around 0 54.4%
*-commutative54.4%
unpow254.4%
associate-*l*54.4%
Simplified54.4%
if -5.5000000000000003e-118 < eps < 3.8e-175Initial program 40.9%
Taylor expanded in eps around 0 97.0%
associate-*r*97.0%
mul-1-neg97.0%
Simplified97.0%
Taylor expanded in x around 0 50.4%
associate-*r*50.4%
neg-mul-150.4%
Simplified50.4%
Final simplification53.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))))
(if (<= eps -1.1e-5)
t_0
(if (<= eps -3e-37)
(* eps (* eps -0.5))
(if (<= eps 3e-8) (* eps (- (sin x))) t_0)))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double tmp;
if (eps <= -1.1e-5) {
tmp = t_0;
} else if (eps <= -3e-37) {
tmp = eps * (eps * -0.5);
} else if (eps <= 3e-8) {
tmp = eps * -sin(x);
} 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 <= (-1.1d-5)) then
tmp = t_0
else if (eps <= (-3d-37)) then
tmp = eps * (eps * (-0.5d0))
else if (eps <= 3d-8) then
tmp = eps * -sin(x)
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 <= -1.1e-5) {
tmp = t_0;
} else if (eps <= -3e-37) {
tmp = eps * (eps * -0.5);
} else if (eps <= 3e-8) {
tmp = eps * -Math.sin(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) tmp = 0 if eps <= -1.1e-5: tmp = t_0 elif eps <= -3e-37: tmp = eps * (eps * -0.5) elif eps <= 3e-8: tmp = eps * -math.sin(x) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -1.1e-5) tmp = t_0; elseif (eps <= -3e-37) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 3e-8) tmp = Float64(eps * Float64(-sin(x))); 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 <= -1.1e-5) tmp = t_0; elseif (eps <= -3e-37) tmp = eps * (eps * -0.5); elseif (eps <= 3e-8) tmp = eps * -sin(x); 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, -1.1e-5], t$95$0, If[LessEqual[eps, -3e-37], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3e-8], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -3 \cdot 10^{-37}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-8}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.1e-5 or 2.99999999999999973e-8 < eps Initial program 51.8%
Taylor expanded in x around 0 53.7%
if -1.1e-5 < eps < -3e-37Initial program 5.0%
Taylor expanded in x around 0 5.0%
Taylor expanded in eps around 0 78.3%
*-commutative78.3%
unpow278.3%
associate-*l*78.3%
Simplified78.3%
if -3e-37 < eps < 2.99999999999999973e-8Initial program 28.4%
Taylor expanded in eps around 0 82.9%
associate-*r*82.9%
mul-1-neg82.9%
Simplified82.9%
Final simplification67.2%
(FPCore (x eps) :precision binary64 (if (<= x -2.4e-72) (* eps (- x)) (* eps (* eps -0.5))))
double code(double x, double eps) {
double tmp;
if (x <= -2.4e-72) {
tmp = eps * -x;
} else {
tmp = eps * (eps * -0.5);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2.4d-72)) then
tmp = eps * -x
else
tmp = eps * (eps * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.4e-72) {
tmp = eps * -x;
} else {
tmp = eps * (eps * -0.5);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.4e-72: tmp = eps * -x else: tmp = eps * (eps * -0.5) return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.4e-72) tmp = Float64(eps * Float64(-x)); else tmp = Float64(eps * Float64(eps * -0.5)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.4e-72) tmp = eps * -x; else tmp = eps * (eps * -0.5); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.4e-72], N[(eps * (-x)), $MachinePrecision], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{-72}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\end{array}
\end{array}
if x < -2.4e-72Initial program 20.6%
Taylor expanded in eps around 0 49.1%
associate-*r*49.1%
mul-1-neg49.1%
Simplified49.1%
Taylor expanded in x around 0 9.5%
associate-*r*9.5%
neg-mul-19.5%
Simplified9.5%
if -2.4e-72 < x Initial program 48.2%
Taylor expanded in x around 0 49.3%
Taylor expanded in eps around 0 34.9%
*-commutative34.9%
unpow234.9%
associate-*l*34.9%
Simplified34.9%
Final simplification27.0%
(FPCore (x eps) :precision binary64 (* eps (- x)))
double code(double x, double eps) {
return eps * -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * -x
end function
public static double code(double x, double eps) {
return eps * -x;
}
def code(x, eps): return eps * -x
function code(x, eps) return Float64(eps * Float64(-x)) end
function tmp = code(x, eps) tmp = eps * -x; end
code[x_, eps_] := N[(eps * (-x)), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(-x\right)
\end{array}
Initial program 39.6%
Taylor expanded in eps around 0 38.6%
associate-*r*38.6%
mul-1-neg38.6%
Simplified38.6%
Taylor expanded in x around 0 17.6%
associate-*r*17.6%
neg-mul-117.6%
Simplified17.6%
Final simplification17.6%
herbie shell --seed 2023200
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))