
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.8e-5) (not (<= eps 4.3e-5))) (fma (cos x) (cos eps) (- (- (cos x)) (* (sin x) (sin eps)))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.8e-5) || !(eps <= 4.3e-5)) {
tmp = fma(cos(x), cos(eps), (-cos(x) - (sin(x) * sin(eps))));
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.8e-5) || !(eps <= 4.3e-5)) tmp = fma(cos(x), cos(eps), Float64(Float64(-cos(x)) - Float64(sin(x) * sin(eps)))); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.8e-5], N[Not[LessEqual[eps, 4.3e-5]], $MachinePrecision]], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[((-N[Cos[x], $MachinePrecision]) - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $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 -3.8 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 4.3 \cdot 10^{-5}\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\cos x\right) - \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -3.8000000000000002e-5 or 4.3000000000000002e-5 < eps Initial program 48.9%
sub-neg48.9%
cos-sum98.4%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
sub-neg98.5%
remove-double-neg98.5%
Applied egg-rr98.5%
if -3.8000000000000002e-5 < eps < 4.3000000000000002e-5Initial program 23.1%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.2e-5) (not (<= eps 5.1e-5))) (- (* (cos x) (cos eps)) (fma (sin eps) (sin x) (cos x))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.2e-5) || !(eps <= 5.1e-5)) {
tmp = (cos(x) * cos(eps)) - fma(sin(eps), sin(x), cos(x));
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.2e-5) || !(eps <= 5.1e-5)) tmp = Float64(Float64(cos(x) * cos(eps)) - fma(sin(eps), sin(x), cos(x))); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.2e-5], N[Not[LessEqual[eps, 5.1e-5]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[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 -3.2 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 5.1 \cdot 10^{-5}\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -3.19999999999999986e-5 or 5.09999999999999996e-5 < eps Initial program 48.9%
sub-neg48.9%
cos-sum98.4%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
fma-neg98.5%
*-commutative98.5%
*-commutative98.5%
fma-neg98.5%
remove-double-neg98.5%
Simplified98.5%
if -3.19999999999999986e-5 < eps < 5.09999999999999996e-5Initial program 23.1%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.4e-5) (not (<= eps 4.1e-5))) (- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps)))) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.4e-5) || !(eps <= 4.1e-5)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
} 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 <= (-3.4d-5)) .or. (.not. (eps <= 4.1d-5))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
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 <= -3.4e-5) || !(eps <= 4.1e-5)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
} 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 <= -3.4e-5) or not (eps <= 4.1e-5): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps))) 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 <= -3.4e-5) || !(eps <= 4.1e-5)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); 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 <= -3.4e-5) || ~((eps <= 4.1e-5))) tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps))); else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.4e-5], N[Not[LessEqual[eps, 4.1e-5]], $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[(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 -3.4 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 4.1 \cdot 10^{-5}\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -3.4e-5 or 4.10000000000000005e-5 < eps Initial program 48.9%
sub-neg48.9%
cos-sum98.4%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 98.5%
if -3.4e-5 < eps < 4.10000000000000005e-5Initial program 23.1%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin x) (sin eps))))
(if (<= eps -2.7e-5)
(- t_0 (+ (cos x) t_1))
(if (<= eps 5.8e-5)
(- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))
(- (- t_0 t_1) (cos x))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -2.7e-5) {
tmp = t_0 - (cos(x) + t_1);
} else if (eps <= 5.8e-5) {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
} 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(x) * sin(eps)
if (eps <= (-2.7d-5)) then
tmp = t_0 - (cos(x) + t_1)
else if (eps <= 5.8d-5) then
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
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(x) * Math.sin(eps);
double tmp;
if (eps <= -2.7e-5) {
tmp = t_0 - (Math.cos(x) + t_1);
} else if (eps <= 5.8e-5) {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
} 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(x) * math.sin(eps) tmp = 0 if eps <= -2.7e-5: tmp = t_0 - (math.cos(x) + t_1) elif eps <= 5.8e-5: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) 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(x) * sin(eps)) tmp = 0.0 if (eps <= -2.7e-5) tmp = Float64(t_0 - Float64(cos(x) + t_1)); elseif (eps <= 5.8e-5) tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); 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(x) * sin(eps); tmp = 0.0; if (eps <= -2.7e-5) tmp = t_0 - (cos(x) + t_1); elseif (eps <= 5.8e-5) tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); 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[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.7e-5], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5.8e-5], 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], 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 x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -2.7 \cdot 10^{-5}:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\mathbf{elif}\;\varepsilon \leq 5.8 \cdot 10^{-5}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\end{array}
\end{array}
if eps < -2.6999999999999999e-5Initial program 47.8%
sub-neg47.8%
cos-sum98.7%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 98.7%
if -2.6999999999999999e-5 < eps < 5.8e-5Initial program 23.1%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
if 5.8e-5 < eps Initial program 49.8%
cos-sum98.3%
Applied egg-rr98.3%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (<= (- (cos (+ eps x)) (cos x)) -5e-15)
(* -2.0 (pow t_0 2.0))
(* (sin x) (* -2.0 t_0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-15) {
tmp = -2.0 * pow(t_0, 2.0);
} else {
tmp = sin(x) * (-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 * 0.5d0))
if ((cos((eps + x)) - cos(x)) <= (-5d-15)) then
tmp = (-2.0d0) * (t_0 ** 2.0d0)
else
tmp = sin(x) * ((-2.0d0) * t_0)
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 ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-15) {
tmp = -2.0 * Math.pow(t_0, 2.0);
} else {
tmp = Math.sin(x) * (-2.0 * t_0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-15: tmp = -2.0 * math.pow(t_0, 2.0) else: tmp = math.sin(x) * (-2.0 * t_0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-15) tmp = Float64(-2.0 * (t_0 ^ 2.0)); else tmp = Float64(sin(x) * Float64(-2.0 * t_0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -5e-15) tmp = -2.0 * (t_0 ^ 2.0); else tmp = sin(x) * (-2.0 * t_0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-15], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-15}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.99999999999999999e-15Initial program 80.8%
diff-cos82.8%
div-inv82.8%
associate--l+82.8%
metadata-eval82.8%
div-inv82.8%
+-commutative82.8%
associate-+l+82.8%
metadata-eval82.8%
Applied egg-rr82.8%
associate-*r*82.8%
*-commutative82.8%
*-commutative82.8%
+-commutative82.8%
count-282.8%
fma-def82.8%
sub-neg82.8%
mul-1-neg82.8%
+-commutative82.8%
associate-+r+82.8%
mul-1-neg82.8%
sub-neg82.8%
+-inverses82.8%
remove-double-neg82.8%
mul-1-neg82.8%
sub-neg82.8%
neg-sub082.8%
mul-1-neg82.8%
remove-double-neg82.8%
Simplified82.8%
Taylor expanded in x around 0 82.6%
if -4.99999999999999999e-15 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.7%
diff-cos24.9%
div-inv24.9%
associate--l+24.9%
metadata-eval24.9%
div-inv24.9%
+-commutative24.9%
associate-+l+24.8%
metadata-eval24.8%
Applied egg-rr24.8%
associate-*r*24.8%
*-commutative24.8%
*-commutative24.8%
+-commutative24.8%
count-224.8%
fma-def24.8%
sub-neg24.8%
mul-1-neg24.8%
+-commutative24.8%
associate-+r+69.2%
mul-1-neg69.2%
sub-neg69.2%
+-inverses69.2%
remove-double-neg69.2%
mul-1-neg69.2%
sub-neg69.2%
neg-sub069.2%
mul-1-neg69.2%
remove-double-neg69.2%
Simplified69.2%
Taylor expanded in eps around 0 61.6%
Final simplification68.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.0245) (not (<= eps 0.04))) (- (* (cos x) (cos eps)) (cos x)) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0245) || !(eps <= 0.04)) {
tmp = (cos(x) * cos(eps)) - cos(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 <= (-0.0245d0)) .or. (.not. (eps <= 0.04d0))) then
tmp = (cos(x) * cos(eps)) - cos(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 <= -0.0245) || !(eps <= 0.04)) {
tmp = (Math.cos(x) * Math.cos(eps)) - Math.cos(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 <= -0.0245) or not (eps <= 0.04): tmp = (math.cos(x) * math.cos(eps)) - math.cos(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 <= -0.0245) || !(eps <= 0.04)) tmp = Float64(Float64(cos(x) * cos(eps)) - cos(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 <= -0.0245) || ~((eps <= 0.04))) tmp = (cos(x) * cos(eps)) - cos(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, -0.0245], N[Not[LessEqual[eps, 0.04]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $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 -0.0245 \lor \neg \left(\varepsilon \leq 0.04\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -0.024500000000000001 or 0.0400000000000000008 < eps Initial program 48.9%
sub-neg48.9%
cos-sum98.4%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
+-commutative98.5%
*-commutative98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in eps around 0 52.8%
if -0.024500000000000001 < eps < 0.0400000000000000008Initial program 23.1%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification74.6%
(FPCore (x eps) :precision binary64 (* (sin (* 0.5 (fma 2.0 x eps))) (* -2.0 (sin (* eps 0.5)))))
double code(double x, double eps) {
return sin((0.5 * fma(2.0, x, eps))) * (-2.0 * sin((eps * 0.5)));
}
function code(x, eps) return Float64(sin(Float64(0.5 * fma(2.0, x, eps))) * Float64(-2.0 * sin(Float64(eps * 0.5)))) end
code[x_, eps_] := N[(N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 37.0%
diff-cos42.5%
div-inv42.5%
associate--l+42.5%
metadata-eval42.5%
div-inv42.5%
+-commutative42.5%
associate-+l+42.5%
metadata-eval42.5%
Applied egg-rr42.5%
associate-*r*42.5%
*-commutative42.5%
*-commutative42.5%
+-commutative42.5%
count-242.5%
fma-def42.5%
sub-neg42.5%
mul-1-neg42.5%
+-commutative42.5%
associate-+r+73.3%
mul-1-neg73.3%
sub-neg73.3%
+-inverses73.3%
remove-double-neg73.3%
mul-1-neg73.3%
sub-neg73.3%
neg-sub073.3%
mul-1-neg73.3%
remove-double-neg73.3%
Simplified73.3%
Final simplification73.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.0036) (not (<= eps 0.0037))) (- (* (cos x) (cos eps)) (cos x)) (* (sin (* 0.5 (fma 2.0 x eps))) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0036) || !(eps <= 0.0037)) {
tmp = (cos(x) * cos(eps)) - cos(x);
} else {
tmp = sin((0.5 * fma(2.0, x, eps))) * -eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.0036) || !(eps <= 0.0037)) tmp = Float64(Float64(cos(x) * cos(eps)) - cos(x)); else tmp = Float64(sin(Float64(0.5 * fma(2.0, x, eps))) * Float64(-eps)); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0036], N[Not[LessEqual[eps, 0.0037]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0036 \lor \neg \left(\varepsilon \leq 0.0037\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.0035999999999999999 or 0.0037000000000000002 < eps Initial program 48.9%
sub-neg48.9%
cos-sum98.4%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
+-commutative98.5%
*-commutative98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in eps around 0 52.8%
if -0.0035999999999999999 < eps < 0.0037000000000000002Initial program 23.1%
diff-cos35.1%
div-inv35.1%
associate--l+35.1%
metadata-eval35.1%
div-inv35.1%
+-commutative35.1%
associate-+l+35.1%
metadata-eval35.1%
Applied egg-rr35.1%
associate-*r*35.1%
*-commutative35.1%
*-commutative35.1%
+-commutative35.1%
count-235.1%
fma-def35.1%
sub-neg35.1%
mul-1-neg35.1%
+-commutative35.1%
associate-+r+99.3%
mul-1-neg99.3%
sub-neg99.3%
+-inverses99.3%
remove-double-neg99.3%
mul-1-neg99.3%
sub-neg99.3%
neg-sub099.3%
mul-1-neg99.3%
remove-double-neg99.3%
Simplified99.3%
Taylor expanded in eps around 0 99.2%
mul-1-neg99.2%
Simplified99.2%
Final simplification74.4%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.1e-7)
(* -2.0 (pow (sin (* eps 0.5)) 2.0))
(if (<= eps 0.0175)
(* (sin (* 0.5 (fma 2.0 x eps))) (- eps))
(- (cos eps) (cos x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.1e-7) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else if (eps <= 0.0175) {
tmp = sin((0.5 * fma(2.0, x, eps))) * -eps;
} else {
tmp = cos(eps) - cos(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -1.1e-7) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); elseif (eps <= 0.0175) tmp = Float64(sin(Float64(0.5 * fma(2.0, x, eps))) * Float64(-eps)); else tmp = Float64(cos(eps) - cos(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -1.1e-7], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0175], N[(N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-eps)), $MachinePrecision], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-7}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{elif}\;\varepsilon \leq 0.0175:\\
\;\;\;\;\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\end{array}
\end{array}
if eps < -1.1000000000000001e-7Initial program 47.6%
diff-cos48.7%
div-inv48.7%
associate--l+48.7%
metadata-eval48.7%
div-inv48.7%
+-commutative48.7%
associate-+l+48.7%
metadata-eval48.7%
Applied egg-rr48.7%
associate-*r*48.7%
*-commutative48.7%
*-commutative48.7%
+-commutative48.7%
count-248.7%
fma-def48.7%
sub-neg48.7%
mul-1-neg48.7%
+-commutative48.7%
associate-+r+50.0%
mul-1-neg50.0%
sub-neg50.0%
+-inverses50.0%
remove-double-neg50.0%
mul-1-neg50.0%
sub-neg50.0%
neg-sub050.0%
mul-1-neg50.0%
remove-double-neg50.0%
Simplified50.0%
Taylor expanded in x around 0 51.6%
if -1.1000000000000001e-7 < eps < 0.017500000000000002Initial program 23.1%
diff-cos34.5%
div-inv34.5%
associate--l+34.5%
metadata-eval34.5%
div-inv34.5%
+-commutative34.5%
associate-+l+34.5%
metadata-eval34.5%
Applied egg-rr34.5%
associate-*r*34.5%
*-commutative34.5%
*-commutative34.5%
+-commutative34.5%
count-234.5%
fma-def34.5%
sub-neg34.5%
mul-1-neg34.5%
+-commutative34.5%
associate-+r+99.2%
mul-1-neg99.2%
sub-neg99.2%
+-inverses99.2%
remove-double-neg99.2%
mul-1-neg99.2%
sub-neg99.2%
neg-sub099.2%
mul-1-neg99.2%
remove-double-neg99.2%
Simplified99.2%
Taylor expanded in eps around 0 99.2%
mul-1-neg99.2%
Simplified99.2%
if 0.017500000000000002 < eps Initial program 49.8%
Taylor expanded in x around 0 52.1%
Final simplification73.7%
(FPCore (x eps) :precision binary64 (if (<= eps -3.5e-15) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (if (<= eps 0.00038) (* eps (- (sin x))) (- (cos eps) (cos x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -3.5e-15) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else if (eps <= 0.00038) {
tmp = eps * -sin(x);
} else {
tmp = cos(eps) - cos(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-3.5d-15)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else if (eps <= 0.00038d0) then
tmp = eps * -sin(x)
else
tmp = cos(eps) - cos(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -3.5e-15) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else if (eps <= 0.00038) {
tmp = eps * -Math.sin(x);
} else {
tmp = Math.cos(eps) - Math.cos(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -3.5e-15: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) elif eps <= 0.00038: tmp = eps * -math.sin(x) else: tmp = math.cos(eps) - math.cos(x) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -3.5e-15) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); elseif (eps <= 0.00038) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(cos(eps) - cos(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -3.5e-15) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); elseif (eps <= 0.00038) tmp = eps * -sin(x); else tmp = cos(eps) - cos(x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -3.5e-15], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00038], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.5 \cdot 10^{-15}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{elif}\;\varepsilon \leq 0.00038:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\end{array}
\end{array}
if eps < -3.5000000000000001e-15Initial program 45.5%
diff-cos49.6%
div-inv49.6%
associate--l+49.6%
metadata-eval49.6%
div-inv49.6%
+-commutative49.6%
associate-+l+49.6%
metadata-eval49.6%
Applied egg-rr49.6%
associate-*r*49.6%
*-commutative49.6%
*-commutative49.6%
+-commutative49.6%
count-249.6%
fma-def49.6%
sub-neg49.6%
mul-1-neg49.6%
+-commutative49.6%
associate-+r+51.9%
mul-1-neg51.9%
sub-neg51.9%
+-inverses51.9%
remove-double-neg51.9%
mul-1-neg51.9%
sub-neg51.9%
neg-sub051.9%
mul-1-neg51.9%
remove-double-neg51.9%
Simplified51.9%
Taylor expanded in x around 0 52.3%
if -3.5000000000000001e-15 < eps < 3.8000000000000002e-4Initial program 23.6%
Taylor expanded in eps around 0 89.5%
mul-1-neg89.5%
*-commutative89.5%
distribute-rgt-neg-in89.5%
Simplified89.5%
if 3.8000000000000002e-4 < eps Initial program 49.8%
Taylor expanded in x around 0 52.1%
Final simplification68.9%
(FPCore (x eps) :precision binary64 (if (<= eps -1.1e-7) (+ (cos eps) -1.0) (if (<= eps 2.4e-6) (* eps (- (sin x))) (- (cos eps) (cos x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.1e-7) {
tmp = cos(eps) + -1.0;
} else if (eps <= 2.4e-6) {
tmp = eps * -sin(x);
} else {
tmp = cos(eps) - cos(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-1.1d-7)) then
tmp = cos(eps) + (-1.0d0)
else if (eps <= 2.4d-6) then
tmp = eps * -sin(x)
else
tmp = cos(eps) - cos(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -1.1e-7) {
tmp = Math.cos(eps) + -1.0;
} else if (eps <= 2.4e-6) {
tmp = eps * -Math.sin(x);
} else {
tmp = Math.cos(eps) - Math.cos(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.1e-7: tmp = math.cos(eps) + -1.0 elif eps <= 2.4e-6: tmp = eps * -math.sin(x) else: tmp = math.cos(eps) - math.cos(x) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.1e-7) tmp = Float64(cos(eps) + -1.0); elseif (eps <= 2.4e-6) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(cos(eps) - cos(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.1e-7) tmp = cos(eps) + -1.0; elseif (eps <= 2.4e-6) tmp = eps * -sin(x); else tmp = cos(eps) - cos(x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.1e-7], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[eps, 2.4e-6], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-7}:\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\end{array}
\end{array}
if eps < -1.1000000000000001e-7Initial program 47.6%
Taylor expanded in x around 0 50.2%
if -1.1000000000000001e-7 < eps < 2.3999999999999999e-6Initial program 23.1%
Taylor expanded in eps around 0 87.8%
mul-1-neg87.8%
*-commutative87.8%
distribute-rgt-neg-in87.8%
Simplified87.8%
if 2.3999999999999999e-6 < eps Initial program 49.8%
Taylor expanded in x around 0 52.1%
Final simplification68.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00014) (not (<= eps 0.00017))) (+ (cos eps) -1.0) (* -0.5 (pow eps 2.0))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00014) || !(eps <= 0.00017)) {
tmp = cos(eps) + -1.0;
} else {
tmp = -0.5 * pow(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 ((eps <= (-0.00014d0)) .or. (.not. (eps <= 0.00017d0))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = (-0.5d0) * (eps ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00014) || !(eps <= 0.00017)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = -0.5 * Math.pow(eps, 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00014) or not (eps <= 0.00017): tmp = math.cos(eps) + -1.0 else: tmp = -0.5 * math.pow(eps, 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00014) || !(eps <= 0.00017)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(-0.5 * (eps ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00014) || ~((eps <= 0.00017))) tmp = cos(eps) + -1.0; else tmp = -0.5 * (eps ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00014], N[Not[LessEqual[eps, 0.00017]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00014 \lor \neg \left(\varepsilon \leq 0.00017\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2}\\
\end{array}
\end{array}
if eps < -1.3999999999999999e-4 or 1.7e-4 < eps Initial program 48.9%
Taylor expanded in x around 0 50.2%
if -1.3999999999999999e-4 < eps < 1.7e-4Initial program 23.1%
Taylor expanded in x around 0 23.1%
Taylor expanded in eps around 0 35.1%
Final simplification43.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.1e-7) (not (<= eps 3.2e-6))) (+ (cos eps) -1.0) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-7) || !(eps <= 3.2e-6)) {
tmp = cos(eps) + -1.0;
} 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 ((eps <= (-1.1d-7)) .or. (.not. (eps <= 3.2d-6))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-7) || !(eps <= 3.2e-6)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.1e-7) or not (eps <= 3.2e-6): tmp = math.cos(eps) + -1.0 else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.1e-7) || !(eps <= 3.2e-6)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.1e-7) || ~((eps <= 3.2e-6))) tmp = cos(eps) + -1.0; else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.1e-7], N[Not[LessEqual[eps, 3.2e-6]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 3.2 \cdot 10^{-6}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -1.1000000000000001e-7 or 3.1999999999999999e-6 < eps Initial program 48.8%
Taylor expanded in x around 0 50.1%
if -1.1000000000000001e-7 < eps < 3.1999999999999999e-6Initial program 23.1%
Taylor expanded in eps around 0 87.8%
mul-1-neg87.8%
*-commutative87.8%
distribute-rgt-neg-in87.8%
Simplified87.8%
Final simplification67.5%
(FPCore (x eps) :precision binary64 (+ (cos eps) -1.0))
double code(double x, double eps) {
return cos(eps) + -1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos(eps) + (-1.0d0)
end function
public static double code(double x, double eps) {
return Math.cos(eps) + -1.0;
}
def code(x, eps): return math.cos(eps) + -1.0
function code(x, eps) return Float64(cos(eps) + -1.0) end
function tmp = code(x, eps) tmp = cos(eps) + -1.0; end
code[x_, eps_] := N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\cos \varepsilon + -1
\end{array}
Initial program 37.0%
Taylor expanded in x around 0 37.6%
Final simplification37.6%
(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.0%
Taylor expanded in x around 0 37.6%
Taylor expanded in eps around 0 12.3%
Final simplification12.3%
herbie shell --seed 2023332
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))