
(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
(let* ((t_0 (* (sin x) (- (sin eps)))))
(if (<= eps -0.0028)
(- (fma (cos x) (cos eps) t_0) (cos x))
(if (<= eps 0.0026)
(+
(-
(* (* (sin x) -0.08333333333333333) (* -2.0 (pow eps 3.0)))
(* eps (sin x)))
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps)))))
(fma (cos x) (cos eps) (- t_0 (cos x)))))))
double code(double x, double eps) {
double t_0 = sin(x) * -sin(eps);
double tmp;
if (eps <= -0.0028) {
tmp = fma(cos(x), cos(eps), t_0) - cos(x);
} else if (eps <= 0.0026) {
tmp = (((sin(x) * -0.08333333333333333) * (-2.0 * pow(eps, 3.0))) - (eps * sin(x))) + (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps))));
} else {
tmp = fma(cos(x), cos(eps), (t_0 - cos(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(x) * Float64(-sin(eps))) tmp = 0.0 if (eps <= -0.0028) tmp = Float64(fma(cos(x), cos(eps), t_0) - cos(x)); elseif (eps <= 0.0026) tmp = Float64(Float64(Float64(Float64(sin(x) * -0.08333333333333333) * Float64(-2.0 * (eps ^ 3.0))) - Float64(eps * sin(x))) + Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps))))); else tmp = fma(cos(x), cos(eps), Float64(t_0 - cos(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[eps, -0.0028], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + t$95$0), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0026], N[(N[(N[(N[(N[Sin[x], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * N[(-2.0 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[(t$95$0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \left(-\sin \varepsilon\right)\\
\mathbf{if}\;\varepsilon \leq -0.0028:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, t_0\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.0026:\\
\;\;\;\;\left(\left(\sin x \cdot -0.08333333333333333\right) \cdot \left(-2 \cdot {\varepsilon}^{3}\right) - \varepsilon \cdot \sin x\right) + \cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, t_0 - \cos x\right)\\
\end{array}
\end{array}
if eps < -0.00279999999999999997Initial program 49.4%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.3%
Applied egg-rr99.3%
if -0.00279999999999999997 < eps < 0.0025999999999999999Initial program 23.2%
diff-cos34.5%
div-inv34.5%
metadata-eval34.5%
div-inv34.5%
+-commutative34.5%
metadata-eval34.5%
Applied egg-rr34.5%
*-commutative34.5%
+-commutative34.5%
associate--l+99.6%
+-inverses99.6%
distribute-lft-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
*-commutative99.6%
+-commutative99.6%
+-rgt-identity99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
Applied egg-rr99.6%
Taylor expanded in eps around 0 99.7%
associate-+r+99.7%
+-commutative99.7%
+-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
Simplified99.7%
if 0.0025999999999999999 < eps Initial program 55.8%
sub-neg55.8%
cos-sum98.6%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.0021)
(- (fma (cos x) (cos eps) (* (sin x) (- (sin eps)))) (cos x))
(if (<= eps 0.0027)
(+
(-
(* (* (sin x) -0.08333333333333333) (* -2.0 (pow eps 3.0)))
(* eps (sin x)))
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps)))))
(- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0021) {
tmp = fma(cos(x), cos(eps), (sin(x) * -sin(eps))) - cos(x);
} else if (eps <= 0.0027) {
tmp = (((sin(x) * -0.08333333333333333) * (-2.0 * pow(eps, 3.0))) - (eps * sin(x))) + (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps))));
} else {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -0.0021) tmp = Float64(fma(cos(x), cos(eps), Float64(sin(x) * Float64(-sin(eps)))) - cos(x)); elseif (eps <= 0.0027) tmp = Float64(Float64(Float64(Float64(sin(x) * -0.08333333333333333) * Float64(-2.0 * (eps ^ 3.0))) - Float64(eps * sin(x))) + Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps))))); else tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.0021], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0027], N[(N[(N[(N[(N[Sin[x], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * N[(-2.0 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0021:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.0027:\\
\;\;\;\;\left(\left(\sin x \cdot -0.08333333333333333\right) \cdot \left(-2 \cdot {\varepsilon}^{3}\right) - \varepsilon \cdot \sin x\right) + \cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.00209999999999999987Initial program 49.4%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.3%
Applied egg-rr99.3%
if -0.00209999999999999987 < eps < 0.0027000000000000001Initial program 23.2%
diff-cos34.5%
div-inv34.5%
metadata-eval34.5%
div-inv34.5%
+-commutative34.5%
metadata-eval34.5%
Applied egg-rr34.5%
*-commutative34.5%
+-commutative34.5%
associate--l+99.6%
+-inverses99.6%
distribute-lft-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
*-commutative99.6%
+-commutative99.6%
+-rgt-identity99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
Applied egg-rr99.6%
Taylor expanded in eps around 0 99.7%
associate-+r+99.7%
+-commutative99.7%
+-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
Simplified99.7%
if 0.0027000000000000001 < eps Initial program 55.8%
sub-neg55.8%
cos-sum98.6%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.6%
remove-double-neg98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.7%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin x) (sin eps))))
(if (<= eps -0.003)
(- (- t_0 t_1) (cos x))
(if (<= eps 0.0028)
(+
(-
(* (* (sin x) -0.08333333333333333) (* -2.0 (pow eps 3.0)))
(* eps (sin x)))
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps)))))
(- t_0 (+ (cos x) t_1))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.003) {
tmp = (t_0 - t_1) - cos(x);
} else if (eps <= 0.0028) {
tmp = (((sin(x) * -0.08333333333333333) * (-2.0 * pow(eps, 3.0))) - (eps * sin(x))) + (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps))));
} else {
tmp = t_0 - (cos(x) + 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 = cos(x) * cos(eps)
t_1 = sin(x) * sin(eps)
if (eps <= (-0.003d0)) then
tmp = (t_0 - t_1) - cos(x)
else if (eps <= 0.0028d0) then
tmp = (((sin(x) * (-0.08333333333333333d0)) * ((-2.0d0) * (eps ** 3.0d0))) - (eps * sin(x))) + (cos(x) * ((0.041666666666666664d0 * (eps ** 4.0d0)) + ((-0.5d0) * (eps * eps))))
else
tmp = t_0 - (cos(x) + t_1)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(x) * Math.cos(eps);
double t_1 = Math.sin(x) * Math.sin(eps);
double tmp;
if (eps <= -0.003) {
tmp = (t_0 - t_1) - Math.cos(x);
} else if (eps <= 0.0028) {
tmp = (((Math.sin(x) * -0.08333333333333333) * (-2.0 * Math.pow(eps, 3.0))) - (eps * Math.sin(x))) + (Math.cos(x) * ((0.041666666666666664 * Math.pow(eps, 4.0)) + (-0.5 * (eps * eps))));
} else {
tmp = t_0 - (Math.cos(x) + t_1);
}
return tmp;
}
def code(x, eps): t_0 = math.cos(x) * math.cos(eps) t_1 = math.sin(x) * math.sin(eps) tmp = 0 if eps <= -0.003: tmp = (t_0 - t_1) - math.cos(x) elif eps <= 0.0028: tmp = (((math.sin(x) * -0.08333333333333333) * (-2.0 * math.pow(eps, 3.0))) - (eps * math.sin(x))) + (math.cos(x) * ((0.041666666666666664 * math.pow(eps, 4.0)) + (-0.5 * (eps * eps)))) else: tmp = t_0 - (math.cos(x) + t_1) return tmp
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) t_1 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.003) tmp = Float64(Float64(t_0 - t_1) - cos(x)); elseif (eps <= 0.0028) tmp = Float64(Float64(Float64(Float64(sin(x) * -0.08333333333333333) * Float64(-2.0 * (eps ^ 3.0))) - Float64(eps * sin(x))) + Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps))))); else tmp = Float64(t_0 - Float64(cos(x) + t_1)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(x) * cos(eps); t_1 = sin(x) * sin(eps); tmp = 0.0; if (eps <= -0.003) tmp = (t_0 - t_1) - cos(x); elseif (eps <= 0.0028) tmp = (((sin(x) * -0.08333333333333333) * (-2.0 * (eps ^ 3.0))) - (eps * sin(x))) + (cos(x) * ((0.041666666666666664 * (eps ^ 4.0)) + (-0.5 * (eps * eps)))); else tmp = t_0 - (cos(x) + t_1); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.003], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0028], N[(N[(N[(N[(N[Sin[x], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * N[(-2.0 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
t_1 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.003:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.0028:\\
\;\;\;\;\left(\left(\sin x \cdot -0.08333333333333333\right) \cdot \left(-2 \cdot {\varepsilon}^{3}\right) - \varepsilon \cdot \sin x\right) + \cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\end{array}
\end{array}
if eps < -0.0030000000000000001Initial program 49.4%
cos-sum99.3%
Applied egg-rr99.3%
if -0.0030000000000000001 < eps < 0.00279999999999999997Initial program 23.2%
diff-cos34.5%
div-inv34.5%
metadata-eval34.5%
div-inv34.5%
+-commutative34.5%
metadata-eval34.5%
Applied egg-rr34.5%
*-commutative34.5%
+-commutative34.5%
associate--l+99.6%
+-inverses99.6%
distribute-lft-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
*-commutative99.6%
+-commutative99.6%
+-rgt-identity99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
Applied egg-rr99.6%
Taylor expanded in eps around 0 99.7%
associate-+r+99.7%
+-commutative99.7%
+-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
associate-*r*99.7%
*-commutative99.7%
distribute-rgt-out99.7%
metadata-eval99.7%
Simplified99.7%
if 0.00279999999999999997 < eps Initial program 55.8%
sub-neg55.8%
cos-sum98.6%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.6%
remove-double-neg98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.7%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00022) (not (<= eps 0.000135))) (- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps)))) (* -2.0 (* (sin (* 0.5 (+ x (+ eps x)))) (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00022) || !(eps <= 0.000135)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
} else {
tmp = -2.0 * (sin((0.5 * (x + (eps + x)))) * sin((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 ((eps <= (-0.00022d0)) .or. (.not. (eps <= 0.000135d0))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
else
tmp = (-2.0d0) * (sin((0.5d0 * (x + (eps + x)))) * sin((eps * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00022) || !(eps <= 0.000135)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
} else {
tmp = -2.0 * (Math.sin((0.5 * (x + (eps + x)))) * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00022) or not (eps <= 0.000135): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps))) else: tmp = -2.0 * (math.sin((0.5 * (x + (eps + x)))) * math.sin((eps * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00022) || !(eps <= 0.000135)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); else tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * Float64(x + Float64(eps + x)))) * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00022) || ~((eps <= 0.000135))) tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps))); else tmp = -2.0 * (sin((0.5 * (x + (eps + x)))) * sin((eps * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00022], N[Not[LessEqual[eps, 0.000135]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00022 \lor \neg \left(\varepsilon \leq 0.000135\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-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}
\end{array}
if eps < -2.20000000000000008e-4 or 1.35000000000000002e-4 < eps Initial program 52.5%
sub-neg52.5%
cos-sum99.0%
associate-+l-99.0%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg99.0%
*-commutative99.0%
*-commutative99.0%
fma-neg98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in eps around inf 99.0%
if -2.20000000000000008e-4 < eps < 1.35000000000000002e-4Initial program 23.2%
diff-cos34.5%
div-inv34.5%
metadata-eval34.5%
div-inv34.5%
+-commutative34.5%
metadata-eval34.5%
Applied egg-rr34.5%
*-commutative34.5%
+-commutative34.5%
associate--l+99.6%
+-inverses99.6%
distribute-lft-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
*-commutative99.6%
+-commutative99.6%
+-rgt-identity99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
Applied egg-rr99.6%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin x) (sin eps))))
(if (<= eps -1.55e-5)
(- (- t_0 t_1) (cos x))
(if (<= eps 0.000135)
(* -2.0 (* (sin (* 0.5 (+ x (+ eps x)))) (sin (* eps 0.5))))
(- t_0 (+ (cos x) t_1))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -1.55e-5) {
tmp = (t_0 - t_1) - cos(x);
} else if (eps <= 0.000135) {
tmp = -2.0 * (sin((0.5 * (x + (eps + x)))) * sin((eps * 0.5)));
} else {
tmp = t_0 - (cos(x) + 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 = cos(x) * cos(eps)
t_1 = sin(x) * sin(eps)
if (eps <= (-1.55d-5)) then
tmp = (t_0 - t_1) - cos(x)
else if (eps <= 0.000135d0) then
tmp = (-2.0d0) * (sin((0.5d0 * (x + (eps + x)))) * sin((eps * 0.5d0)))
else
tmp = t_0 - (cos(x) + t_1)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(x) * Math.cos(eps);
double t_1 = Math.sin(x) * Math.sin(eps);
double tmp;
if (eps <= -1.55e-5) {
tmp = (t_0 - t_1) - Math.cos(x);
} else if (eps <= 0.000135) {
tmp = -2.0 * (Math.sin((0.5 * (x + (eps + x)))) * Math.sin((eps * 0.5)));
} else {
tmp = t_0 - (Math.cos(x) + t_1);
}
return tmp;
}
def code(x, eps): t_0 = math.cos(x) * math.cos(eps) t_1 = math.sin(x) * math.sin(eps) tmp = 0 if eps <= -1.55e-5: tmp = (t_0 - t_1) - math.cos(x) elif eps <= 0.000135: tmp = -2.0 * (math.sin((0.5 * (x + (eps + x)))) * math.sin((eps * 0.5))) else: tmp = t_0 - (math.cos(x) + t_1) return tmp
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) t_1 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -1.55e-5) tmp = Float64(Float64(t_0 - t_1) - cos(x)); elseif (eps <= 0.000135) tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * Float64(x + Float64(eps + x)))) * sin(Float64(eps * 0.5)))); else tmp = Float64(t_0 - Float64(cos(x) + t_1)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(x) * cos(eps); t_1 = sin(x) * sin(eps); tmp = 0.0; if (eps <= -1.55e-5) tmp = (t_0 - t_1) - cos(x); elseif (eps <= 0.000135) tmp = -2.0 * (sin((0.5 * (x + (eps + x)))) * sin((eps * 0.5))); else tmp = t_0 - (cos(x) + t_1); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1.55e-5], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.000135], 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], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
t_1 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -1.55 \cdot 10^{-5}:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.000135:\\
\;\;\;\;-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)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\end{array}
\end{array}
if eps < -1.55000000000000007e-5Initial program 49.4%
cos-sum99.3%
Applied egg-rr99.3%
if -1.55000000000000007e-5 < eps < 1.35000000000000002e-4Initial program 23.2%
diff-cos34.5%
div-inv34.5%
metadata-eval34.5%
div-inv34.5%
+-commutative34.5%
metadata-eval34.5%
Applied egg-rr34.5%
*-commutative34.5%
+-commutative34.5%
associate--l+99.6%
+-inverses99.6%
distribute-lft-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
expm1-log1p-u99.6%
*-commutative99.6%
+-commutative99.6%
+-rgt-identity99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
Applied egg-rr99.6%
if 1.35000000000000002e-4 < eps Initial program 55.8%
sub-neg55.8%
cos-sum98.6%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.6%
remove-double-neg98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.7%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.0021)
(- (cos eps) (cos x))
(if (<= eps 9e-5)
(- (* -0.5 (* eps (* eps (cos x)))) (* eps (sin x)))
(* -2.0 (pow (sin (* eps 0.5)) 2.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0021) {
tmp = cos(eps) - cos(x);
} else if (eps <= 9e-5) {
tmp = (-0.5 * (eps * (eps * cos(x)))) - (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 (eps <= (-0.0021d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 9d-5) then
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) - (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 (eps <= -0.0021) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 9e-5) {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) - (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 eps <= -0.0021: tmp = math.cos(eps) - math.cos(x) elif eps <= 9e-5: tmp = (-0.5 * (eps * (eps * math.cos(x)))) - (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 (eps <= -0.0021) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 9e-5) tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) - Float64(eps * 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 (eps <= -0.0021) tmp = cos(eps) - cos(x); elseif (eps <= 9e-5) tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x)); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0021], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9e-5], N[(N[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $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}\;\varepsilon \leq -0.0021:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 9 \cdot 10^{-5}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) - \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if eps < -0.00209999999999999987Initial program 49.4%
Taylor expanded in x around 0 52.5%
if -0.00209999999999999987 < eps < 9.00000000000000057e-5Initial program 23.0%
Taylor expanded in eps around 0 99.5%
mul-1-neg99.5%
unsub-neg99.5%
unpow299.5%
associate-*l*99.5%
Simplified99.5%
if 9.00000000000000057e-5 < eps Initial program 55.9%
diff-cos57.6%
div-inv57.6%
metadata-eval57.6%
div-inv57.6%
+-commutative57.6%
metadata-eval57.6%
Applied egg-rr57.6%
*-commutative57.6%
+-commutative57.6%
associate--l+59.6%
+-inverses59.6%
distribute-lft-in59.6%
metadata-eval59.6%
*-commutative59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in x around 0 57.9%
Final simplification78.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 37.3%
diff-cos43.1%
div-inv43.1%
metadata-eval43.1%
div-inv43.1%
+-commutative43.1%
metadata-eval43.1%
Applied egg-rr43.1%
*-commutative43.1%
+-commutative43.1%
associate--l+78.0%
+-inverses78.0%
distribute-lft-in78.0%
metadata-eval78.0%
*-commutative78.0%
+-commutative78.0%
Simplified78.0%
expm1-log1p-u78.0%
*-commutative78.0%
+-commutative78.0%
+-rgt-identity78.0%
Applied egg-rr78.0%
expm1-log1p-u78.0%
Applied egg-rr78.0%
Final simplification78.0%
(FPCore (x eps)
:precision binary64
(if (<= eps -2.5e-5)
(- (cos eps) (cos x))
(if (<= eps 1.05e-54)
(* eps (- (sin x)))
(if (<= eps 2.45e-5)
(* -2.0 (* (sin (* eps 0.5)) (+ x (* eps 0.5))))
(+ (* (cos x) (cos eps)) -1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -2.5e-5) {
tmp = cos(eps) - cos(x);
} else if (eps <= 1.05e-54) {
tmp = eps * -sin(x);
} else if (eps <= 2.45e-5) {
tmp = -2.0 * (sin((eps * 0.5)) * (x + (eps * 0.5)));
} else {
tmp = (cos(x) * cos(eps)) + -1.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-2.5d-5)) then
tmp = cos(eps) - cos(x)
else if (eps <= 1.05d-54) then
tmp = eps * -sin(x)
else if (eps <= 2.45d-5) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) * (x + (eps * 0.5d0)))
else
tmp = (cos(x) * cos(eps)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -2.5e-5) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 1.05e-54) {
tmp = eps * -Math.sin(x);
} else if (eps <= 2.45e-5) {
tmp = -2.0 * (Math.sin((eps * 0.5)) * (x + (eps * 0.5)));
} else {
tmp = (Math.cos(x) * Math.cos(eps)) + -1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -2.5e-5: tmp = math.cos(eps) - math.cos(x) elif eps <= 1.05e-54: tmp = eps * -math.sin(x) elif eps <= 2.45e-5: tmp = -2.0 * (math.sin((eps * 0.5)) * (x + (eps * 0.5))) else: tmp = (math.cos(x) * math.cos(eps)) + -1.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= -2.5e-5) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 1.05e-54) tmp = Float64(eps * Float64(-sin(x))); elseif (eps <= 2.45e-5) tmp = Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * Float64(x + Float64(eps * 0.5)))); else tmp = Float64(Float64(cos(x) * cos(eps)) + -1.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -2.5e-5) tmp = cos(eps) - cos(x); elseif (eps <= 1.05e-54) tmp = eps * -sin(x); elseif (eps <= 2.45e-5) tmp = -2.0 * (sin((eps * 0.5)) * (x + (eps * 0.5))); else tmp = (cos(x) * cos(eps)) + -1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -2.5e-5], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.05e-54], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.45e-5], N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[(x + N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.5 \cdot 10^{-5}:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 1.05 \cdot 10^{-54}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \left(x + \varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon + -1\\
\end{array}
\end{array}
if eps < -2.50000000000000012e-5Initial program 49.4%
Taylor expanded in x around 0 52.5%
if -2.50000000000000012e-5 < eps < 1.05e-54Initial program 23.8%
Taylor expanded in eps around 0 92.6%
associate-*r*92.6%
mul-1-neg92.6%
Simplified92.6%
if 1.05e-54 < eps < 2.45e-5Initial program 3.6%
diff-cos75.7%
div-inv75.7%
metadata-eval75.7%
div-inv75.7%
+-commutative75.7%
metadata-eval75.7%
Applied egg-rr75.7%
*-commutative75.7%
+-commutative75.7%
associate--l+99.8%
+-inverses99.8%
distribute-lft-in99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in eps around 0 99.8%
Taylor expanded in x around 0 87.7%
associate-*r*87.7%
*-commutative87.7%
distribute-rgt-out87.7%
Simplified87.7%
if 2.45e-5 < eps Initial program 56.1%
sub-neg56.1%
cos-sum97.7%
associate-+l-97.8%
fma-neg97.8%
Applied egg-rr97.8%
fma-neg97.8%
*-commutative97.8%
*-commutative97.8%
fma-neg97.7%
remove-double-neg97.7%
Simplified97.7%
Taylor expanded in x around 0 56.4%
Final simplification73.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -1.06e-44) (not (<= x 4.5e-47)))
(* -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 <= -1.06e-44) || !(x <= 4.5e-47)) {
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 <= (-1.06d-44)) .or. (.not. (x <= 4.5d-47))) 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 <= -1.06e-44) || !(x <= 4.5e-47)) {
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 <= -1.06e-44) or not (x <= 4.5e-47): 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 <= -1.06e-44) || !(x <= 4.5e-47)) 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 <= -1.06e-44) || ~((x <= 4.5e-47))) 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, -1.06e-44], N[Not[LessEqual[x, 4.5e-47]], $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 -1.06 \cdot 10^{-44} \lor \neg \left(x \leq 4.5 \cdot 10^{-47}\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -1.0599999999999999e-44 or 4.5e-47 < x Initial program 11.1%
diff-cos11.8%
div-inv11.8%
metadata-eval11.8%
div-inv11.8%
+-commutative11.8%
metadata-eval11.8%
Applied egg-rr11.8%
*-commutative11.8%
+-commutative11.8%
associate--l+65.8%
+-inverses65.8%
distribute-lft-in65.8%
metadata-eval65.8%
*-commutative65.8%
+-commutative65.8%
Simplified65.8%
Taylor expanded in eps around 0 59.1%
Taylor expanded in x around -inf 59.1%
Taylor expanded in eps around 0 61.0%
if -1.0599999999999999e-44 < x < 4.5e-47Initial program 83.2%
diff-cos98.1%
div-inv98.1%
metadata-eval98.1%
div-inv98.1%
+-commutative98.1%
metadata-eval98.1%
Applied egg-rr98.1%
*-commutative98.1%
+-commutative98.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 97.2%
Final simplification74.1%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.0004)
(- (cos eps) (cos x))
(if (<= eps 5.4e-45)
(* eps (- (sin x)))
(* -2.0 (pow (sin (* eps 0.5)) 2.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0004) {
tmp = cos(eps) - cos(x);
} else if (eps <= 5.4e-45) {
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 (eps <= (-0.0004d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 5.4d-45) 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 (eps <= -0.0004) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 5.4e-45) {
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 eps <= -0.0004: tmp = math.cos(eps) - math.cos(x) elif eps <= 5.4e-45: 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 (eps <= -0.0004) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 5.4e-45) 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 (eps <= -0.0004) tmp = cos(eps) - cos(x); elseif (eps <= 5.4e-45) tmp = eps * -sin(x); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0004], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.4e-45], 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}\;\varepsilon \leq -0.0004:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 5.4 \cdot 10^{-45}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if eps < -4.00000000000000019e-4Initial program 49.4%
Taylor expanded in x around 0 52.5%
if -4.00000000000000019e-4 < eps < 5.3999999999999997e-45Initial program 23.7%
Taylor expanded in eps around 0 92.7%
associate-*r*92.7%
mul-1-neg92.7%
Simplified92.7%
if 5.3999999999999997e-45 < eps Initial program 50.8%
diff-cos60.7%
div-inv60.7%
metadata-eval60.7%
div-inv60.7%
+-commutative60.7%
metadata-eval60.7%
Applied egg-rr60.7%
*-commutative60.7%
+-commutative60.7%
associate--l+64.2%
+-inverses64.2%
distribute-lft-in64.2%
metadata-eval64.2%
*-commutative64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in x around 0 59.2%
Final simplification73.7%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.2e-6)
(- (cos eps) (cos x))
(if (<= eps 3.8e-53)
(* eps (- (sin x)))
(if (<= eps 2.4e-5)
(* -2.0 (* (sin (* eps 0.5)) (+ x (* eps 0.5))))
(+ (cos eps) -1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.2e-6) {
tmp = cos(eps) - cos(x);
} else if (eps <= 3.8e-53) {
tmp = eps * -sin(x);
} else if (eps <= 2.4e-5) {
tmp = -2.0 * (sin((eps * 0.5)) * (x + (eps * 0.5)));
} else {
tmp = cos(eps) + -1.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-1.2d-6)) then
tmp = cos(eps) - cos(x)
else if (eps <= 3.8d-53) then
tmp = eps * -sin(x)
else if (eps <= 2.4d-5) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) * (x + (eps * 0.5d0)))
else
tmp = cos(eps) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -1.2e-6) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 3.8e-53) {
tmp = eps * -Math.sin(x);
} else if (eps <= 2.4e-5) {
tmp = -2.0 * (Math.sin((eps * 0.5)) * (x + (eps * 0.5)));
} else {
tmp = Math.cos(eps) + -1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.2e-6: tmp = math.cos(eps) - math.cos(x) elif eps <= 3.8e-53: tmp = eps * -math.sin(x) elif eps <= 2.4e-5: tmp = -2.0 * (math.sin((eps * 0.5)) * (x + (eps * 0.5))) else: tmp = math.cos(eps) + -1.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.2e-6) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 3.8e-53) tmp = Float64(eps * Float64(-sin(x))); elseif (eps <= 2.4e-5) tmp = Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * Float64(x + Float64(eps * 0.5)))); else tmp = Float64(cos(eps) + -1.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.2e-6) tmp = cos(eps) - cos(x); elseif (eps <= 3.8e-53) tmp = eps * -sin(x); elseif (eps <= 2.4e-5) tmp = -2.0 * (sin((eps * 0.5)) * (x + (eps * 0.5))); else tmp = cos(eps) + -1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.2e-6], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.8e-53], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.4e-5], N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[(x + N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.2 \cdot 10^{-6}:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 3.8 \cdot 10^{-53}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-5}:\\
\;\;\;\;-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \left(x + \varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \varepsilon + -1\\
\end{array}
\end{array}
if eps < -1.1999999999999999e-6Initial program 49.4%
Taylor expanded in x around 0 52.5%
if -1.1999999999999999e-6 < eps < 3.7999999999999998e-53Initial program 23.8%
Taylor expanded in eps around 0 92.6%
associate-*r*92.6%
mul-1-neg92.6%
Simplified92.6%
if 3.7999999999999998e-53 < eps < 2.4000000000000001e-5Initial program 3.6%
diff-cos75.7%
div-inv75.7%
metadata-eval75.7%
div-inv75.7%
+-commutative75.7%
metadata-eval75.7%
Applied egg-rr75.7%
*-commutative75.7%
+-commutative75.7%
associate--l+99.8%
+-inverses99.8%
distribute-lft-in99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in eps around 0 99.8%
Taylor expanded in x around 0 87.7%
associate-*r*87.7%
*-commutative87.7%
distribute-rgt-out87.7%
Simplified87.7%
if 2.4000000000000001e-5 < eps Initial program 56.1%
Taylor expanded in x around 0 56.3%
Final simplification73.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)))
(if (<= eps -1.85e-6)
t_0
(if (<= eps 8.4e-54)
(* eps (- (sin x)))
(if (<= eps 2.45e-5)
(* -2.0 (* (sin (* eps 0.5)) (+ x (* eps 0.5))))
t_0)))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double tmp;
if (eps <= -1.85e-6) {
tmp = t_0;
} else if (eps <= 8.4e-54) {
tmp = eps * -sin(x);
} else if (eps <= 2.45e-5) {
tmp = -2.0 * (sin((eps * 0.5)) * (x + (eps * 0.5)));
} 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) + (-1.0d0)
if (eps <= (-1.85d-6)) then
tmp = t_0
else if (eps <= 8.4d-54) then
tmp = eps * -sin(x)
else if (eps <= 2.45d-5) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) * (x + (eps * 0.5d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(eps) + -1.0;
double tmp;
if (eps <= -1.85e-6) {
tmp = t_0;
} else if (eps <= 8.4e-54) {
tmp = eps * -Math.sin(x);
} else if (eps <= 2.45e-5) {
tmp = -2.0 * (Math.sin((eps * 0.5)) * (x + (eps * 0.5)));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 tmp = 0 if eps <= -1.85e-6: tmp = t_0 elif eps <= 8.4e-54: tmp = eps * -math.sin(x) elif eps <= 2.45e-5: tmp = -2.0 * (math.sin((eps * 0.5)) * (x + (eps * 0.5))) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) tmp = 0.0 if (eps <= -1.85e-6) tmp = t_0; elseif (eps <= 8.4e-54) tmp = Float64(eps * Float64(-sin(x))); elseif (eps <= 2.45e-5) tmp = Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * Float64(x + Float64(eps * 0.5)))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) + -1.0; tmp = 0.0; if (eps <= -1.85e-6) tmp = t_0; elseif (eps <= 8.4e-54) tmp = eps * -sin(x); elseif (eps <= 2.45e-5) tmp = -2.0 * (sin((eps * 0.5)) * (x + (eps * 0.5))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[eps, -1.85e-6], t$95$0, If[LessEqual[eps, 8.4e-54], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 2.45e-5], N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[(x + N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -1.85 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 8.4 \cdot 10^{-54}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \left(x + \varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.8500000000000001e-6 or 2.45e-5 < eps Initial program 52.7%
Taylor expanded in x around 0 53.1%
if -1.8500000000000001e-6 < eps < 8.4e-54Initial program 23.8%
Taylor expanded in eps around 0 92.6%
associate-*r*92.6%
mul-1-neg92.6%
Simplified92.6%
if 8.4e-54 < eps < 2.45e-5Initial program 3.6%
diff-cos75.7%
div-inv75.7%
metadata-eval75.7%
div-inv75.7%
+-commutative75.7%
metadata-eval75.7%
Applied egg-rr75.7%
*-commutative75.7%
+-commutative75.7%
associate--l+99.8%
+-inverses99.8%
distribute-lft-in99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in eps around 0 99.8%
Taylor expanded in x around 0 87.7%
associate-*r*87.7%
*-commutative87.7%
distribute-rgt-out87.7%
Simplified87.7%
Final simplification73.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* eps (- (sin x)))))
(if (<= eps -7.5e-7)
t_0
(if (<= eps 4.5e-44)
t_1
(if (<= eps 2.45e-5)
(* eps (* eps -0.5))
(if (<= eps 4.8e-5) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = eps * -sin(x);
double tmp;
if (eps <= -7.5e-7) {
tmp = t_0;
} else if (eps <= 4.5e-44) {
tmp = t_1;
} else if (eps <= 2.45e-5) {
tmp = eps * (eps * -0.5);
} else if (eps <= 4.8e-5) {
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 = cos(eps) + (-1.0d0)
t_1 = eps * -sin(x)
if (eps <= (-7.5d-7)) then
tmp = t_0
else if (eps <= 4.5d-44) then
tmp = t_1
else if (eps <= 2.45d-5) then
tmp = eps * (eps * (-0.5d0))
else if (eps <= 4.8d-5) 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 = Math.cos(eps) + -1.0;
double t_1 = eps * -Math.sin(x);
double tmp;
if (eps <= -7.5e-7) {
tmp = t_0;
} else if (eps <= 4.5e-44) {
tmp = t_1;
} else if (eps <= 2.45e-5) {
tmp = eps * (eps * -0.5);
} else if (eps <= 4.8e-5) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = eps * -math.sin(x) tmp = 0 if eps <= -7.5e-7: tmp = t_0 elif eps <= 4.5e-44: tmp = t_1 elif eps <= 2.45e-5: tmp = eps * (eps * -0.5) elif eps <= 4.8e-5: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(eps * Float64(-sin(x))) tmp = 0.0 if (eps <= -7.5e-7) tmp = t_0; elseif (eps <= 4.5e-44) tmp = t_1; elseif (eps <= 2.45e-5) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 4.8e-5) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) + -1.0; t_1 = eps * -sin(x); tmp = 0.0; if (eps <= -7.5e-7) tmp = t_0; elseif (eps <= 4.5e-44) tmp = t_1; elseif (eps <= 2.45e-5) tmp = eps * (eps * -0.5); elseif (eps <= 4.8e-5) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[eps, -7.5e-7], t$95$0, If[LessEqual[eps, 4.5e-44], t$95$1, If[LessEqual[eps, 2.45e-5], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.8e-5], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \varepsilon \cdot \left(-\sin x\right)\\
\mathbf{if}\;\varepsilon \leq -7.5 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 4.5 \cdot 10^{-44}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 4.8 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -7.5000000000000002e-7 or 4.8000000000000001e-5 < eps Initial program 52.6%
Taylor expanded in x around 0 53.5%
if -7.5000000000000002e-7 < eps < 4.4999999999999999e-44 or 2.45e-5 < eps < 4.8000000000000001e-5Initial program 24.0%
Taylor expanded in eps around 0 92.3%
associate-*r*92.3%
mul-1-neg92.3%
Simplified92.3%
if 4.4999999999999999e-44 < eps < 2.45e-5Initial program 3.6%
Taylor expanded in x around 0 3.6%
Taylor expanded in eps around 0 76.9%
*-commutative76.9%
unpow276.9%
associate-*l*76.9%
Simplified76.9%
Final simplification73.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* eps (* eps -0.5))))
(if (<= eps -1e-15)
t_0
(if (<= eps -3.6e-90)
t_1
(if (<= eps 1.55e-77) (* eps (- x)) (if (<= eps 0.00015) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = eps * (eps * -0.5);
double tmp;
if (eps <= -1e-15) {
tmp = t_0;
} else if (eps <= -3.6e-90) {
tmp = t_1;
} else if (eps <= 1.55e-77) {
tmp = eps * -x;
} else if (eps <= 0.00015) {
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 = cos(eps) + (-1.0d0)
t_1 = eps * (eps * (-0.5d0))
if (eps <= (-1d-15)) then
tmp = t_0
else if (eps <= (-3.6d-90)) then
tmp = t_1
else if (eps <= 1.55d-77) then
tmp = eps * -x
else if (eps <= 0.00015d0) 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 = Math.cos(eps) + -1.0;
double t_1 = eps * (eps * -0.5);
double tmp;
if (eps <= -1e-15) {
tmp = t_0;
} else if (eps <= -3.6e-90) {
tmp = t_1;
} else if (eps <= 1.55e-77) {
tmp = eps * -x;
} else if (eps <= 0.00015) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = eps * (eps * -0.5) tmp = 0 if eps <= -1e-15: tmp = t_0 elif eps <= -3.6e-90: tmp = t_1 elif eps <= 1.55e-77: tmp = eps * -x elif eps <= 0.00015: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(eps * Float64(eps * -0.5)) tmp = 0.0 if (eps <= -1e-15) tmp = t_0; elseif (eps <= -3.6e-90) tmp = t_1; elseif (eps <= 1.55e-77) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.00015) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) + -1.0; t_1 = eps * (eps * -0.5); tmp = 0.0; if (eps <= -1e-15) tmp = t_0; elseif (eps <= -3.6e-90) tmp = t_1; elseif (eps <= 1.55e-77) tmp = eps * -x; elseif (eps <= 0.00015) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -1e-15], t$95$0, If[LessEqual[eps, -3.6e-90], t$95$1, If[LessEqual[eps, 1.55e-77], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00015], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{if}\;\varepsilon \leq -1 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -3.6 \cdot 10^{-90}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 1.55 \cdot 10^{-77}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00015:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.0000000000000001e-15 or 1.49999999999999987e-4 < eps Initial program 51.9%
Taylor expanded in x around 0 52.6%
if -1.0000000000000001e-15 < eps < -3.59999999999999981e-90 or 1.55000000000000004e-77 < eps < 1.49999999999999987e-4Initial program 7.8%
Taylor expanded in x around 0 5.9%
Taylor expanded in eps around 0 43.4%
*-commutative43.4%
unpow243.4%
associate-*l*43.4%
Simplified43.4%
if -3.59999999999999981e-90 < eps < 1.55000000000000004e-77Initial program 28.0%
diff-cos31.1%
div-inv31.1%
metadata-eval31.1%
div-inv31.1%
+-commutative31.1%
metadata-eval31.1%
Applied egg-rr31.1%
*-commutative31.1%
+-commutative31.1%
associate--l+99.7%
+-inverses99.7%
distribute-lft-in99.7%
metadata-eval99.7%
*-commutative99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in eps around 0 96.8%
mul-1-neg96.8%
distribute-lft-neg-out96.8%
*-commutative96.8%
Simplified96.8%
Taylor expanded in x around 0 41.6%
associate-*r*41.6%
mul-1-neg41.6%
Simplified41.6%
Final simplification47.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -1e-80) (not (<= x 2.7e-120))) (* eps (- x)) (* eps (* eps -0.5))))
double code(double x, double eps) {
double tmp;
if ((x <= -1e-80) || !(x <= 2.7e-120)) {
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 <= (-1d-80)) .or. (.not. (x <= 2.7d-120))) 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 <= -1e-80) || !(x <= 2.7e-120)) {
tmp = eps * -x;
} else {
tmp = eps * (eps * -0.5);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1e-80) or not (x <= 2.7e-120): tmp = eps * -x else: tmp = eps * (eps * -0.5) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1e-80) || !(x <= 2.7e-120)) 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 <= -1e-80) || ~((x <= 2.7e-120))) tmp = eps * -x; else tmp = eps * (eps * -0.5); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1e-80], N[Not[LessEqual[x, 2.7e-120]], $MachinePrecision]], N[(eps * (-x)), $MachinePrecision], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-80} \lor \neg \left(x \leq 2.7 \cdot 10^{-120}\right):\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\end{array}
\end{array}
if x < -9.99999999999999961e-81 or 2.6999999999999999e-120 < x Initial program 18.9%
diff-cos19.7%
div-inv19.7%
metadata-eval19.7%
div-inv19.7%
+-commutative19.7%
metadata-eval19.7%
Applied egg-rr19.7%
*-commutative19.7%
+-commutative19.7%
associate--l+69.1%
+-inverses69.1%
distribute-lft-in69.1%
metadata-eval69.1%
*-commutative69.1%
+-commutative69.1%
Simplified69.1%
Taylor expanded in eps around 0 54.1%
mul-1-neg54.1%
distribute-lft-neg-out54.1%
*-commutative54.1%
Simplified54.1%
Taylor expanded in x around 0 13.6%
associate-*r*13.6%
mul-1-neg13.6%
Simplified13.6%
if -9.99999999999999961e-81 < x < 2.6999999999999999e-120Initial program 81.6%
Taylor expanded in x around 0 81.6%
Taylor expanded in eps around 0 48.2%
*-commutative48.2%
unpow248.2%
associate-*l*48.2%
Simplified48.2%
Final simplification23.8%
(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 37.3%
diff-cos43.1%
div-inv43.1%
metadata-eval43.1%
div-inv43.1%
+-commutative43.1%
metadata-eval43.1%
Applied egg-rr43.1%
*-commutative43.1%
+-commutative43.1%
associate--l+78.0%
+-inverses78.0%
distribute-lft-in78.0%
metadata-eval78.0%
*-commutative78.0%
+-commutative78.0%
Simplified78.0%
Taylor expanded in eps around 0 47.5%
mul-1-neg47.5%
distribute-lft-neg-out47.5%
*-commutative47.5%
Simplified47.5%
Taylor expanded in x around 0 18.9%
associate-*r*18.9%
mul-1-neg18.9%
Simplified18.9%
Final simplification18.9%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 37.3%
sub-neg37.3%
+-commutative37.3%
add-log-exp37.3%
add-log-exp37.3%
sum-log37.1%
Applied egg-rr37.1%
Taylor expanded in eps around 0 13.0%
exp-neg13.1%
lft-mult-inverse13.0%
metadata-eval13.0%
Simplified13.0%
Final simplification13.0%
herbie shell --seed 2023201
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))