
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (- (sin eps)))))
(if (<= eps -4.5e-5)
(- (fma (cos x) (cos eps) t_0) (cos x))
(if (<= eps 5e-5)
(* (+ (sin x) (* (cos x) (* eps 0.5))) (* -2.0 (sin (* eps 0.5))))
(fma (cos x) (cos eps) (- t_0 (cos x)))))))
double code(double x, double eps) {
double t_0 = sin(x) * -sin(eps);
double tmp;
if (eps <= -4.5e-5) {
tmp = fma(cos(x), cos(eps), t_0) - cos(x);
} else if (eps <= 5e-5) {
tmp = (sin(x) + (cos(x) * (eps * 0.5))) * (-2.0 * sin((eps * 0.5)));
} else {
tmp = fma(cos(x), cos(eps), (t_0 - cos(x)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(x) * Float64(-sin(eps))) tmp = 0.0 if (eps <= -4.5e-5) tmp = Float64(fma(cos(x), cos(eps), t_0) - cos(x)); elseif (eps <= 5e-5) tmp = Float64(Float64(sin(x) + Float64(cos(x) * Float64(eps * 0.5))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); else tmp = fma(cos(x), cos(eps), Float64(t_0 - cos(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[eps, -4.5e-5], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + t$95$0), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e-5], N[(N[(N[Sin[x], $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[(t$95$0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \left(-\sin \varepsilon\right)\\
\mathbf{if}\;\varepsilon \leq -4.5 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, t_0\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\left(\sin x + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, t_0 - \cos x\right)\\
\end{array}
\end{array}
if eps < -4.50000000000000028e-5Initial program 49.8%
cos-sum98.8%
cancel-sign-sub-inv98.8%
fma-def98.9%
Applied egg-rr98.9%
if -4.50000000000000028e-5 < eps < 5.00000000000000024e-5Initial program 24.8%
diff-cos41.3%
div-inv41.3%
associate--l+41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
associate-+l+41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
+-commutative41.3%
count-241.3%
fma-def41.3%
sub-neg41.3%
mul-1-neg41.3%
+-commutative41.3%
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.5%
associate-*r*99.5%
Simplified99.5%
if 5.00000000000000024e-5 < eps Initial program 52.5%
sub-neg52.5%
cos-sum99.0%
associate-+l-99.0%
fma-neg99.2%
Applied egg-rr99.2%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -2.4e-5)
(- (fma (cos x) (cos eps) (* (sin x) (- (sin eps)))) (cos x))
(if (<= eps 4.5e-5)
(* (+ (sin x) (* (cos x) (* eps 0.5))) (* -2.0 (sin (* eps 0.5))))
(- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -2.4e-5) {
tmp = fma(cos(x), cos(eps), (sin(x) * -sin(eps))) - cos(x);
} else if (eps <= 4.5e-5) {
tmp = (sin(x) + (cos(x) * (eps * 0.5))) * (-2.0 * sin((eps * 0.5)));
} else {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -2.4e-5) tmp = Float64(fma(cos(x), cos(eps), Float64(sin(x) * Float64(-sin(eps)))) - cos(x)); elseif (eps <= 4.5e-5) tmp = Float64(Float64(sin(x) + Float64(cos(x) * Float64(eps * 0.5))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); else tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -2.4e-5], 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, 4.5e-5], N[(N[(N[Sin[x], $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.4 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 4.5 \cdot 10^{-5}:\\
\;\;\;\;\left(\sin x + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\end{array}
\end{array}
if eps < -2.4000000000000001e-5Initial program 49.8%
cos-sum98.8%
cancel-sign-sub-inv98.8%
fma-def98.9%
Applied egg-rr98.9%
if -2.4000000000000001e-5 < eps < 4.50000000000000028e-5Initial program 24.8%
diff-cos41.3%
div-inv41.3%
associate--l+41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
associate-+l+41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
+-commutative41.3%
count-241.3%
fma-def41.3%
sub-neg41.3%
mul-1-neg41.3%
+-commutative41.3%
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.5%
associate-*r*99.5%
Simplified99.5%
if 4.50000000000000028e-5 < eps Initial program 52.5%
cos-sum99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 99.0%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))))
(if (<= eps -5.5e-5)
(- t_0 (fma (sin eps) (sin x) (cos x)))
(if (<= eps 5e-5)
(* (+ (sin x) (* (cos x) (* eps 0.5))) (* -2.0 (sin (* eps 0.5))))
(- t_0 (+ (cos x) (* (sin x) (sin eps))))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double tmp;
if (eps <= -5.5e-5) {
tmp = t_0 - fma(sin(eps), sin(x), cos(x));
} else if (eps <= 5e-5) {
tmp = (sin(x) + (cos(x) * (eps * 0.5))) * (-2.0 * sin((eps * 0.5)));
} else {
tmp = t_0 - (cos(x) + (sin(x) * sin(eps)));
}
return tmp;
}
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) tmp = 0.0 if (eps <= -5.5e-5) tmp = Float64(t_0 - fma(sin(eps), sin(x), cos(x))); elseif (eps <= 5e-5) tmp = Float64(Float64(sin(x) + Float64(cos(x) * Float64(eps * 0.5))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); else tmp = Float64(t_0 - Float64(cos(x) + Float64(sin(x) * sin(eps)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.5e-5], N[(t$95$0 - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e-5], N[(N[(N[Sin[x], $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -5.5 \cdot 10^{-5}:\\
\;\;\;\;t_0 - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\left(\sin x + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\end{array}
\end{array}
if eps < -5.5000000000000002e-5Initial program 49.8%
sub-neg49.8%
cos-sum98.8%
associate-+l-98.8%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg98.8%
*-commutative98.8%
*-commutative98.8%
fma-neg98.9%
remove-double-neg98.9%
Simplified98.9%
if -5.5000000000000002e-5 < eps < 5.00000000000000024e-5Initial program 24.8%
diff-cos41.3%
div-inv41.3%
associate--l+41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
associate-+l+41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
+-commutative41.3%
count-241.3%
fma-def41.3%
sub-neg41.3%
mul-1-neg41.3%
+-commutative41.3%
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.5%
associate-*r*99.5%
Simplified99.5%
if 5.00000000000000024e-5 < eps Initial program 52.5%
cos-sum99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 99.0%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.9e-5) (not (<= eps 4.5e-5))) (- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps)))) (* (+ (sin x) (* (cos x) (* eps 0.5))) (* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.9e-5) || !(eps <= 4.5e-5)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
} else {
tmp = (sin(x) + (cos(x) * (eps * 0.5))) * (-2.0 * sin((eps * 0.5)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-2.9d-5)) .or. (.not. (eps <= 4.5d-5))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
else
tmp = (sin(x) + (cos(x) * (eps * 0.5d0))) * ((-2.0d0) * sin((eps * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2.9e-5) || !(eps <= 4.5e-5)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
} else {
tmp = (Math.sin(x) + (Math.cos(x) * (eps * 0.5))) * (-2.0 * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.9e-5) or not (eps <= 4.5e-5): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps))) else: tmp = (math.sin(x) + (math.cos(x) * (eps * 0.5))) * (-2.0 * math.sin((eps * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.9e-5) || !(eps <= 4.5e-5)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); else tmp = Float64(Float64(sin(x) + Float64(cos(x) * Float64(eps * 0.5))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.9e-5) || ~((eps <= 4.5e-5))) tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps))); else tmp = (sin(x) + (cos(x) * (eps * 0.5))) * (-2.0 * sin((eps * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.9e-5], N[Not[LessEqual[eps, 4.5e-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[Sin[x], $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.9 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 4.5 \cdot 10^{-5}\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sin x + \cos x \cdot \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if eps < -2.9e-5 or 4.50000000000000028e-5 < eps Initial program 51.1%
cos-sum98.9%
Applied egg-rr98.9%
Taylor expanded in x around inf 98.9%
if -2.9e-5 < eps < 4.50000000000000028e-5Initial program 24.8%
diff-cos41.3%
div-inv41.3%
associate--l+41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
associate-+l+41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
+-commutative41.3%
count-241.3%
fma-def41.3%
sub-neg41.3%
mul-1-neg41.3%
+-commutative41.3%
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.5%
associate-*r*99.5%
Simplified99.5%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-15) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (* eps (- (sin (* 0.5 (fma 2.0 x eps)))))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-15) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = eps * -sin((0.5 * fma(2.0, x, eps)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-15) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(eps * Float64(-sin(Float64(0.5 * fma(2.0, x, eps))))); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-15], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-15}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.99999999999999999e-15Initial program 76.1%
diff-cos77.6%
div-inv77.6%
associate--l+77.6%
metadata-eval77.6%
div-inv77.6%
+-commutative77.6%
associate-+l+77.4%
metadata-eval77.4%
Applied egg-rr77.4%
associate-*r*77.4%
*-commutative77.4%
*-commutative77.4%
+-commutative77.4%
count-277.4%
fma-def77.4%
sub-neg77.4%
mul-1-neg77.4%
+-commutative77.4%
associate-+r+77.4%
mul-1-neg77.4%
sub-neg77.4%
+-inverses77.4%
remove-double-neg77.4%
mul-1-neg77.4%
sub-neg77.4%
neg-sub077.4%
mul-1-neg77.4%
remove-double-neg77.4%
Simplified77.4%
Taylor expanded in x around 0 78.0%
if -4.99999999999999999e-15 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.1%
diff-cos31.4%
div-inv31.4%
associate--l+31.4%
metadata-eval31.4%
div-inv31.4%
+-commutative31.4%
associate-+l+31.5%
metadata-eval31.5%
Applied egg-rr31.5%
associate-*r*31.5%
*-commutative31.5%
*-commutative31.5%
+-commutative31.5%
count-231.5%
fma-def31.5%
sub-neg31.5%
mul-1-neg31.5%
+-commutative31.5%
associate-+r+76.0%
mul-1-neg76.0%
sub-neg76.0%
+-inverses76.0%
remove-double-neg76.0%
mul-1-neg76.0%
sub-neg76.0%
neg-sub076.0%
mul-1-neg76.0%
remove-double-neg76.0%
Simplified76.0%
Taylor expanded in eps around 0 74.4%
mul-1-neg74.4%
Simplified74.4%
Final simplification75.5%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.0013)
(- (cos eps) (cos x))
(if (<= eps 1.12e-7)
(- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))
(* -2.0 (pow (sin (* eps 0.5)) 2.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.0013) {
tmp = cos(eps) - cos(x);
} else if (eps <= 1.12e-7) {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
} else {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.0013d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= 1.12d-7) then
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
else
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.0013) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 1.12e-7) {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.0013: tmp = math.cos(eps) - math.cos(x) elif eps <= 1.12e-7: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.0013) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 1.12e-7) tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); else tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.0013) tmp = cos(eps) - cos(x); elseif (eps <= 1.12e-7) tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.0013], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.12e-7], 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[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0013:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 1.12 \cdot 10^{-7}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if eps < -0.0012999999999999999Initial program 49.8%
Taylor expanded in x around 0 52.7%
if -0.0012999999999999999 < eps < 1.12e-7Initial program 24.5%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
if 1.12e-7 < eps Initial program 52.1%
diff-cos53.1%
div-inv53.1%
associate--l+53.1%
metadata-eval53.1%
div-inv53.1%
+-commutative53.1%
associate-+l+52.8%
metadata-eval52.8%
Applied egg-rr52.8%
associate-*r*52.8%
*-commutative52.8%
*-commutative52.8%
+-commutative52.8%
count-252.8%
fma-def52.8%
sub-neg52.8%
mul-1-neg52.8%
+-commutative52.8%
associate-+r+53.4%
mul-1-neg53.4%
sub-neg53.4%
+-inverses53.4%
remove-double-neg53.4%
mul-1-neg53.4%
sub-neg53.4%
neg-sub053.4%
mul-1-neg53.4%
remove-double-neg53.4%
Simplified53.4%
Taylor expanded in x around 0 54.7%
Final simplification77.2%
(FPCore (x eps) :precision binary64 (* (* -2.0 (sin (* eps 0.5))) (sin (* 0.5 (fma 2.0 x eps)))))
double code(double x, double eps) {
return (-2.0 * sin((eps * 0.5))) * sin((0.5 * fma(2.0, x, eps)));
}
function code(x, eps) return Float64(Float64(-2.0 * sin(Float64(eps * 0.5))) * sin(Float64(0.5 * fma(2.0, x, eps)))) end
code[x_, eps_] := N[(N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot \sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right)
\end{array}
Initial program 37.4%
diff-cos45.7%
div-inv45.7%
associate--l+45.7%
metadata-eval45.7%
div-inv45.7%
+-commutative45.7%
associate-+l+45.7%
metadata-eval45.7%
Applied egg-rr45.7%
associate-*r*45.7%
*-commutative45.7%
*-commutative45.7%
+-commutative45.7%
count-245.7%
fma-def45.7%
sub-neg45.7%
mul-1-neg45.7%
+-commutative45.7%
associate-+r+76.4%
mul-1-neg76.4%
sub-neg76.4%
+-inverses76.4%
remove-double-neg76.4%
mul-1-neg76.4%
sub-neg76.4%
neg-sub076.4%
mul-1-neg76.4%
remove-double-neg76.4%
Simplified76.4%
Final simplification76.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -4.9e-11) (not (<= x 1.4e-30)))
(* (sin x) (* -2.0 t_0))
(* -2.0 (pow t_0 2.0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((x <= -4.9e-11) || !(x <= 1.4e-30)) {
tmp = sin(x) * (-2.0 * t_0);
} else {
tmp = -2.0 * pow(t_0, 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin((eps * 0.5d0))
if ((x <= (-4.9d-11)) .or. (.not. (x <= 1.4d-30))) then
tmp = sin(x) * ((-2.0d0) * t_0)
else
tmp = (-2.0d0) * (t_0 ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps * 0.5));
double tmp;
if ((x <= -4.9e-11) || !(x <= 1.4e-30)) {
tmp = Math.sin(x) * (-2.0 * t_0);
} else {
tmp = -2.0 * Math.pow(t_0, 2.0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (x <= -4.9e-11) or not (x <= 1.4e-30): tmp = math.sin(x) * (-2.0 * t_0) else: tmp = -2.0 * math.pow(t_0, 2.0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if ((x <= -4.9e-11) || !(x <= 1.4e-30)) tmp = Float64(sin(x) * Float64(-2.0 * t_0)); else tmp = Float64(-2.0 * (t_0 ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); tmp = 0.0; if ((x <= -4.9e-11) || ~((x <= 1.4e-30))) tmp = sin(x) * (-2.0 * t_0); else tmp = -2.0 * (t_0 ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x, -4.9e-11], N[Not[LessEqual[x, 1.4e-30]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;x \leq -4.9 \cdot 10^{-11} \lor \neg \left(x \leq 1.4 \cdot 10^{-30}\right):\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -4.8999999999999999e-11 or 1.39999999999999994e-30 < x Initial program 9.0%
diff-cos8.2%
div-inv8.2%
associate--l+8.2%
metadata-eval8.2%
div-inv8.2%
+-commutative8.2%
associate-+l+8.2%
metadata-eval8.2%
Applied egg-rr8.2%
associate-*r*8.2%
*-commutative8.2%
*-commutative8.2%
+-commutative8.2%
count-28.2%
fma-def8.2%
sub-neg8.2%
mul-1-neg8.2%
+-commutative8.2%
associate-+r+59.1%
mul-1-neg59.1%
sub-neg59.1%
+-inverses59.1%
remove-double-neg59.1%
mul-1-neg59.1%
sub-neg59.1%
neg-sub059.1%
mul-1-neg59.1%
remove-double-neg59.1%
Simplified59.1%
Taylor expanded in eps around 0 57.9%
if -4.8999999999999999e-11 < x < 1.39999999999999994e-30Initial program 75.2%
diff-cos95.4%
div-inv95.4%
associate--l+95.4%
metadata-eval95.4%
div-inv95.4%
+-commutative95.4%
associate-+l+95.4%
metadata-eval95.4%
Applied egg-rr95.4%
associate-*r*95.4%
*-commutative95.4%
*-commutative95.4%
+-commutative95.4%
count-295.4%
fma-def95.4%
sub-neg95.4%
mul-1-neg95.4%
+-commutative95.4%
associate-+r+99.4%
mul-1-neg99.4%
sub-neg99.4%
+-inverses99.4%
remove-double-neg99.4%
mul-1-neg99.4%
sub-neg99.4%
neg-sub099.4%
mul-1-neg99.4%
remove-double-neg99.4%
Simplified99.4%
Taylor expanded in x around 0 91.7%
Final simplification72.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -4e-11) (not (<= x 6.9e-29))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -4e-11) || !(x <= 6.9e-29)) {
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 <= (-4d-11)) .or. (.not. (x <= 6.9d-29))) 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 <= -4e-11) || !(x <= 6.9e-29)) {
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 <= -4e-11) or not (x <= 6.9e-29): 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 <= -4e-11) || !(x <= 6.9e-29)) 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 <= -4e-11) || ~((x <= 6.9e-29))) 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, -4e-11], N[Not[LessEqual[x, 6.9e-29]], $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 -4 \cdot 10^{-11} \lor \neg \left(x \leq 6.9 \cdot 10^{-29}\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 < -3.99999999999999976e-11 or 6.9e-29 < x Initial program 8.3%
Taylor expanded in eps around 0 54.2%
mul-1-neg54.2%
*-commutative54.2%
distribute-rgt-neg-in54.2%
Simplified54.2%
if -3.99999999999999976e-11 < x < 6.9e-29Initial program 74.8%
diff-cos94.6%
div-inv94.6%
associate--l+94.6%
metadata-eval94.6%
div-inv94.6%
+-commutative94.6%
associate-+l+94.7%
metadata-eval94.7%
Applied egg-rr94.7%
associate-*r*94.7%
*-commutative94.7%
*-commutative94.7%
+-commutative94.7%
count-294.7%
fma-def94.7%
sub-neg94.7%
mul-1-neg94.7%
+-commutative94.7%
associate-+r+99.4%
mul-1-neg99.4%
sub-neg99.4%
+-inverses99.4%
remove-double-neg99.4%
mul-1-neg99.4%
sub-neg99.4%
neg-sub099.4%
mul-1-neg99.4%
remove-double-neg99.4%
Simplified99.4%
Taylor expanded in x around 0 91.0%
Final simplification70.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.9e-5) (not (<= eps 1.12e-7))) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.9e-5) || !(eps <= 1.12e-7)) {
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 ((eps <= (-1.9d-5)) .or. (.not. (eps <= 1.12d-7))) 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 ((eps <= -1.9e-5) || !(eps <= 1.12e-7)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.9e-5) or not (eps <= 1.12e-7): tmp = math.cos(eps) - math.cos(x) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.9e-5) || !(eps <= 1.12e-7)) 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 ((eps <= -1.9e-5) || ~((eps <= 1.12e-7))) tmp = cos(eps) - cos(x); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.9e-5], N[Not[LessEqual[eps, 1.12e-7]], $MachinePrecision]], 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}\;\varepsilon \leq -1.9 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 1.12 \cdot 10^{-7}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -1.9000000000000001e-5 or 1.12e-7 < eps Initial program 50.9%
Taylor expanded in x around 0 52.9%
if -1.9000000000000001e-5 < eps < 1.12e-7Initial program 24.5%
Taylor expanded in eps around 0 83.9%
mul-1-neg83.9%
*-commutative83.9%
distribute-rgt-neg-in83.9%
Simplified83.9%
Final simplification68.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.1e-10) (not (<= eps 0.00016))) (+ (cos eps) -1.0) (* -0.5 (pow eps 2.0))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-10) || !(eps <= 0.00016)) {
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 <= (-1.1d-10)) .or. (.not. (eps <= 0.00016d0))) 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 <= -1.1e-10) || !(eps <= 0.00016)) {
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 <= -1.1e-10) or not (eps <= 0.00016): 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 <= -1.1e-10) || !(eps <= 0.00016)) 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 <= -1.1e-10) || ~((eps <= 0.00016))) tmp = cos(eps) + -1.0; else tmp = -0.5 * (eps ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.1e-10], N[Not[LessEqual[eps, 0.00016]], $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 -1.1 \cdot 10^{-10} \lor \neg \left(\varepsilon \leq 0.00016\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2}\\
\end{array}
\end{array}
if eps < -1.09999999999999995e-10 or 1.60000000000000013e-4 < eps Initial program 50.7%
Taylor expanded in x around 0 51.5%
if -1.09999999999999995e-10 < eps < 1.60000000000000013e-4Initial program 24.9%
Taylor expanded in x around 0 24.9%
Taylor expanded in eps around 0 38.6%
Final simplification44.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.8e-6) (not (<= eps 1e-7))) (+ (cos eps) -1.0) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.8e-6) || !(eps <= 1e-7)) {
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.8d-6)) .or. (.not. (eps <= 1d-7))) 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.8e-6) || !(eps <= 1e-7)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.8e-6) or not (eps <= 1e-7): tmp = math.cos(eps) + -1.0 else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.8e-6) || !(eps <= 1e-7)) 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.8e-6) || ~((eps <= 1e-7))) tmp = cos(eps) + -1.0; else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.8e-6], N[Not[LessEqual[eps, 1e-7]], $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.8 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 10^{-7}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -1.79999999999999992e-6 or 9.9999999999999995e-8 < eps Initial program 50.9%
Taylor expanded in x around 0 51.8%
if -1.79999999999999992e-6 < eps < 9.9999999999999995e-8Initial program 24.5%
Taylor expanded in eps around 0 83.9%
mul-1-neg83.9%
*-commutative83.9%
distribute-rgt-neg-in83.9%
Simplified83.9%
Final simplification68.2%
(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.4%
Taylor expanded in x around 0 37.8%
Final simplification37.8%
(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.4%
Taylor expanded in x around 0 37.8%
log1p-expm1-u37.7%
log1p-udef37.7%
sub-neg37.7%
metadata-eval37.7%
Applied egg-rr37.7%
Taylor expanded in eps around 0 14.1%
Final simplification14.1%
herbie shell --seed 2023334
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))