
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= eps -7.8)
(- (fma (cos x) (cos eps) (* (- (sin x)) (sin eps))) (cos x))
(if (<= eps 0.00019)
(* (sin (/ (+ eps (- x x)) 2.0)) (* (sin (/ (+ eps (+ x x)) 2.0)) -2.0))
(fma (cos x) (cos eps) (- (fma (sin x) (sin eps) (cos x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -7.8) {
tmp = fma(cos(x), cos(eps), (-sin(x) * sin(eps))) - cos(x);
} else if (eps <= 0.00019) {
tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0);
} else {
tmp = fma(cos(x), cos(eps), -fma(sin(x), sin(eps), cos(x)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -7.8) tmp = Float64(fma(cos(x), cos(eps), Float64(Float64(-sin(x)) * sin(eps))) - cos(x)); elseif (eps <= 0.00019) tmp = Float64(sin(Float64(Float64(eps + Float64(x - x)) / 2.0)) * Float64(sin(Float64(Float64(eps + Float64(x + x)) / 2.0)) * -2.0)); else tmp = fma(cos(x), cos(eps), Float64(-fma(sin(x), sin(eps), cos(x)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -7.8], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[((-N[Sin[x], $MachinePrecision]) * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00019], N[(N[Sin[N[(N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $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}
\mathbf{if}\;\varepsilon \leq -7.8:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\sin x\right) \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.00019:\\
\;\;\;\;\sin \left(\frac{\varepsilon + \left(x - x\right)}{2}\right) \cdot \left(\sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right) \cdot -2\right)\\
\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 < -7.79999999999999982Initial program 54.3%
cos-sum98.7%
cancel-sign-sub-inv98.7%
fma-def98.7%
Applied egg-rr98.7%
if -7.79999999999999982 < eps < 1.9000000000000001e-4Initial program 35.6%
add-exp-log34.0%
Applied egg-rr34.0%
add-exp-log35.6%
diff-cos52.1%
Applied egg-rr52.1%
*-commutative52.1%
associate-*l*52.2%
+-commutative52.2%
associate--l+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
if 1.9000000000000001e-4 < eps Initial program 48.0%
cos-sum98.6%
associate--l-98.7%
fma-neg98.8%
fma-def98.9%
Applied egg-rr98.9%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))))
(if (<= eps -7.8)
(- (- t_0 (* (sin x) (sin eps))) (cos x))
(if (<= eps 0.0054)
(* (sin (/ (+ eps (- x x)) 2.0)) (* (sin (/ (+ eps (+ x x)) 2.0)) -2.0))
(- t_0 (fma (sin eps) (sin x) (cos x)))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double tmp;
if (eps <= -7.8) {
tmp = (t_0 - (sin(x) * sin(eps))) - cos(x);
} else if (eps <= 0.0054) {
tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0);
} else {
tmp = t_0 - fma(sin(eps), sin(x), cos(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) tmp = 0.0 if (eps <= -7.8) tmp = Float64(Float64(t_0 - Float64(sin(x) * sin(eps))) - cos(x)); elseif (eps <= 0.0054) tmp = Float64(sin(Float64(Float64(eps + Float64(x - x)) / 2.0)) * Float64(sin(Float64(Float64(eps + Float64(x + x)) / 2.0)) * -2.0)); else tmp = Float64(t_0 - fma(sin(eps), sin(x), cos(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7.8], N[(N[(t$95$0 - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0054], N[(N[Sin[N[(N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -7.8:\\
\;\;\;\;\left(t_0 - \sin x \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.0054:\\
\;\;\;\;\sin \left(\frac{\varepsilon + \left(x - x\right)}{2}\right) \cdot \left(\sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right) \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\end{array}
\end{array}
if eps < -7.79999999999999982Initial program 54.3%
cos-sum98.7%
Applied egg-rr98.7%
if -7.79999999999999982 < eps < 0.0054000000000000003Initial program 35.6%
add-exp-log34.0%
Applied egg-rr34.0%
add-exp-log35.6%
diff-cos52.1%
Applied egg-rr52.1%
*-commutative52.1%
associate-*l*52.2%
+-commutative52.2%
associate--l+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
if 0.0054000000000000003 < eps Initial program 48.0%
sub-neg48.0%
cos-sum98.6%
associate-+l-98.7%
fma-neg98.8%
Applied egg-rr98.8%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (<= eps -7.8)
(- (fma (cos x) (cos eps) (* (- (sin x)) (sin eps))) (cos x))
(if (<= eps 0.0054)
(* (sin (/ (+ eps (- x x)) 2.0)) (* (sin (/ (+ eps (+ x x)) 2.0)) -2.0))
(- (* (cos x) (cos eps)) (fma (sin eps) (sin x) (cos x))))))
double code(double x, double eps) {
double tmp;
if (eps <= -7.8) {
tmp = fma(cos(x), cos(eps), (-sin(x) * sin(eps))) - cos(x);
} else if (eps <= 0.0054) {
tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0);
} else {
tmp = (cos(x) * cos(eps)) - fma(sin(eps), sin(x), cos(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -7.8) tmp = Float64(fma(cos(x), cos(eps), Float64(Float64(-sin(x)) * sin(eps))) - cos(x)); elseif (eps <= 0.0054) tmp = Float64(sin(Float64(Float64(eps + Float64(x - x)) / 2.0)) * Float64(sin(Float64(Float64(eps + Float64(x + x)) / 2.0)) * -2.0)); else tmp = Float64(Float64(cos(x) * cos(eps)) - fma(sin(eps), sin(x), cos(x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -7.8], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[((-N[Sin[x], $MachinePrecision]) * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0054], N[(N[Sin[N[(N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7.8:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\sin x\right) \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.0054:\\
\;\;\;\;\sin \left(\frac{\varepsilon + \left(x - x\right)}{2}\right) \cdot \left(\sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right) \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\end{array}
\end{array}
if eps < -7.79999999999999982Initial program 54.3%
cos-sum98.7%
cancel-sign-sub-inv98.7%
fma-def98.7%
Applied egg-rr98.7%
if -7.79999999999999982 < eps < 0.0054000000000000003Initial program 35.6%
add-exp-log34.0%
Applied egg-rr34.0%
add-exp-log35.6%
diff-cos52.1%
Applied egg-rr52.1%
*-commutative52.1%
associate-*l*52.2%
+-commutative52.2%
associate--l+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
if 0.0054000000000000003 < eps Initial program 48.0%
sub-neg48.0%
cos-sum98.6%
associate-+l-98.7%
fma-neg98.8%
Applied egg-rr98.8%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -7.8) (not (<= eps 0.00096))) (- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps)))) (* (sin (/ (+ eps (- x x)) 2.0)) (* (sin (/ (+ eps (+ x x)) 2.0)) -2.0))))
double code(double x, double eps) {
double tmp;
if ((eps <= -7.8) || !(eps <= 0.00096)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
} else {
tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -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 <= (-7.8d0)) .or. (.not. (eps <= 0.00096d0))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
else
tmp = sin(((eps + (x - x)) / 2.0d0)) * (sin(((eps + (x + x)) / 2.0d0)) * (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -7.8) || !(eps <= 0.00096)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
} else {
tmp = Math.sin(((eps + (x - x)) / 2.0)) * (Math.sin(((eps + (x + x)) / 2.0)) * -2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -7.8) or not (eps <= 0.00096): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps))) else: tmp = math.sin(((eps + (x - x)) / 2.0)) * (math.sin(((eps + (x + x)) / 2.0)) * -2.0) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -7.8) || !(eps <= 0.00096)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); else tmp = Float64(sin(Float64(Float64(eps + Float64(x - x)) / 2.0)) * Float64(sin(Float64(Float64(eps + Float64(x + x)) / 2.0)) * -2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -7.8) || ~((eps <= 0.00096))) tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps))); else tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -7.8], N[Not[LessEqual[eps, 0.00096]], $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[Sin[N[(N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7.8 \lor \neg \left(\varepsilon \leq 0.00096\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\frac{\varepsilon + \left(x - x\right)}{2}\right) \cdot \left(\sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right) \cdot -2\right)\\
\end{array}
\end{array}
if eps < -7.79999999999999982 or 9.60000000000000024e-4 < eps Initial program 51.2%
cos-sum98.7%
cancel-sign-sub-inv98.7%
fma-def98.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 98.7%
neg-mul-198.7%
+-commutative98.7%
sub-neg98.7%
associate--l-98.6%
*-commutative98.6%
*-commutative98.6%
Simplified98.6%
if -7.79999999999999982 < eps < 9.60000000000000024e-4Initial program 35.6%
add-exp-log34.0%
Applied egg-rr34.0%
add-exp-log35.6%
diff-cos52.1%
Applied egg-rr52.1%
*-commutative52.1%
associate-*l*52.2%
+-commutative52.2%
associate--l+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin x) (sin eps))))
(if (<= eps -7.8)
(- (- t_0 t_1) (cos x))
(if (<= eps 0.00095)
(* (sin (/ (+ eps (- x x)) 2.0)) (* (sin (/ (+ eps (+ x x)) 2.0)) -2.0))
(- t_0 (+ (cos x) t_1))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -7.8) {
tmp = (t_0 - t_1) - cos(x);
} else if (eps <= 0.00095) {
tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0);
} else {
tmp = t_0 - (cos(x) + t_1);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(x) * cos(eps)
t_1 = sin(x) * sin(eps)
if (eps <= (-7.8d0)) then
tmp = (t_0 - t_1) - cos(x)
else if (eps <= 0.00095d0) then
tmp = sin(((eps + (x - x)) / 2.0d0)) * (sin(((eps + (x + x)) / 2.0d0)) * (-2.0d0))
else
tmp = t_0 - (cos(x) + t_1)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(x) * Math.cos(eps);
double t_1 = Math.sin(x) * Math.sin(eps);
double tmp;
if (eps <= -7.8) {
tmp = (t_0 - t_1) - Math.cos(x);
} else if (eps <= 0.00095) {
tmp = Math.sin(((eps + (x - x)) / 2.0)) * (Math.sin(((eps + (x + x)) / 2.0)) * -2.0);
} else {
tmp = t_0 - (Math.cos(x) + t_1);
}
return tmp;
}
def code(x, eps): t_0 = math.cos(x) * math.cos(eps) t_1 = math.sin(x) * math.sin(eps) tmp = 0 if eps <= -7.8: tmp = (t_0 - t_1) - math.cos(x) elif eps <= 0.00095: tmp = math.sin(((eps + (x - x)) / 2.0)) * (math.sin(((eps + (x + x)) / 2.0)) * -2.0) else: tmp = t_0 - (math.cos(x) + t_1) return tmp
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) t_1 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -7.8) tmp = Float64(Float64(t_0 - t_1) - cos(x)); elseif (eps <= 0.00095) tmp = Float64(sin(Float64(Float64(eps + Float64(x - x)) / 2.0)) * Float64(sin(Float64(Float64(eps + Float64(x + x)) / 2.0)) * -2.0)); else tmp = Float64(t_0 - Float64(cos(x) + t_1)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(x) * cos(eps); t_1 = sin(x) * sin(eps); tmp = 0.0; if (eps <= -7.8) tmp = (t_0 - t_1) - cos(x); elseif (eps <= 0.00095) tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0); else tmp = t_0 - (cos(x) + t_1); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -7.8], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00095], N[(N[Sin[N[(N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
t_1 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -7.8:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.00095:\\
\;\;\;\;\sin \left(\frac{\varepsilon + \left(x - x\right)}{2}\right) \cdot \left(\sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right) \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\end{array}
\end{array}
if eps < -7.79999999999999982Initial program 54.3%
cos-sum98.7%
Applied egg-rr98.7%
if -7.79999999999999982 < eps < 9.49999999999999998e-4Initial program 35.6%
add-exp-log34.0%
Applied egg-rr34.0%
add-exp-log35.6%
diff-cos52.1%
Applied egg-rr52.1%
*-commutative52.1%
associate-*l*52.2%
+-commutative52.2%
associate--l+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
if 9.49999999999999998e-4 < eps Initial program 48.0%
cos-sum98.6%
cancel-sign-sub-inv98.6%
fma-def98.8%
Applied egg-rr98.8%
Taylor expanded in x around inf 98.6%
neg-mul-198.6%
+-commutative98.6%
sub-neg98.6%
associate--l-98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (* (sin (/ (+ eps (- x x)) 2.0)) (* (sin (/ (+ eps (+ x x)) 2.0)) -2.0)))
double code(double x, double eps) {
return sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(((eps + (x - x)) / 2.0d0)) * (sin(((eps + (x + x)) / 2.0d0)) * (-2.0d0))
end function
public static double code(double x, double eps) {
return Math.sin(((eps + (x - x)) / 2.0)) * (Math.sin(((eps + (x + x)) / 2.0)) * -2.0);
}
def code(x, eps): return math.sin(((eps + (x - x)) / 2.0)) * (math.sin(((eps + (x + x)) / 2.0)) * -2.0)
function code(x, eps) return Float64(sin(Float64(Float64(eps + Float64(x - x)) / 2.0)) * Float64(sin(Float64(Float64(eps + Float64(x + x)) / 2.0)) * -2.0)) end
function tmp = code(x, eps) tmp = sin(((eps + (x - x)) / 2.0)) * (sin(((eps + (x + x)) / 2.0)) * -2.0); end
code[x_, eps_] := N[(N[Sin[N[(N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(\frac{\varepsilon + \left(x - x\right)}{2}\right) \cdot \left(\sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right) \cdot -2\right)
\end{array}
Initial program 43.1%
add-exp-log29.9%
Applied egg-rr29.9%
add-exp-log43.1%
diff-cos51.5%
Applied egg-rr51.5%
*-commutative51.5%
associate-*l*51.5%
+-commutative51.5%
associate--l+76.6%
+-commutative76.6%
associate-+l+76.6%
Simplified76.6%
Final simplification76.6%
(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 43.1%
add-exp-log29.9%
Applied egg-rr29.9%
add-exp-log43.1%
diff-cos51.5%
Applied egg-rr51.5%
*-commutative51.5%
associate-*l*51.5%
+-commutative51.5%
associate--l+76.6%
+-commutative76.6%
associate-+l+76.6%
Simplified76.6%
Taylor expanded in x around -inf 76.6%
Final simplification76.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (cos eps) (cos x))) (t_1 (* -0.5 (* eps (+ x (+ eps x))))))
(if (<= eps -5e-5)
t_0
(if (<= eps -3.4e-71)
t_1
(if (<= eps 3.5e-79) (* eps (- (sin x))) (if (<= eps 4.7) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) - cos(x);
double t_1 = -0.5 * (eps * (x + (eps + x)));
double tmp;
if (eps <= -5e-5) {
tmp = t_0;
} else if (eps <= -3.4e-71) {
tmp = t_1;
} else if (eps <= 3.5e-79) {
tmp = eps * -sin(x);
} else if (eps <= 4.7) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(eps) - cos(x)
t_1 = (-0.5d0) * (eps * (x + (eps + x)))
if (eps <= (-5d-5)) then
tmp = t_0
else if (eps <= (-3.4d-71)) then
tmp = t_1
else if (eps <= 3.5d-79) then
tmp = eps * -sin(x)
else if (eps <= 4.7d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(eps) - Math.cos(x);
double t_1 = -0.5 * (eps * (x + (eps + x)));
double tmp;
if (eps <= -5e-5) {
tmp = t_0;
} else if (eps <= -3.4e-71) {
tmp = t_1;
} else if (eps <= 3.5e-79) {
tmp = eps * -Math.sin(x);
} else if (eps <= 4.7) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) - math.cos(x) t_1 = -0.5 * (eps * (x + (eps + x))) tmp = 0 if eps <= -5e-5: tmp = t_0 elif eps <= -3.4e-71: tmp = t_1 elif eps <= 3.5e-79: tmp = eps * -math.sin(x) elif eps <= 4.7: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) - cos(x)) t_1 = Float64(-0.5 * Float64(eps * Float64(x + Float64(eps + x)))) tmp = 0.0 if (eps <= -5e-5) tmp = t_0; elseif (eps <= -3.4e-71) tmp = t_1; elseif (eps <= 3.5e-79) tmp = Float64(eps * Float64(-sin(x))); elseif (eps <= 4.7) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) - cos(x); t_1 = -0.5 * (eps * (x + (eps + x))); tmp = 0.0; if (eps <= -5e-5) tmp = t_0; elseif (eps <= -3.4e-71) tmp = t_1; elseif (eps <= 3.5e-79) tmp = eps * -sin(x); elseif (eps <= 4.7) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(eps * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5e-5], t$95$0, If[LessEqual[eps, -3.4e-71], t$95$1, If[LessEqual[eps, 3.5e-79], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 4.7], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon - \cos x\\
t_1 := -0.5 \cdot \left(\varepsilon \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\\
\mathbf{if}\;\varepsilon \leq -5 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -3.4 \cdot 10^{-71}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{-79}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 4.7:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -5.00000000000000024e-5 or 4.70000000000000018 < eps Initial program 52.3%
Taylor expanded in x around 0 53.8%
if -5.00000000000000024e-5 < eps < -3.40000000000000003e-71 or 3.5000000000000003e-79 < eps < 4.70000000000000018Initial program 7.6%
Taylor expanded in x around 0 7.6%
Taylor expanded in eps around 0 65.3%
+-rgt-identity65.3%
metadata-eval65.3%
+-inverses65.3%
+-inverses65.3%
flip--0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
flip-+64.6%
pow264.6%
associate-+r+64.6%
+-commutative64.6%
distribute-rgt-in64.6%
Applied egg-rr72.5%
distribute-rgt-out72.5%
+-commutative72.5%
Simplified72.5%
if -3.40000000000000003e-71 < eps < 3.5000000000000003e-79Initial program 42.2%
Taylor expanded in eps around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-rgt-neg-in97.1%
Simplified97.1%
Final simplification73.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3e-69) (not (<= eps 8e-30))) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3e-69) || !(eps <= 8e-30)) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.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 <= (-3d-69)) .or. (.not. (eps <= 8d-30))) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3e-69) || !(eps <= 8e-30)) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3e-69) or not (eps <= 8e-30): tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3e-69) || !(eps <= 8e-30)) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3e-69) || ~((eps <= 8e-30))) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3e-69], N[Not[LessEqual[eps, 8e-30]], $MachinePrecision]], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3 \cdot 10^{-69} \lor \neg \left(\varepsilon \leq 8 \cdot 10^{-30}\right):\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -2.99999999999999989e-69 or 8.000000000000001e-30 < eps Initial program 46.4%
diff-cos55.8%
div-inv55.8%
associate--l+55.8%
metadata-eval55.8%
div-inv55.8%
+-commutative55.8%
associate-+l+55.9%
metadata-eval55.9%
Applied egg-rr55.9%
associate-*r*55.9%
*-commutative55.9%
*-commutative55.9%
+-commutative55.9%
count-255.9%
fma-def55.9%
sub-neg55.9%
mul-1-neg55.9%
+-commutative55.9%
associate-+r+58.7%
mul-1-neg58.7%
sub-neg58.7%
+-inverses58.7%
remove-double-neg58.7%
mul-1-neg58.7%
sub-neg58.7%
neg-sub058.7%
mul-1-neg58.7%
remove-double-neg58.7%
Simplified58.7%
Taylor expanded in x around 0 55.7%
if -2.99999999999999989e-69 < eps < 8.000000000000001e-30Initial program 38.8%
Taylor expanded in eps around 0 93.1%
mul-1-neg93.1%
*-commutative93.1%
distribute-rgt-neg-in93.1%
Simplified93.1%
Final simplification71.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* -0.5 (* eps (+ x (+ eps x))))))
(if (<= eps -0.006)
t_0
(if (<= eps -3.2e-72)
t_1
(if (<= eps 1.6e-79) (* eps (- (sin x))) (if (<= eps 4.7) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = -0.5 * (eps * (x + (eps + x)));
double tmp;
if (eps <= -0.006) {
tmp = t_0;
} else if (eps <= -3.2e-72) {
tmp = t_1;
} else if (eps <= 1.6e-79) {
tmp = eps * -sin(x);
} else if (eps <= 4.7) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(eps) + (-1.0d0)
t_1 = (-0.5d0) * (eps * (x + (eps + x)))
if (eps <= (-0.006d0)) then
tmp = t_0
else if (eps <= (-3.2d-72)) then
tmp = t_1
else if (eps <= 1.6d-79) then
tmp = eps * -sin(x)
else if (eps <= 4.7d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(eps) + -1.0;
double t_1 = -0.5 * (eps * (x + (eps + x)));
double tmp;
if (eps <= -0.006) {
tmp = t_0;
} else if (eps <= -3.2e-72) {
tmp = t_1;
} else if (eps <= 1.6e-79) {
tmp = eps * -Math.sin(x);
} else if (eps <= 4.7) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = -0.5 * (eps * (x + (eps + x))) tmp = 0 if eps <= -0.006: tmp = t_0 elif eps <= -3.2e-72: tmp = t_1 elif eps <= 1.6e-79: tmp = eps * -math.sin(x) elif eps <= 4.7: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(-0.5 * Float64(eps * Float64(x + Float64(eps + x)))) tmp = 0.0 if (eps <= -0.006) tmp = t_0; elseif (eps <= -3.2e-72) tmp = t_1; elseif (eps <= 1.6e-79) tmp = Float64(eps * Float64(-sin(x))); elseif (eps <= 4.7) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) + -1.0; t_1 = -0.5 * (eps * (x + (eps + x))); tmp = 0.0; if (eps <= -0.006) tmp = t_0; elseif (eps <= -3.2e-72) tmp = t_1; elseif (eps <= 1.6e-79) tmp = eps * -sin(x); elseif (eps <= 4.7) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(eps * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.006], t$95$0, If[LessEqual[eps, -3.2e-72], t$95$1, If[LessEqual[eps, 1.6e-79], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], If[LessEqual[eps, 4.7], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := -0.5 \cdot \left(\varepsilon \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\\
\mathbf{if}\;\varepsilon \leq -0.006:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -3.2 \cdot 10^{-72}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 1.6 \cdot 10^{-79}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 4.7:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -0.0060000000000000001 or 4.70000000000000018 < eps Initial program 52.2%
Taylor expanded in x around 0 52.6%
if -0.0060000000000000001 < eps < -3.19999999999999999e-72 or 1.59999999999999994e-79 < eps < 4.70000000000000018Initial program 9.5%
Taylor expanded in x around 0 7.4%
Taylor expanded in eps around 0 63.2%
+-rgt-identity63.2%
metadata-eval63.2%
+-inverses63.2%
+-inverses63.2%
flip--0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
flip-+62.6%
pow262.6%
associate-+r+62.6%
+-commutative62.6%
distribute-rgt-in62.6%
Applied egg-rr70.6%
distribute-rgt-out70.6%
+-commutative70.6%
Simplified70.6%
if -3.19999999999999999e-72 < eps < 1.59999999999999994e-79Initial program 42.2%
Taylor expanded in eps around 0 97.1%
mul-1-neg97.1%
*-commutative97.1%
distribute-rgt-neg-in97.1%
Simplified97.1%
Final simplification72.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.006) (not (<= eps 4.7))) (+ (cos eps) -1.0) (* -0.5 (* eps (+ x (+ eps x))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.006) || !(eps <= 4.7)) {
tmp = cos(eps) + -1.0;
} else {
tmp = -0.5 * (eps * (x + (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 <= (-0.006d0)) .or. (.not. (eps <= 4.7d0))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = (-0.5d0) * (eps * (x + (eps + x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.006) || !(eps <= 4.7)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = -0.5 * (eps * (x + (eps + x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.006) or not (eps <= 4.7): tmp = math.cos(eps) + -1.0 else: tmp = -0.5 * (eps * (x + (eps + x))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.006) || !(eps <= 4.7)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(-0.5 * Float64(eps * Float64(x + Float64(eps + x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.006) || ~((eps <= 4.7))) tmp = cos(eps) + -1.0; else tmp = -0.5 * (eps * (x + (eps + x))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.006], N[Not[LessEqual[eps, 4.7]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(-0.5 * N[(eps * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.006 \lor \neg \left(\varepsilon \leq 4.7\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\\
\end{array}
\end{array}
if eps < -0.0060000000000000001 or 4.70000000000000018 < eps Initial program 52.2%
Taylor expanded in x around 0 52.6%
if -0.0060000000000000001 < eps < 4.70000000000000018Initial program 34.6%
Taylor expanded in x around 0 34.0%
Taylor expanded in eps around 0 49.0%
+-rgt-identity49.0%
metadata-eval49.0%
+-inverses49.0%
+-inverses49.0%
flip--0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
flip-+35.3%
pow235.3%
associate-+r+35.3%
+-commutative35.3%
distribute-rgt-in35.3%
Applied egg-rr61.9%
distribute-rgt-out61.9%
+-commutative61.9%
Simplified61.9%
Final simplification57.4%
(FPCore (x eps) :precision binary64 (* -0.5 (* eps (+ x (+ eps x)))))
double code(double x, double eps) {
return -0.5 * (eps * (x + (eps + x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-0.5d0) * (eps * (x + (eps + x)))
end function
public static double code(double x, double eps) {
return -0.5 * (eps * (x + (eps + x)));
}
def code(x, eps): return -0.5 * (eps * (x + (eps + x)))
function code(x, eps) return Float64(-0.5 * Float64(eps * Float64(x + Float64(eps + x)))) end
function tmp = code(x, eps) tmp = -0.5 * (eps * (x + (eps + x))); end
code[x_, eps_] := N[(-0.5 * N[(eps * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \left(\varepsilon \cdot \left(x + \left(\varepsilon + x\right)\right)\right)
\end{array}
Initial program 43.1%
Taylor expanded in x around 0 43.0%
Taylor expanded in eps around 0 27.0%
+-rgt-identity27.0%
metadata-eval27.0%
+-inverses27.0%
+-inverses27.0%
flip--0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
flip-+19.8%
pow219.8%
associate-+r+19.8%
+-commutative19.8%
distribute-rgt-in19.8%
Applied egg-rr33.5%
distribute-rgt-out33.6%
+-commutative33.6%
Simplified33.6%
Final simplification33.6%
(FPCore (x eps) :precision binary64 (* -0.5 (* eps eps)))
double code(double x, double eps) {
return -0.5 * (eps * eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-0.5d0) * (eps * eps)
end function
public static double code(double x, double eps) {
return -0.5 * (eps * eps);
}
def code(x, eps): return -0.5 * (eps * eps)
function code(x, eps) return Float64(-0.5 * Float64(eps * eps)) end
function tmp = code(x, eps) tmp = -0.5 * (eps * eps); end
code[x_, eps_] := N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)
\end{array}
Initial program 43.1%
Taylor expanded in x around 0 43.0%
Taylor expanded in eps around 0 27.0%
unpow227.0%
Applied egg-rr27.0%
Final simplification27.0%
herbie shell --seed 2023333
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))