
(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 19 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.0062)
(log (exp (- (* (cos x) (+ (cos eps) -1.0)) t_0)))
(if (<= eps 0.005)
(-
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps))))
t_0)
(fma (cos x) (cos eps) (- (fma (sin x) (sin eps) (cos x))))))))
double code(double x, double eps) {
double t_0 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.0062) {
tmp = log(exp(((cos(x) * (cos(eps) + -1.0)) - t_0)));
} else if (eps <= 0.005) {
tmp = (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_0;
} else {
tmp = fma(cos(x), cos(eps), -fma(sin(x), sin(eps), cos(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.0062) tmp = log(exp(Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - t_0))); elseif (eps <= 0.005) tmp = Float64(Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps)))) - t_0); else tmp = fma(cos(x), cos(eps), Float64(-fma(sin(x), sin(eps), 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.0062], N[Log[N[Exp[N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[eps, 0.005], N[(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] - t$95$0), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + (-N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0062:\\
\;\;\;\;\log \left(e^{\cos x \cdot \left(\cos \varepsilon + -1\right) - t_0}\right)\\
\mathbf{elif}\;\varepsilon \leq 0.005:\\
\;\;\;\;\cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, -\mathsf{fma}\left(\sin x, \sin \varepsilon, \cos x\right)\right)\\
\end{array}
\end{array}
if eps < -0.00619999999999999978Initial program 59.5%
cos-sum98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.4%
associate--r+98.2%
*-commutative98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
neg-mul-198.2%
distribute-rgt-out98.3%
Simplified98.3%
add-log-exp98.5%
Applied egg-rr98.5%
if -0.00619999999999999978 < eps < 0.0050000000000000001Initial program 24.7%
cos-sum27.1%
Applied egg-rr27.1%
Taylor expanded in x around inf 27.1%
associate--r+84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in x around inf 84.4%
sub-neg84.4%
neg-mul-184.4%
distribute-rgt-out84.4%
Simplified84.4%
Taylor expanded in eps around 0 99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
if 0.0050000000000000001 < eps Initial program 53.9%
cos-sum98.5%
associate--l-98.5%
fma-neg98.6%
fma-def98.7%
Applied egg-rr98.7%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (sin eps))))
(if (<= eps -0.0062)
(log (exp (- (* (cos x) (+ (cos eps) -1.0)) t_0)))
(if (<= eps 0.005)
(-
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps))))
t_0)
(fma (cos x) (cos eps) (- (- (cos x)) t_0))))))
double code(double x, double eps) {
double t_0 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.0062) {
tmp = log(exp(((cos(x) * (cos(eps) + -1.0)) - t_0)));
} else if (eps <= 0.005) {
tmp = (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_0;
} else {
tmp = fma(cos(x), cos(eps), (-cos(x) - t_0));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.0062) tmp = log(exp(Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - t_0))); elseif (eps <= 0.005) tmp = Float64(Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps)))) - t_0); else tmp = fma(cos(x), cos(eps), Float64(Float64(-cos(x)) - t_0)); 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.0062], N[Log[N[Exp[N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[eps, 0.005], N[(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] - t$95$0), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[((-N[Cos[x], $MachinePrecision]) - t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0062:\\
\;\;\;\;\log \left(e^{\cos x \cdot \left(\cos \varepsilon + -1\right) - t_0}\right)\\
\mathbf{elif}\;\varepsilon \leq 0.005:\\
\;\;\;\;\cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\cos x\right) - t_0\right)\\
\end{array}
\end{array}
if eps < -0.00619999999999999978Initial program 59.5%
cos-sum98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.4%
associate--r+98.2%
*-commutative98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
neg-mul-198.2%
distribute-rgt-out98.3%
Simplified98.3%
add-log-exp98.5%
Applied egg-rr98.5%
if -0.00619999999999999978 < eps < 0.0050000000000000001Initial program 24.7%
cos-sum27.1%
Applied egg-rr27.1%
Taylor expanded in x around inf 27.1%
associate--r+84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in x around inf 84.4%
sub-neg84.4%
neg-mul-184.4%
distribute-rgt-out84.4%
Simplified84.4%
Taylor expanded in eps around 0 99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
if 0.0050000000000000001 < eps Initial program 53.9%
sub-neg53.9%
cos-sum98.5%
associate-+l-98.5%
fma-neg98.6%
Applied egg-rr98.6%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* (sin x) (sin eps))))
(if (<= eps -0.0062)
(log (exp (- (* (cos x) t_0) t_1)))
(if (<= eps 0.005)
(-
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps))))
t_1)
(fma t_0 (cos x) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.0062) {
tmp = log(exp(((cos(x) * t_0) - t_1)));
} else if (eps <= 0.005) {
tmp = (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_1;
} else {
tmp = fma(t_0, cos(x), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.0062) tmp = log(exp(Float64(Float64(cos(x) * t_0) - t_1))); elseif (eps <= 0.005) tmp = Float64(Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps)))) - t_1); else tmp = fma(t_0, cos(x), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0062], N[Log[N[Exp[N[(N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[eps, 0.005], N[(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] - t$95$1), $MachinePrecision], N[(t$95$0 * N[Cos[x], $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0062:\\
\;\;\;\;\log \left(e^{\cos x \cdot t_0 - t_1}\right)\\
\mathbf{elif}\;\varepsilon \leq 0.005:\\
\;\;\;\;\cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \cos x, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -0.00619999999999999978Initial program 59.5%
cos-sum98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.4%
associate--r+98.2%
*-commutative98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
neg-mul-198.2%
distribute-rgt-out98.3%
Simplified98.3%
add-log-exp98.5%
Applied egg-rr98.5%
if -0.00619999999999999978 < eps < 0.0050000000000000001Initial program 24.7%
cos-sum27.1%
Applied egg-rr27.1%
Taylor expanded in x around inf 27.1%
associate--r+84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in x around inf 84.4%
sub-neg84.4%
neg-mul-184.4%
distribute-rgt-out84.4%
Simplified84.4%
Taylor expanded in eps around 0 99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
if 0.0050000000000000001 < eps Initial program 53.9%
cos-sum98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 98.5%
associate--r+98.5%
*-commutative98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
sub-neg98.5%
neg-mul-198.5%
distribute-rgt-out98.5%
Simplified98.5%
*-commutative98.5%
fma-neg98.5%
Applied egg-rr98.5%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* (sin x) (sin eps))))
(if (<= eps -0.0055)
(- (* (cos x) t_0) t_1)
(if (<= eps 0.005)
(-
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps))))
t_1)
(fma t_0 (cos x) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.0055) {
tmp = (cos(x) * t_0) - t_1;
} else if (eps <= 0.005) {
tmp = (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_1;
} else {
tmp = fma(t_0, cos(x), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.0055) tmp = Float64(Float64(cos(x) * t_0) - t_1); elseif (eps <= 0.005) tmp = Float64(Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps)))) - t_1); else tmp = fma(t_0, cos(x), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0055], N[(N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[eps, 0.005], N[(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] - t$95$1), $MachinePrecision], N[(t$95$0 * N[Cos[x], $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0055:\\
\;\;\;\;\cos x \cdot t_0 - t_1\\
\mathbf{elif}\;\varepsilon \leq 0.005:\\
\;\;\;\;\cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, \cos x, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -0.0054999999999999997Initial program 58.5%
cos-sum98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.3%
associate--r+98.2%
*-commutative98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
neg-mul-198.2%
distribute-rgt-out98.3%
Simplified98.3%
if -0.0054999999999999997 < eps < 0.0050000000000000001Initial program 24.8%
cos-sum26.6%
Applied egg-rr26.6%
Taylor expanded in x around inf 26.6%
associate--r+84.3%
*-commutative84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in x around inf 84.3%
sub-neg84.3%
neg-mul-184.3%
distribute-rgt-out84.3%
Simplified84.3%
Taylor expanded in eps around 0 99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
if 0.0050000000000000001 < eps Initial program 53.9%
cos-sum98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 98.5%
associate--r+98.5%
*-commutative98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
sub-neg98.5%
neg-mul-198.5%
distribute-rgt-out98.5%
Simplified98.5%
*-commutative98.5%
fma-neg98.5%
Applied egg-rr98.5%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (sin eps))))
(if (<= eps -0.0062)
(- (* (cos x) (cos eps)) (+ (cos x) t_0))
(if (<= eps 0.005)
(-
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps))))
t_0)
(fma (+ (cos eps) -1.0) (cos x) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.0062) {
tmp = (cos(x) * cos(eps)) - (cos(x) + t_0);
} else if (eps <= 0.005) {
tmp = (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_0;
} else {
tmp = fma((cos(eps) + -1.0), cos(x), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.0062) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + t_0)); elseif (eps <= 0.005) tmp = Float64(Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps)))) - t_0); else tmp = fma(Float64(cos(eps) + -1.0), cos(x), Float64(sin(eps) * Float64(-sin(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.0062], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.005], N[(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] - t$95$0), $MachinePrecision], N[(N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] * N[Cos[x], $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0062:\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + t_0\right)\\
\mathbf{elif}\;\varepsilon \leq 0.005:\\
\;\;\;\;\cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \varepsilon + -1, \cos x, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -0.00619999999999999978Initial program 59.5%
cos-sum98.3%
Applied egg-rr98.3%
Taylor expanded in x around inf 98.4%
if -0.00619999999999999978 < eps < 0.0050000000000000001Initial program 24.7%
cos-sum27.1%
Applied egg-rr27.1%
Taylor expanded in x around inf 27.1%
associate--r+84.4%
*-commutative84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in x around inf 84.4%
sub-neg84.4%
neg-mul-184.4%
distribute-rgt-out84.4%
Simplified84.4%
Taylor expanded in eps around 0 99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
if 0.0050000000000000001 < eps Initial program 53.9%
cos-sum98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 98.5%
associate--r+98.5%
*-commutative98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
sub-neg98.5%
neg-mul-198.5%
distribute-rgt-out98.5%
Simplified98.5%
*-commutative98.5%
fma-neg98.5%
Applied egg-rr98.5%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (sin eps))))
(if (or (<= eps -0.0055) (not (<= eps 0.005)))
(- (* (cos x) (+ (cos eps) -1.0)) t_0)
(-
(*
(cos x)
(+ (* 0.041666666666666664 (pow eps 4.0)) (* -0.5 (* eps eps))))
t_0))))
double code(double x, double eps) {
double t_0 = sin(x) * sin(eps);
double tmp;
if ((eps <= -0.0055) || !(eps <= 0.005)) {
tmp = (cos(x) * (cos(eps) + -1.0)) - t_0;
} else {
tmp = (cos(x) * ((0.041666666666666664 * pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - 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(x) * sin(eps)
if ((eps <= (-0.0055d0)) .or. (.not. (eps <= 0.005d0))) then
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - t_0
else
tmp = (cos(x) * ((0.041666666666666664d0 * (eps ** 4.0d0)) + ((-0.5d0) * (eps * eps)))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) * Math.sin(eps);
double tmp;
if ((eps <= -0.0055) || !(eps <= 0.005)) {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - t_0;
} else {
tmp = (Math.cos(x) * ((0.041666666666666664 * Math.pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) * math.sin(eps) tmp = 0 if (eps <= -0.0055) or not (eps <= 0.005): tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - t_0 else: tmp = (math.cos(x) * ((0.041666666666666664 * math.pow(eps, 4.0)) + (-0.5 * (eps * eps)))) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(x) * sin(eps)) tmp = 0.0 if ((eps <= -0.0055) || !(eps <= 0.005)) tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - t_0); else tmp = Float64(Float64(cos(x) * Float64(Float64(0.041666666666666664 * (eps ^ 4.0)) + Float64(-0.5 * Float64(eps * eps)))) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) * sin(eps); tmp = 0.0; if ((eps <= -0.0055) || ~((eps <= 0.005))) tmp = (cos(x) * (cos(eps) + -1.0)) - t_0; else tmp = (cos(x) * ((0.041666666666666664 * (eps ^ 4.0)) + (-0.5 * (eps * eps)))) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.0055], N[Not[LessEqual[eps, 0.005]], $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[(N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0055 \lor \neg \left(\varepsilon \leq 0.005\right):\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(0.041666666666666664 \cdot {\varepsilon}^{4} + -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_0\\
\end{array}
\end{array}
if eps < -0.0054999999999999997 or 0.0050000000000000001 < eps Initial program 56.0%
cos-sum98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
associate--r+98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around inf 98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-rgt-out98.4%
Simplified98.4%
if -0.0054999999999999997 < eps < 0.0050000000000000001Initial program 24.8%
cos-sum26.6%
Applied egg-rr26.6%
Taylor expanded in x around inf 26.6%
associate--r+84.3%
*-commutative84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in x around inf 84.3%
sub-neg84.3%
neg-mul-184.3%
distribute-rgt-out84.3%
Simplified84.3%
Taylor expanded in eps around 0 99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -0.0002) (* (sin eps) (- (tan (/ eps 2.0)))) (- (* -0.5 (* eps (* eps (cos x)))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -0.0002) {
tmp = sin(eps) * -tan((eps / 2.0));
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((eps + x)) - cos(x)) <= (-0.0002d0)) then
tmp = sin(eps) * -tan((eps / 2.0d0))
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -0.0002) {
tmp = Math.sin(eps) * -Math.tan((eps / 2.0));
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -0.0002: tmp = math.sin(eps) * -math.tan((eps / 2.0)) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -0.0002) tmp = Float64(sin(eps) * Float64(-tan(Float64(eps / 2.0)))); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -0.0002) tmp = sin(eps) * -tan((eps / 2.0)); else tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -0.0002], N[(N[Sin[eps], $MachinePrecision] * (-N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -0.0002:\\
\;\;\;\;\sin \varepsilon \cdot \left(-\tan \left(\frac{\varepsilon}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -2.0000000000000001e-4Initial program 85.1%
Taylor expanded in x around 0 85.1%
flip--84.4%
metadata-eval84.4%
Applied egg-rr84.4%
sub-1-cos85.1%
unpow285.1%
+-commutative85.1%
Simplified85.1%
Taylor expanded in eps around inf 85.1%
mul-1-neg85.1%
+-commutative85.1%
unpow285.1%
associate-*r/85.2%
distribute-lft-neg-in85.2%
+-commutative85.2%
hang-0p-tan86.2%
Simplified86.2%
if -2.0000000000000001e-4 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.0%
Taylor expanded in eps around 0 75.3%
+-commutative75.3%
mul-1-neg75.3%
unsub-neg75.3%
unpow275.3%
associate-*l*75.3%
Simplified75.3%
Final simplification78.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (sin eps))))
(if (or (<= eps -0.00016) (not (<= eps 0.00015)))
(- (* (cos x) (+ (cos eps) -1.0)) t_0)
(- (* (cos x) (* eps (* eps -0.5))) t_0))))
double code(double x, double eps) {
double t_0 = sin(x) * sin(eps);
double tmp;
if ((eps <= -0.00016) || !(eps <= 0.00015)) {
tmp = (cos(x) * (cos(eps) + -1.0)) - t_0;
} else {
tmp = (cos(x) * (eps * (eps * -0.5))) - 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(x) * sin(eps)
if ((eps <= (-0.00016d0)) .or. (.not. (eps <= 0.00015d0))) then
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - t_0
else
tmp = (cos(x) * (eps * (eps * (-0.5d0)))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) * Math.sin(eps);
double tmp;
if ((eps <= -0.00016) || !(eps <= 0.00015)) {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - t_0;
} else {
tmp = (Math.cos(x) * (eps * (eps * -0.5))) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) * math.sin(eps) tmp = 0 if (eps <= -0.00016) or not (eps <= 0.00015): tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - t_0 else: tmp = (math.cos(x) * (eps * (eps * -0.5))) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(x) * sin(eps)) tmp = 0.0 if ((eps <= -0.00016) || !(eps <= 0.00015)) tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - t_0); else tmp = Float64(Float64(cos(x) * Float64(eps * Float64(eps * -0.5))) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) * sin(eps); tmp = 0.0; if ((eps <= -0.00016) || ~((eps <= 0.00015))) tmp = (cos(x) * (cos(eps) + -1.0)) - t_0; else tmp = (cos(x) * (eps * (eps * -0.5))) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.00016], 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[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.00016 \lor \neg \left(\varepsilon \leq 0.00015\right):\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\right) - t_0\\
\end{array}
\end{array}
if eps < -1.60000000000000013e-4 or 1.49999999999999987e-4 < eps Initial program 56.0%
cos-sum98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
associate--r+98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around inf 98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-rgt-out98.4%
Simplified98.4%
if -1.60000000000000013e-4 < eps < 1.49999999999999987e-4Initial program 24.8%
cos-sum26.6%
Applied egg-rr26.6%
Taylor expanded in x around inf 26.6%
associate--r+84.3%
*-commutative84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in eps around 0 99.7%
associate-*r*99.7%
*-commutative99.7%
unpow299.7%
associate-*r*99.7%
Simplified99.7%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -0.0002) (+ -1.0 (* (cos x) (cos eps))) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -0.0002) {
tmp = -1.0 + (cos(x) * cos(eps));
} 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 ((cos((eps + x)) - cos(x)) <= (-0.0002d0)) then
tmp = (-1.0d0) + (cos(x) * cos(eps))
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -0.0002) {
tmp = -1.0 + (Math.cos(x) * Math.cos(eps));
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -0.0002: tmp = -1.0 + (math.cos(x) * math.cos(eps)) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -0.0002) tmp = Float64(-1.0 + Float64(cos(x) * cos(eps))); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -0.0002) tmp = -1.0 + (cos(x) * cos(eps)); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -0.0002], N[(-1.0 + N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -0.0002:\\
\;\;\;\;-1 + \cos x \cdot \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -2.0000000000000001e-4Initial program 85.1%
cos-sum98.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 98.4%
Taylor expanded in x around 0 85.3%
if -2.0000000000000001e-4 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.0%
Taylor expanded in eps around 0 63.6%
mul-1-neg63.6%
*-commutative63.6%
distribute-rgt-neg-in63.6%
Simplified63.6%
Final simplification70.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -0.0002) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -0.0002) {
tmp = cos(eps) - cos(x);
} else {
tmp = 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 ((cos((eps + x)) - cos(x)) <= (-0.0002d0)) then
tmp = cos(eps) - cos(x)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -0.0002) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -0.0002: tmp = math.cos(eps) - math.cos(x) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -0.0002) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -0.0002) tmp = cos(eps) - cos(x); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -0.0002], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -0.0002:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -2.0000000000000001e-4Initial program 85.1%
Taylor expanded in x around 0 85.2%
if -2.0000000000000001e-4 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.0%
Taylor expanded in eps around 0 63.6%
mul-1-neg63.6%
*-commutative63.6%
distribute-rgt-neg-in63.6%
Simplified63.6%
Final simplification70.2%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* eps 0.5)) (sin (* 0.5 (- eps (* x -2.0)))))))
double code(double x, double eps) {
return -2.0 * (sin((eps * 0.5)) * sin((0.5 * (eps - (x * -2.0)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((eps * 0.5d0)) * sin((0.5d0 * (eps - (x * (-2.0d0))))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((eps * 0.5)) * Math.sin((0.5 * (eps - (x * -2.0)))));
}
def code(x, eps): return -2.0 * (math.sin((eps * 0.5)) * math.sin((0.5 * (eps - (x * -2.0)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * sin(Float64(0.5 * Float64(eps - Float64(x * -2.0)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((eps * 0.5)) * sin((0.5 * (eps - (x * -2.0))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps - N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon - x \cdot -2\right)\right)\right)
\end{array}
Initial program 39.8%
diff-cos47.9%
div-inv47.9%
metadata-eval47.9%
div-inv47.9%
+-commutative47.9%
metadata-eval47.9%
Applied egg-rr47.9%
*-commutative47.9%
+-commutative47.9%
associate--l+79.0%
+-inverses79.0%
distribute-lft-in79.0%
metadata-eval79.0%
*-commutative79.0%
associate-+r+78.9%
+-commutative78.9%
Simplified78.9%
Taylor expanded in x around -inf 78.9%
Final simplification78.9%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.8e-61) (not (<= x 2.1e-49))) (* -2.0 (* (sin x) (sin (* eps 0.5)))) (* (sin eps) (- (tan (/ eps 2.0))))))
double code(double x, double eps) {
double tmp;
if ((x <= -3.8e-61) || !(x <= 2.1e-49)) {
tmp = -2.0 * (sin(x) * sin((eps * 0.5)));
} else {
tmp = sin(eps) * -tan((eps / 2.0));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-3.8d-61)) .or. (.not. (x <= 2.1d-49))) then
tmp = (-2.0d0) * (sin(x) * sin((eps * 0.5d0)))
else
tmp = sin(eps) * -tan((eps / 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -3.8e-61) || !(x <= 2.1e-49)) {
tmp = -2.0 * (Math.sin(x) * Math.sin((eps * 0.5)));
} else {
tmp = Math.sin(eps) * -Math.tan((eps / 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -3.8e-61) or not (x <= 2.1e-49): tmp = -2.0 * (math.sin(x) * math.sin((eps * 0.5))) else: tmp = math.sin(eps) * -math.tan((eps / 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -3.8e-61) || !(x <= 2.1e-49)) tmp = Float64(-2.0 * Float64(sin(x) * sin(Float64(eps * 0.5)))); else tmp = Float64(sin(eps) * Float64(-tan(Float64(eps / 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -3.8e-61) || ~((x <= 2.1e-49))) tmp = -2.0 * (sin(x) * sin((eps * 0.5))); else tmp = sin(eps) * -tan((eps / 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -3.8e-61], N[Not[LessEqual[x, 2.1e-49]], $MachinePrecision]], N[(-2.0 * N[(N[Sin[x], $MachinePrecision] * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * (-N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-61} \lor \neg \left(x \leq 2.1 \cdot 10^{-49}\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \varepsilon \cdot \left(-\tan \left(\frac{\varepsilon}{2}\right)\right)\\
\end{array}
\end{array}
if x < -3.7999999999999998e-61 or 2.0999999999999999e-49 < x Initial program 11.1%
diff-cos11.3%
div-inv11.3%
metadata-eval11.3%
div-inv11.3%
+-commutative11.3%
metadata-eval11.3%
Applied egg-rr11.3%
*-commutative11.3%
+-commutative11.3%
associate--l+63.8%
+-inverses63.8%
distribute-lft-in63.8%
metadata-eval63.8%
*-commutative63.8%
associate-+r+63.7%
+-commutative63.7%
Simplified63.7%
Taylor expanded in x around -inf 63.7%
Taylor expanded in eps around 0 60.8%
if -3.7999999999999998e-61 < x < 2.0999999999999999e-49Initial program 78.6%
Taylor expanded in x around 0 78.6%
flip--78.1%
metadata-eval78.1%
Applied egg-rr78.1%
sub-1-cos96.3%
unpow296.3%
+-commutative96.3%
Simplified96.3%
Taylor expanded in eps around inf 96.3%
mul-1-neg96.3%
+-commutative96.3%
unpow296.3%
associate-*r/96.3%
distribute-lft-neg-in96.3%
+-commutative96.3%
hang-0p-tan97.0%
Simplified97.0%
Final simplification76.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.6e-62) (not (<= x 2.1e-49))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -6.6e-62) || !(x <= 2.1e-49)) {
tmp = eps * -sin(x);
} else {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-6.6d-62)) .or. (.not. (x <= 2.1d-49))) then
tmp = eps * -sin(x)
else
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6.6e-62) || !(x <= 2.1e-49)) {
tmp = eps * -Math.sin(x);
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6.6e-62) or not (x <= 2.1e-49): tmp = eps * -math.sin(x) else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6.6e-62) || !(x <= 2.1e-49)) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6.6e-62) || ~((x <= 2.1e-49))) tmp = eps * -sin(x); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.6e-62], N[Not[LessEqual[x, 2.1e-49]], $MachinePrecision]], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{-62} \lor \neg \left(x \leq 2.1 \cdot 10^{-49}\right):\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if x < -6.60000000000000009e-62 or 2.0999999999999999e-49 < x Initial program 11.1%
Taylor expanded in eps around 0 58.8%
mul-1-neg58.8%
*-commutative58.8%
distribute-rgt-neg-in58.8%
Simplified58.8%
if -6.60000000000000009e-62 < x < 2.0999999999999999e-49Initial program 78.6%
diff-cos97.3%
div-inv97.3%
metadata-eval97.3%
div-inv97.3%
+-commutative97.3%
metadata-eval97.3%
Applied egg-rr97.3%
*-commutative97.3%
+-commutative97.3%
associate--l+99.4%
+-inverses99.4%
distribute-lft-in99.4%
metadata-eval99.4%
*-commutative99.4%
associate-+r+99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 96.8%
Final simplification75.0%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.15e-60) (not (<= x 9.5e-50))) (* eps (- (sin x))) (* (sin eps) (- (tan (/ eps 2.0))))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.15e-60) || !(x <= 9.5e-50)) {
tmp = eps * -sin(x);
} else {
tmp = sin(eps) * -tan((eps / 2.0));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-2.15d-60)) .or. (.not. (x <= 9.5d-50))) then
tmp = eps * -sin(x)
else
tmp = sin(eps) * -tan((eps / 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -2.15e-60) || !(x <= 9.5e-50)) {
tmp = eps * -Math.sin(x);
} else {
tmp = Math.sin(eps) * -Math.tan((eps / 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2.15e-60) or not (x <= 9.5e-50): tmp = eps * -math.sin(x) else: tmp = math.sin(eps) * -math.tan((eps / 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2.15e-60) || !(x <= 9.5e-50)) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(sin(eps) * Float64(-tan(Float64(eps / 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -2.15e-60) || ~((x <= 9.5e-50))) tmp = eps * -sin(x); else tmp = sin(eps) * -tan((eps / 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.15e-60], N[Not[LessEqual[x, 9.5e-50]], $MachinePrecision]], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(N[Sin[eps], $MachinePrecision] * (-N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{-60} \lor \neg \left(x \leq 9.5 \cdot 10^{-50}\right):\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \varepsilon \cdot \left(-\tan \left(\frac{\varepsilon}{2}\right)\right)\\
\end{array}
\end{array}
if x < -2.15e-60 or 9.4999999999999993e-50 < x Initial program 11.1%
Taylor expanded in eps around 0 58.8%
mul-1-neg58.8%
*-commutative58.8%
distribute-rgt-neg-in58.8%
Simplified58.8%
if -2.15e-60 < x < 9.4999999999999993e-50Initial program 78.6%
Taylor expanded in x around 0 78.6%
flip--78.1%
metadata-eval78.1%
Applied egg-rr78.1%
sub-1-cos96.3%
unpow296.3%
+-commutative96.3%
Simplified96.3%
Taylor expanded in eps around inf 96.3%
mul-1-neg96.3%
+-commutative96.3%
unpow296.3%
associate-*r/96.3%
distribute-lft-neg-in96.3%
+-commutative96.3%
hang-0p-tan97.0%
Simplified97.0%
Final simplification75.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.0062) (not (<= eps 7e-5))) (+ (cos eps) -1.0) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0062) || !(eps <= 7e-5)) {
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 <= (-0.0062d0)) .or. (.not. (eps <= 7d-5))) 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 <= -0.0062) || !(eps <= 7e-5)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0062) or not (eps <= 7e-5): tmp = math.cos(eps) + -1.0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0062) || !(eps <= 7e-5)) 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 <= -0.0062) || ~((eps <= 7e-5))) tmp = cos(eps) + -1.0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0062], N[Not[LessEqual[eps, 7e-5]], $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 -0.0062 \lor \neg \left(\varepsilon \leq 7 \cdot 10^{-5}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.00619999999999999978 or 6.9999999999999994e-5 < eps Initial program 56.5%
Taylor expanded in x around 0 58.0%
if -0.00619999999999999978 < eps < 6.9999999999999994e-5Initial program 24.7%
Taylor expanded in eps around 0 83.4%
mul-1-neg83.4%
*-commutative83.4%
distribute-rgt-neg-in83.4%
Simplified83.4%
Final simplification71.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -5.8e-5) (not (<= eps 4.2e-7))) (+ (cos eps) -1.0) (- (* -0.5 (* eps eps)) (* eps x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -5.8e-5) || !(eps <= 4.2e-7)) {
tmp = cos(eps) + -1.0;
} else {
tmp = (-0.5 * (eps * eps)) - (eps * x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-5.8d-5)) .or. (.not. (eps <= 4.2d-7))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = ((-0.5d0) * (eps * eps)) - (eps * x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -5.8e-5) || !(eps <= 4.2e-7)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = (-0.5 * (eps * eps)) - (eps * x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -5.8e-5) or not (eps <= 4.2e-7): tmp = math.cos(eps) + -1.0 else: tmp = (-0.5 * (eps * eps)) - (eps * x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -5.8e-5) || !(eps <= 4.2e-7)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(Float64(-0.5 * Float64(eps * eps)) - Float64(eps * x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -5.8e-5) || ~((eps <= 4.2e-7))) tmp = cos(eps) + -1.0; else tmp = (-0.5 * (eps * eps)) - (eps * x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -5.8e-5], N[Not[LessEqual[eps, 4.2e-7]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] - N[(eps * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -5.8 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 4.2 \cdot 10^{-7}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right) - \varepsilon \cdot x\\
\end{array}
\end{array}
if eps < -5.8e-5 or 4.2e-7 < eps Initial program 54.8%
Taylor expanded in x around 0 56.5%
if -5.8e-5 < eps < 4.2e-7Initial program 25.3%
Taylor expanded in eps around 0 25.5%
+-commutative25.5%
associate-+r+25.5%
mul-1-neg25.5%
unsub-neg25.5%
associate-*r*25.5%
distribute-rgt1-in25.5%
distribute-lft1-in25.5%
*-lft-identity25.5%
distribute-rgt-out25.5%
unpow225.5%
Simplified25.5%
Taylor expanded in x around 0 47.8%
+-commutative47.8%
mul-1-neg47.8%
unsub-neg47.8%
*-commutative47.8%
unpow247.8%
*-commutative47.8%
Simplified47.8%
Final simplification52.1%
(FPCore (x eps) :precision binary64 (if (<= x -360.0) (- 1.0 (cos eps)) (- (* -0.5 (* eps eps)) (* eps x))))
double code(double x, double eps) {
double tmp;
if (x <= -360.0) {
tmp = 1.0 - cos(eps);
} else {
tmp = (-0.5 * (eps * eps)) - (eps * x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-360.0d0)) then
tmp = 1.0d0 - cos(eps)
else
tmp = ((-0.5d0) * (eps * eps)) - (eps * x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -360.0) {
tmp = 1.0 - Math.cos(eps);
} else {
tmp = (-0.5 * (eps * eps)) - (eps * x);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -360.0: tmp = 1.0 - math.cos(eps) else: tmp = (-0.5 * (eps * eps)) - (eps * x) return tmp
function code(x, eps) tmp = 0.0 if (x <= -360.0) tmp = Float64(1.0 - cos(eps)); else tmp = Float64(Float64(-0.5 * Float64(eps * eps)) - Float64(eps * x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -360.0) tmp = 1.0 - cos(eps); else tmp = (-0.5 * (eps * eps)) - (eps * x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -360.0], N[(1.0 - N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] - N[(eps * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -360:\\
\;\;\;\;1 - \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right) - \varepsilon \cdot x\\
\end{array}
\end{array}
if x < -360Initial program 6.1%
Taylor expanded in x around 0 7.0%
flip--7.0%
metadata-eval7.0%
Applied egg-rr7.0%
sub-1-cos7.1%
unpow27.1%
+-commutative7.1%
Simplified7.1%
add-sqr-sqrt2.1%
sqrt-unprod9.4%
sqr-neg9.4%
sqrt-unprod9.5%
add-sqr-sqrt9.5%
unpow29.5%
1-sub-cos9.2%
metadata-eval9.2%
flip--9.2%
sub-neg9.2%
Applied egg-rr9.2%
sub-neg9.2%
Simplified9.2%
if -360 < x Initial program 51.1%
Taylor expanded in eps around 0 18.9%
+-commutative18.9%
associate-+r+18.9%
mul-1-neg18.9%
unsub-neg18.9%
associate-*r*18.9%
distribute-rgt1-in18.9%
distribute-lft1-in18.9%
*-lft-identity18.9%
distribute-rgt-out18.9%
unpow218.9%
Simplified18.9%
Taylor expanded in x around 0 33.8%
+-commutative33.8%
mul-1-neg33.8%
unsub-neg33.8%
*-commutative33.8%
unpow233.8%
*-commutative33.8%
Simplified33.8%
Final simplification27.6%
(FPCore (x eps) :precision binary64 (- (* -0.5 (* eps eps)) (* eps x)))
double code(double x, double eps) {
return (-0.5 * (eps * eps)) - (eps * x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((-0.5d0) * (eps * eps)) - (eps * x)
end function
public static double code(double x, double eps) {
return (-0.5 * (eps * eps)) - (eps * x);
}
def code(x, eps): return (-0.5 * (eps * eps)) - (eps * x)
function code(x, eps) return Float64(Float64(-0.5 * Float64(eps * eps)) - Float64(eps * x)) end
function tmp = code(x, eps) tmp = (-0.5 * (eps * eps)) - (eps * x); end
code[x_, eps_] := N[(N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] - N[(eps * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right) - \varepsilon \cdot x
\end{array}
Initial program 39.8%
Taylor expanded in eps around 0 15.9%
+-commutative15.9%
associate-+r+15.9%
mul-1-neg15.9%
unsub-neg15.9%
associate-*r*15.9%
distribute-rgt1-in15.9%
distribute-lft1-in15.9%
*-lft-identity15.9%
distribute-rgt-out15.9%
unpow215.9%
Simplified15.9%
Taylor expanded in x around 0 26.0%
+-commutative26.0%
mul-1-neg26.0%
unsub-neg26.0%
*-commutative26.0%
unpow226.0%
*-commutative26.0%
Simplified26.0%
Final simplification26.0%
(FPCore (x eps) :precision binary64 (* eps (* eps -0.5)))
double code(double x, double eps) {
return eps * (eps * -0.5);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (eps * (-0.5d0))
end function
public static double code(double x, double eps) {
return eps * (eps * -0.5);
}
def code(x, eps): return eps * (eps * -0.5)
function code(x, eps) return Float64(eps * Float64(eps * -0.5)) end
function tmp = code(x, eps) tmp = eps * (eps * -0.5); end
code[x_, eps_] := N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)
\end{array}
Initial program 39.8%
Taylor expanded in x around 0 40.7%
Taylor expanded in eps around 0 22.5%
*-commutative22.5%
unpow222.5%
Simplified22.5%
Taylor expanded in eps around 0 22.5%
*-commutative22.5%
unpow222.5%
associate-*r*22.5%
Simplified22.5%
Final simplification22.5%
herbie shell --seed 2023283
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))