
(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 14 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 (* (cos x) (cos eps))) (t_1 (* (sin eps) (sin x))))
(if (<= eps -0.005)
(- t_0 (+ (cos x) t_1))
(if (<= eps 0.0053)
(-
(*
(cos x)
(+ (* -0.5 (pow eps 2.0)) (* 0.041666666666666664 (pow eps 4.0))))
t_1)
(- (- t_0 t_1) (cos x))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(eps) * sin(x);
double tmp;
if (eps <= -0.005) {
tmp = t_0 - (cos(x) + t_1);
} else if (eps <= 0.0053) {
tmp = (cos(x) * ((-0.5 * pow(eps, 2.0)) + (0.041666666666666664 * pow(eps, 4.0)))) - t_1;
} else {
tmp = (t_0 - t_1) - cos(x);
}
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(eps) * sin(x)
if (eps <= (-0.005d0)) then
tmp = t_0 - (cos(x) + t_1)
else if (eps <= 0.0053d0) then
tmp = (cos(x) * (((-0.5d0) * (eps ** 2.0d0)) + (0.041666666666666664d0 * (eps ** 4.0d0)))) - t_1
else
tmp = (t_0 - t_1) - cos(x)
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(eps) * Math.sin(x);
double tmp;
if (eps <= -0.005) {
tmp = t_0 - (Math.cos(x) + t_1);
} else if (eps <= 0.0053) {
tmp = (Math.cos(x) * ((-0.5 * Math.pow(eps, 2.0)) + (0.041666666666666664 * Math.pow(eps, 4.0)))) - t_1;
} else {
tmp = (t_0 - t_1) - Math.cos(x);
}
return tmp;
}
def code(x, eps): t_0 = math.cos(x) * math.cos(eps) t_1 = math.sin(eps) * math.sin(x) tmp = 0 if eps <= -0.005: tmp = t_0 - (math.cos(x) + t_1) elif eps <= 0.0053: tmp = (math.cos(x) * ((-0.5 * math.pow(eps, 2.0)) + (0.041666666666666664 * math.pow(eps, 4.0)))) - t_1 else: tmp = (t_0 - t_1) - math.cos(x) return tmp
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) t_1 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -0.005) tmp = Float64(t_0 - Float64(cos(x) + t_1)); elseif (eps <= 0.0053) tmp = Float64(Float64(cos(x) * Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(0.041666666666666664 * (eps ^ 4.0)))) - t_1); else tmp = Float64(Float64(t_0 - t_1) - cos(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(x) * cos(eps); t_1 = sin(eps) * sin(x); tmp = 0.0; if (eps <= -0.005) tmp = t_0 - (cos(x) + t_1); elseif (eps <= 0.0053) tmp = (cos(x) * ((-0.5 * (eps ^ 2.0)) + (0.041666666666666664 * (eps ^ 4.0)))) - t_1; else tmp = (t_0 - t_1) - cos(x); 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[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.005], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0053], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
t_1 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.005:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0053:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2} + 0.041666666666666664 \cdot {\varepsilon}^{4}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\end{array}
\end{array}
if eps < -0.0050000000000000001Initial program 55.7%
cos-sum98.8%
cancel-sign-sub-inv98.8%
associate--l+98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-+r-98.8%
distribute-rgt-neg-out98.8%
sub-neg98.8%
associate--l-98.9%
*-commutative98.9%
add-sqr-sqrt46.5%
sqrt-unprod78.7%
sqr-neg78.7%
sqrt-unprod32.1%
add-sqr-sqrt56.1%
+-commutative56.1%
add-sqr-sqrt32.1%
sqrt-unprod78.7%
Applied egg-rr98.9%
if -0.0050000000000000001 < eps < 0.00530000000000000002Initial program 21.5%
sub-neg21.5%
cos-sum22.5%
cancel-sign-sub-inv22.5%
associate-+l+22.5%
*-commutative22.5%
Applied egg-rr22.5%
+-commutative22.5%
distribute-rgt-neg-out22.5%
*-commutative22.5%
unsub-neg22.5%
associate-+r-75.9%
*-commutative75.9%
neg-mul-175.9%
distribute-rgt-out75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in eps around 0 99.8%
if 0.00530000000000000002 < eps Initial program 44.3%
cos-sum98.8%
Applied egg-rr98.8%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (- (/ (* (pow (sin eps) 2.0) (- (cos x))) (+ (cos eps) 1.0)) (* (sin eps) (sin x))))
double code(double x, double eps) {
return ((pow(sin(eps), 2.0) * -cos(x)) / (cos(eps) + 1.0)) - (sin(eps) * sin(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((sin(eps) ** 2.0d0) * -cos(x)) / (cos(eps) + 1.0d0)) - (sin(eps) * sin(x))
end function
public static double code(double x, double eps) {
return ((Math.pow(Math.sin(eps), 2.0) * -Math.cos(x)) / (Math.cos(eps) + 1.0)) - (Math.sin(eps) * Math.sin(x));
}
def code(x, eps): return ((math.pow(math.sin(eps), 2.0) * -math.cos(x)) / (math.cos(eps) + 1.0)) - (math.sin(eps) * math.sin(x))
function code(x, eps) return Float64(Float64(Float64((sin(eps) ^ 2.0) * Float64(-cos(x))) / Float64(cos(eps) + 1.0)) - Float64(sin(eps) * sin(x))) end
function tmp = code(x, eps) tmp = (((sin(eps) ^ 2.0) * -cos(x)) / (cos(eps) + 1.0)) - (sin(eps) * sin(x)); end
code[x_, eps_] := N[(N[(N[(N[Power[N[Sin[eps], $MachinePrecision], 2.0], $MachinePrecision] * (-N[Cos[x], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\sin \varepsilon}^{2} \cdot \left(-\cos x\right)}{\cos \varepsilon + 1} - \sin \varepsilon \cdot \sin x
\end{array}
Initial program 37.1%
sub-neg37.1%
cos-sum63.6%
cancel-sign-sub-inv63.6%
associate-+l+63.6%
*-commutative63.6%
Applied egg-rr63.6%
+-commutative63.6%
distribute-rgt-neg-out63.6%
*-commutative63.6%
unsub-neg63.6%
associate-+r-88.2%
*-commutative88.2%
neg-mul-188.2%
distribute-rgt-out88.2%
*-commutative88.2%
Simplified88.2%
add-exp-log48.5%
*-commutative48.5%
Applied egg-rr48.5%
add-exp-log88.2%
flip-+87.9%
associate-*l/87.9%
metadata-eval87.9%
sub-1-cos99.1%
pow299.1%
sub-neg99.1%
metadata-eval99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (or (<= eps -0.00017) (not (<= eps 0.000155)))
(- (* (cos x) (cos eps)) (+ (cos x) t_0))
(- (* (cos x) (* -0.5 (pow eps 2.0))) t_0))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.000155)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + t_0);
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin(eps) * sin(x)
if ((eps <= (-0.00017d0)) .or. (.not. (eps <= 0.000155d0))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + t_0)
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) * Math.sin(x);
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.000155)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + t_0);
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) * math.sin(x) tmp = 0 if (eps <= -0.00017) or not (eps <= 0.000155): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + t_0) else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if ((eps <= -0.00017) || !(eps <= 0.000155)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + t_0)); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) * sin(x); tmp = 0.0; if ((eps <= -0.00017) || ~((eps <= 0.000155))) tmp = (cos(x) * cos(eps)) - (cos(x) + t_0); else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.00017], N[Not[LessEqual[eps, 0.000155]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.00017 \lor \neg \left(\varepsilon \leq 0.000155\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - t_0\\
\end{array}
\end{array}
if eps < -1.7e-4 or 1.55e-4 < eps Initial program 50.4%
cos-sum98.8%
cancel-sign-sub-inv98.8%
associate--l+98.8%
*-commutative98.8%
Applied egg-rr98.8%
associate-+r-98.8%
distribute-rgt-neg-out98.8%
sub-neg98.8%
associate--l-98.8%
*-commutative98.8%
add-sqr-sqrt42.9%
sqrt-unprod73.7%
sqr-neg73.7%
sqrt-unprod30.8%
add-sqr-sqrt51.0%
+-commutative51.0%
add-sqr-sqrt30.8%
sqrt-unprod73.7%
Applied egg-rr98.8%
if -1.7e-4 < eps < 1.55e-4Initial program 21.5%
sub-neg21.5%
cos-sum22.5%
cancel-sign-sub-inv22.5%
associate-+l+22.5%
*-commutative22.5%
Applied egg-rr22.5%
+-commutative22.5%
distribute-rgt-neg-out22.5%
*-commutative22.5%
unsub-neg22.5%
associate-+r-75.9%
*-commutative75.9%
neg-mul-175.9%
distribute-rgt-out75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in eps around 0 99.6%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin eps) (sin x))))
(if (<= eps -0.000155)
(- t_0 (+ (cos x) t_1))
(if (<= eps 0.000165)
(- (* (cos x) (* -0.5 (pow eps 2.0))) t_1)
(- (- t_0 t_1) (cos x))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(eps) * sin(x);
double tmp;
if (eps <= -0.000155) {
tmp = t_0 - (cos(x) + t_1);
} else if (eps <= 0.000165) {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - t_1;
} else {
tmp = (t_0 - t_1) - cos(x);
}
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(eps) * sin(x)
if (eps <= (-0.000155d0)) then
tmp = t_0 - (cos(x) + t_1)
else if (eps <= 0.000165d0) then
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - t_1
else
tmp = (t_0 - t_1) - cos(x)
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(eps) * Math.sin(x);
double tmp;
if (eps <= -0.000155) {
tmp = t_0 - (Math.cos(x) + t_1);
} else if (eps <= 0.000165) {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - t_1;
} else {
tmp = (t_0 - t_1) - Math.cos(x);
}
return tmp;
}
def code(x, eps): t_0 = math.cos(x) * math.cos(eps) t_1 = math.sin(eps) * math.sin(x) tmp = 0 if eps <= -0.000155: tmp = t_0 - (math.cos(x) + t_1) elif eps <= 0.000165: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - t_1 else: tmp = (t_0 - t_1) - math.cos(x) return tmp
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) t_1 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -0.000155) tmp = Float64(t_0 - Float64(cos(x) + t_1)); elseif (eps <= 0.000165) tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - t_1); else tmp = Float64(Float64(t_0 - t_1) - cos(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(x) * cos(eps); t_1 = sin(eps) * sin(x); tmp = 0.0; if (eps <= -0.000155) tmp = t_0 - (cos(x) + t_1); elseif (eps <= 0.000165) tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - t_1; else tmp = (t_0 - t_1) - cos(x); 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[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.000155], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.000165], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
t_1 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.000155:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\mathbf{elif}\;\varepsilon \leq 0.000165:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\end{array}
\end{array}
if eps < -1.55e-4Initial program 55.7%
cos-sum98.8%
cancel-sign-sub-inv98.8%
associate--l+98.9%
*-commutative98.9%
Applied egg-rr98.9%
associate-+r-98.8%
distribute-rgt-neg-out98.8%
sub-neg98.8%
associate--l-98.9%
*-commutative98.9%
add-sqr-sqrt46.5%
sqrt-unprod78.7%
sqr-neg78.7%
sqrt-unprod32.1%
add-sqr-sqrt56.1%
+-commutative56.1%
add-sqr-sqrt32.1%
sqrt-unprod78.7%
Applied egg-rr98.9%
if -1.55e-4 < eps < 1.65e-4Initial program 21.5%
sub-neg21.5%
cos-sum22.5%
cancel-sign-sub-inv22.5%
associate-+l+22.5%
*-commutative22.5%
Applied egg-rr22.5%
+-commutative22.5%
distribute-rgt-neg-out22.5%
*-commutative22.5%
unsub-neg22.5%
associate-+r-75.9%
*-commutative75.9%
neg-mul-175.9%
distribute-rgt-out75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in eps around 0 99.6%
if 1.65e-4 < eps Initial program 44.3%
cos-sum98.8%
Applied egg-rr98.8%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.000125) (not (<= eps 0.00015))) (fma (cos x) (+ (cos eps) -1.0) (* (sin eps) (- (sin x)))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* (sin eps) (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.000125) || !(eps <= 0.00015)) {
tmp = fma(cos(x), (cos(eps) + -1.0), (sin(eps) * -sin(x)));
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (sin(eps) * sin(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.000125) || !(eps <= 0.00015)) tmp = fma(cos(x), Float64(cos(eps) + -1.0), Float64(sin(eps) * Float64(-sin(x)))); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(sin(eps) * sin(x))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.000125], N[Not[LessEqual[eps, 0.00015]], $MachinePrecision]], N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.000125 \lor \neg \left(\varepsilon \leq 0.00015\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon + -1, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \sin \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -1.25e-4 or 1.49999999999999987e-4 < eps Initial program 50.4%
add-sqr-sqrt24.4%
sqrt-unprod32.0%
pow232.0%
Applied egg-rr32.0%
unpow232.0%
rem-sqrt-square32.0%
+-commutative32.0%
Simplified32.0%
sub-neg32.0%
+-commutative32.0%
+-commutative32.0%
rem-cube-cbrt31.9%
sqr-pow24.2%
fabs-sqr24.2%
sqr-pow50.4%
rem-cube-cbrt50.4%
+-commutative50.4%
cos-sum98.8%
cancel-sign-sub-inv98.8%
associate-+r+98.7%
neg-mul-198.7%
distribute-rgt-in98.8%
+-commutative98.8%
Applied egg-rr98.8%
distribute-lft-neg-in98.8%
fma-def98.8%
+-commutative98.8%
distribute-lft-neg-in98.8%
*-commutative98.8%
Simplified98.8%
if -1.25e-4 < eps < 1.49999999999999987e-4Initial program 21.5%
sub-neg21.5%
cos-sum22.5%
cancel-sign-sub-inv22.5%
associate-+l+22.5%
*-commutative22.5%
Applied egg-rr22.5%
+-commutative22.5%
distribute-rgt-neg-out22.5%
*-commutative22.5%
unsub-neg22.5%
associate-+r-75.9%
*-commutative75.9%
neg-mul-175.9%
distribute-rgt-out75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in eps around 0 99.6%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (or (<= eps -0.000125) (not (<= eps 0.00015)))
(- (* (cos x) (+ (cos eps) -1.0)) t_0)
(- (* (cos x) (* -0.5 (pow eps 2.0))) t_0))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if ((eps <= -0.000125) || !(eps <= 0.00015)) {
tmp = (cos(x) * (cos(eps) + -1.0)) - t_0;
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin(eps) * sin(x)
if ((eps <= (-0.000125d0)) .or. (.not. (eps <= 0.00015d0))) then
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - t_0
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) * Math.sin(x);
double tmp;
if ((eps <= -0.000125) || !(eps <= 0.00015)) {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - t_0;
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) * math.sin(x) tmp = 0 if (eps <= -0.000125) or not (eps <= 0.00015): tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - t_0 else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if ((eps <= -0.000125) || !(eps <= 0.00015)) tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - t_0); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) * sin(x); tmp = 0.0; if ((eps <= -0.000125) || ~((eps <= 0.00015))) tmp = (cos(x) * (cos(eps) + -1.0)) - t_0; else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.000125], N[Not[LessEqual[eps, 0.00015]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.000125 \lor \neg \left(\varepsilon \leq 0.00015\right):\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - t_0\\
\end{array}
\end{array}
if eps < -1.25e-4 or 1.49999999999999987e-4 < eps Initial program 50.4%
sub-neg50.4%
cos-sum98.8%
cancel-sign-sub-inv98.8%
associate-+l+98.8%
*-commutative98.8%
Applied egg-rr98.8%
+-commutative98.8%
distribute-rgt-neg-out98.8%
*-commutative98.8%
unsub-neg98.8%
associate-+r-98.7%
*-commutative98.7%
neg-mul-198.7%
distribute-rgt-out98.8%
*-commutative98.8%
Simplified98.8%
if -1.25e-4 < eps < 1.49999999999999987e-4Initial program 21.5%
sub-neg21.5%
cos-sum22.5%
cancel-sign-sub-inv22.5%
associate-+l+22.5%
*-commutative22.5%
Applied egg-rr22.5%
+-commutative22.5%
distribute-rgt-neg-out22.5%
*-commutative22.5%
unsub-neg22.5%
associate-+r-75.9%
*-commutative75.9%
neg-mul-175.9%
distribute-rgt-out75.9%
*-commutative75.9%
Simplified75.9%
Taylor expanded in eps around 0 99.6%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.4e-5) (not (<= eps 2.4e-5))) (- (* (cos x) (+ (cos eps) -1.0)) (* (sin eps) (sin x))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.4e-5) || !(eps <= 2.4e-5)) {
tmp = (cos(x) * (cos(eps) + -1.0)) - (sin(eps) * sin(x));
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (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 <= (-2.4d-5)) .or. (.not. (eps <= 2.4d-5))) then
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - (sin(eps) * sin(x))
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2.4e-5) || !(eps <= 2.4e-5)) {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - (Math.sin(eps) * Math.sin(x));
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.4e-5) or not (eps <= 2.4e-5): tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - (math.sin(eps) * math.sin(x)) else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.4e-5) || !(eps <= 2.4e-5)) tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - Float64(sin(eps) * sin(x))); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.4e-5) || ~((eps <= 2.4e-5))) tmp = (cos(x) * (cos(eps) + -1.0)) - (sin(eps) * sin(x)); else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.4e-5], N[Not[LessEqual[eps, 2.4e-5]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.4 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 2.4 \cdot 10^{-5}\right):\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -2.4000000000000001e-5 or 2.4000000000000001e-5 < eps Initial program 50.4%
sub-neg50.4%
cos-sum98.8%
cancel-sign-sub-inv98.8%
associate-+l+98.8%
*-commutative98.8%
Applied egg-rr98.8%
+-commutative98.8%
distribute-rgt-neg-out98.8%
*-commutative98.8%
unsub-neg98.8%
associate-+r-98.7%
*-commutative98.7%
neg-mul-198.7%
distribute-rgt-out98.8%
*-commutative98.8%
Simplified98.8%
if -2.4000000000000001e-5 < eps < 2.4000000000000001e-5Initial program 21.5%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (* (sin (* 0.5 (+ eps (* 2.0 x)))) (* -2.0 (sin (* eps 0.5)))))
double code(double x, double eps) {
return sin((0.5 * (eps + (2.0 * x)))) * (-2.0 * sin((eps * 0.5)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin((0.5d0 * (eps + (2.0d0 * x)))) * ((-2.0d0) * sin((eps * 0.5d0)))
end function
public static double code(double x, double eps) {
return Math.sin((0.5 * (eps + (2.0 * x)))) * (-2.0 * Math.sin((eps * 0.5)));
}
def code(x, eps): return math.sin((0.5 * (eps + (2.0 * x)))) * (-2.0 * math.sin((eps * 0.5)))
function code(x, eps) return Float64(sin(Float64(0.5 * Float64(eps + Float64(2.0 * x)))) * Float64(-2.0 * sin(Float64(eps * 0.5)))) end
function tmp = code(x, eps) tmp = sin((0.5 * (eps + (2.0 * x)))) * (-2.0 * sin((eps * 0.5))); end
code[x_, eps_] := N[(N[Sin[N[(0.5 * N[(eps + N[(2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(0.5 \cdot \left(\varepsilon + 2 \cdot x\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 37.1%
diff-cos47.7%
div-inv47.7%
+-commutative47.7%
associate--l+73.6%
*-un-lft-identity73.6%
*-un-lft-identity73.6%
distribute-rgt-out--73.6%
metadata-eval73.6%
metadata-eval73.6%
div-inv73.6%
+-commutative73.6%
associate-+l+73.6%
count-273.6%
*-commutative73.6%
metadata-eval73.6%
Applied egg-rr73.6%
associate-*r*73.6%
*-commutative73.6%
*-commutative73.6%
*-commutative73.6%
mul0-rgt73.6%
Simplified73.6%
Final simplification73.6%
(FPCore (x eps) :precision binary64 (if (<= eps -0.76) (- (cos eps) (cos x)) (if (<= eps 4.8e-6) (* (sin x) (- eps)) (+ (* (cos x) (cos eps)) -1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.76) {
tmp = cos(eps) - cos(x);
} else if (eps <= 4.8e-6) {
tmp = sin(x) * -eps;
} 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 <= (-0.76d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 4.8d-6) then
tmp = sin(x) * -eps
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 <= -0.76) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 4.8e-6) {
tmp = Math.sin(x) * -eps;
} else {
tmp = (Math.cos(x) * Math.cos(eps)) + -1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.76: tmp = math.cos(eps) - math.cos(x) elif eps <= 4.8e-6: tmp = math.sin(x) * -eps else: tmp = (math.cos(x) * math.cos(eps)) + -1.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.76) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 4.8e-6) tmp = Float64(sin(x) * Float64(-eps)); 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 <= -0.76) tmp = cos(eps) - cos(x); elseif (eps <= 4.8e-6) tmp = sin(x) * -eps; else tmp = (cos(x) * cos(eps)) + -1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.76], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.8e-6], N[(N[Sin[x], $MachinePrecision] * (-eps)), $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 -0.76:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon + -1\\
\end{array}
\end{array}
if eps < -0.76000000000000001Initial program 56.4%
Taylor expanded in x around 0 57.7%
if -0.76000000000000001 < eps < 4.7999999999999998e-6Initial program 21.1%
Taylor expanded in eps around 0 75.5%
associate-*r*75.5%
mul-1-neg75.5%
Simplified75.5%
if 4.7999999999999998e-6 < eps Initial program 44.3%
cos-sum98.1%
cancel-sign-sub-inv98.1%
associate--l+98.0%
*-commutative98.0%
Applied egg-rr98.0%
Taylor expanded in x around 0 47.6%
Final simplification63.3%
(FPCore (x eps) :precision binary64 (if (<= eps -0.76) (- (cos eps) (cos x)) (if (<= eps 1.7e-7) (* (sin x) (- eps)) (+ (cos eps) -1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.76) {
tmp = cos(eps) - cos(x);
} else if (eps <= 1.7e-7) {
tmp = sin(x) * -eps;
} 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 <= (-0.76d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 1.7d-7) then
tmp = sin(x) * -eps
else
tmp = cos(eps) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.76) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 1.7e-7) {
tmp = Math.sin(x) * -eps;
} else {
tmp = Math.cos(eps) + -1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.76: tmp = math.cos(eps) - math.cos(x) elif eps <= 1.7e-7: tmp = math.sin(x) * -eps else: tmp = math.cos(eps) + -1.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.76) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 1.7e-7) tmp = Float64(sin(x) * Float64(-eps)); else tmp = Float64(cos(eps) + -1.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.76) tmp = cos(eps) - cos(x); elseif (eps <= 1.7e-7) tmp = sin(x) * -eps; else tmp = cos(eps) + -1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.76], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.7e-7], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.76:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 1.7 \cdot 10^{-7}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \varepsilon + -1\\
\end{array}
\end{array}
if eps < -0.76000000000000001Initial program 56.4%
Taylor expanded in x around 0 57.7%
if -0.76000000000000001 < eps < 1.69999999999999987e-7Initial program 21.1%
Taylor expanded in eps around 0 75.5%
associate-*r*75.5%
mul-1-neg75.5%
Simplified75.5%
if 1.69999999999999987e-7 < eps Initial program 44.3%
Taylor expanded in x around 0 47.4%
Final simplification63.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.16e-6) (not (<= eps 3.15e-6))) (+ (cos eps) -1.0) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.16e-6) || !(eps <= 3.15e-6)) {
tmp = cos(eps) + -1.0;
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.16d-6)) .or. (.not. (eps <= 3.15d-6))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.16e-6) || !(eps <= 3.15e-6)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.16e-6) or not (eps <= 3.15e-6): tmp = math.cos(eps) + -1.0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.16e-6) || !(eps <= 3.15e-6)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.16e-6) || ~((eps <= 3.15e-6))) tmp = cos(eps) + -1.0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.16e-6], N[Not[LessEqual[eps, 3.15e-6]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.16 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 3.15 \cdot 10^{-6}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.1599999999999999e-6 or 3.14999999999999991e-6 < eps Initial program 50.4%
Taylor expanded in x around 0 51.8%
if -1.1599999999999999e-6 < eps < 3.14999999999999991e-6Initial program 21.3%
Taylor expanded in eps around 0 76.0%
associate-*r*76.0%
mul-1-neg76.0%
Simplified76.0%
Final simplification62.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.3e-73) (not (<= eps 1.05e-8))) (+ (cos eps) -1.0) (* x (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.3e-73) || !(eps <= 1.05e-8)) {
tmp = cos(eps) + -1.0;
} else {
tmp = x * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.3d-73)) .or. (.not. (eps <= 1.05d-8))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = x * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.3e-73) || !(eps <= 1.05e-8)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = x * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.3e-73) or not (eps <= 1.05e-8): tmp = math.cos(eps) + -1.0 else: tmp = x * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.3e-73) || !(eps <= 1.05e-8)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(x * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.3e-73) || ~((eps <= 1.05e-8))) tmp = cos(eps) + -1.0; else tmp = x * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.3e-73], N[Not[LessEqual[eps, 1.05e-8]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(x * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.3 \cdot 10^{-73} \lor \neg \left(\varepsilon \leq 1.05 \cdot 10^{-8}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.3e-73 or 1.04999999999999997e-8 < eps Initial program 45.0%
Taylor expanded in x around 0 46.3%
if -1.3e-73 < eps < 1.04999999999999997e-8Initial program 24.5%
sub-neg24.5%
cos-sum25.0%
cancel-sign-sub-inv25.0%
associate-+l+25.0%
*-commutative25.0%
Applied egg-rr25.0%
+-commutative25.0%
distribute-rgt-neg-out25.0%
*-commutative25.0%
unsub-neg25.0%
associate-+r-83.9%
*-commutative83.9%
neg-mul-183.9%
distribute-rgt-out83.9%
*-commutative83.9%
Simplified83.9%
Taylor expanded in eps around 0 83.9%
associate-*r*83.9%
mul-1-neg83.9%
*-commutative83.9%
Simplified83.9%
Taylor expanded in x around 0 37.0%
associate-*r*37.0%
mul-1-neg37.0%
Simplified37.0%
Final simplification42.7%
(FPCore (x eps) :precision binary64 (* x (- eps)))
double code(double x, double eps) {
return x * -eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = x * -eps
end function
public static double code(double x, double eps) {
return x * -eps;
}
def code(x, eps): return x * -eps
function code(x, eps) return Float64(x * Float64(-eps)) end
function tmp = code(x, eps) tmp = x * -eps; end
code[x_, eps_] := N[(x * (-eps)), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-\varepsilon\right)
\end{array}
Initial program 37.1%
sub-neg37.1%
cos-sum63.6%
cancel-sign-sub-inv63.6%
associate-+l+63.6%
*-commutative63.6%
Applied egg-rr63.6%
+-commutative63.6%
distribute-rgt-neg-out63.6%
*-commutative63.6%
unsub-neg63.6%
associate-+r-88.2%
*-commutative88.2%
neg-mul-188.2%
distribute-rgt-out88.2%
*-commutative88.2%
Simplified88.2%
Taylor expanded in eps around 0 36.6%
associate-*r*36.6%
mul-1-neg36.6%
*-commutative36.6%
Simplified36.6%
Taylor expanded in x around 0 16.0%
associate-*r*16.0%
mul-1-neg16.0%
Simplified16.0%
Final simplification16.0%
(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.1%
diff-cos47.7%
sin-mult36.7%
associate-*r/36.7%
Applied egg-rr36.9%
*-commutative36.9%
associate-/l*36.9%
associate--l+36.9%
mul0-rgt36.9%
mul0-rgt36.9%
metadata-eval36.9%
Simplified36.9%
sub-neg36.9%
Applied egg-rr11.4%
sub-neg11.4%
+-inverses11.4%
Simplified11.4%
Final simplification11.4%
herbie shell --seed 2023301
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))