
(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 16 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 eps) (- (sin x)))))
(if (<= eps -0.0055)
(fma (cos x) (+ -1.0 (cos eps)) t_0)
(if (<= eps 0.0042)
(-
(*
(cos x)
(fma 0.041666666666666664 (pow eps 4.0) (* -0.5 (* eps eps))))
(* (sin eps) (sin x)))
(- (fma (cos x) (cos eps) t_0) (cos x))))))
double code(double x, double eps) {
double t_0 = sin(eps) * -sin(x);
double tmp;
if (eps <= -0.0055) {
tmp = fma(cos(x), (-1.0 + cos(eps)), t_0);
} else if (eps <= 0.0042) {
tmp = (cos(x) * fma(0.041666666666666664, pow(eps, 4.0), (-0.5 * (eps * eps)))) - (sin(eps) * sin(x));
} else {
tmp = fma(cos(x), cos(eps), t_0) - cos(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) * Float64(-sin(x))) tmp = 0.0 if (eps <= -0.0055) tmp = fma(cos(x), Float64(-1.0 + cos(eps)), t_0); elseif (eps <= 0.0042) tmp = Float64(Float64(cos(x) * fma(0.041666666666666664, (eps ^ 4.0), Float64(-0.5 * Float64(eps * eps)))) - Float64(sin(eps) * sin(x))); else tmp = Float64(fma(cos(x), cos(eps), t_0) - cos(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[eps, -0.0055], N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[eps, 0.0042], N[(N[(N[Cos[x], $MachinePrecision] * N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision] + N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + t$95$0), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \left(-\sin x\right)\\
\mathbf{if}\;\varepsilon \leq -0.0055:\\
\;\;\;\;\mathsf{fma}\left(\cos x, -1 + \cos \varepsilon, t_0\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0042:\\
\;\;\;\;\cos x \cdot \mathsf{fma}\left(0.041666666666666664, {\varepsilon}^{4}, -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, t_0\right) - \cos x\\
\end{array}
\end{array}
if eps < -0.0054999999999999997Initial program 51.8%
sub-neg51.8%
cos-sum98.9%
associate-+l-99.0%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg99.0%
*-commutative99.0%
*-commutative99.0%
fma-neg99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in eps around inf 99.0%
*-commutative99.0%
associate--r+98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
fma-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
if -0.0054999999999999997 < eps < 0.00419999999999999974Initial program 20.5%
sub-neg20.5%
cos-sum22.3%
associate-+l-22.3%
fma-neg22.3%
Applied egg-rr22.3%
fma-neg22.3%
*-commutative22.3%
*-commutative22.3%
fma-neg22.3%
remove-double-neg22.3%
Simplified22.3%
Taylor expanded in eps around inf 22.3%
*-commutative22.3%
associate--r+80.0%
*-commutative80.0%
*-rgt-identity80.0%
distribute-lft-out--80.0%
sub-neg80.0%
metadata-eval80.0%
+-commutative80.0%
Simplified80.0%
Taylor expanded in eps around 0 99.8%
fma-def99.8%
unpow299.8%
Simplified99.8%
if 0.00419999999999999974 < eps Initial program 47.8%
cos-sum98.9%
cancel-sign-sub-inv98.9%
fma-def99.0%
Applied egg-rr99.0%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (- (* (cos x) (/ (pow (sin eps) 2.0) (- -1.0 (cos eps)))) (* (sin eps) (sin x))))
double code(double x, double eps) {
return (cos(x) * (pow(sin(eps), 2.0) / (-1.0 - cos(eps)))) - (sin(eps) * sin(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (cos(x) * ((sin(eps) ** 2.0d0) / ((-1.0d0) - cos(eps)))) - (sin(eps) * sin(x))
end function
public static double code(double x, double eps) {
return (Math.cos(x) * (Math.pow(Math.sin(eps), 2.0) / (-1.0 - Math.cos(eps)))) - (Math.sin(eps) * Math.sin(x));
}
def code(x, eps): return (math.cos(x) * (math.pow(math.sin(eps), 2.0) / (-1.0 - math.cos(eps)))) - (math.sin(eps) * math.sin(x))
function code(x, eps) return Float64(Float64(cos(x) * Float64((sin(eps) ^ 2.0) / Float64(-1.0 - cos(eps)))) - Float64(sin(eps) * sin(x))) end
function tmp = code(x, eps) tmp = (cos(x) * ((sin(eps) ^ 2.0) / (-1.0 - cos(eps)))) - (sin(eps) * sin(x)); end
code[x_, eps_] := N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Power[N[Sin[eps], $MachinePrecision], 2.0], $MachinePrecision] / N[(-1.0 - N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{{\sin \varepsilon}^{2}}{-1 - \cos \varepsilon} - \sin \varepsilon \cdot \sin x
\end{array}
Initial program 34.8%
sub-neg34.8%
cos-sum59.4%
associate-+l-59.4%
fma-neg59.4%
Applied egg-rr59.4%
fma-neg59.4%
*-commutative59.4%
*-commutative59.4%
fma-neg59.4%
remove-double-neg59.4%
Simplified59.4%
Taylor expanded in eps around inf 59.4%
*-commutative59.4%
associate--r+89.1%
*-commutative89.1%
*-rgt-identity89.1%
distribute-lft-out--89.1%
sub-neg89.1%
metadata-eval89.1%
+-commutative89.1%
Simplified89.1%
flip-+88.7%
metadata-eval88.7%
Applied egg-rr88.7%
1-sub-cos99.2%
unpow299.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))) (t_1 (* (sin eps) (sin x))))
(if (<= eps -0.0055)
(fma (cos x) t_0 (* (sin eps) (- (sin x))))
(if (<= eps 0.00375)
(-
(*
(cos x)
(fma 0.041666666666666664 (pow eps 4.0) (* -0.5 (* eps eps))))
t_1)
(- (* (cos x) t_0) t_1)))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double t_1 = sin(eps) * sin(x);
double tmp;
if (eps <= -0.0055) {
tmp = fma(cos(x), t_0, (sin(eps) * -sin(x)));
} else if (eps <= 0.00375) {
tmp = (cos(x) * fma(0.041666666666666664, pow(eps, 4.0), (-0.5 * (eps * eps)))) - t_1;
} else {
tmp = (cos(x) * t_0) - t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) t_1 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -0.0055) tmp = fma(cos(x), t_0, Float64(sin(eps) * Float64(-sin(x)))); elseif (eps <= 0.00375) tmp = Float64(Float64(cos(x) * fma(0.041666666666666664, (eps ^ 4.0), Float64(-0.5 * Float64(eps * eps)))) - t_1); else tmp = Float64(Float64(cos(x) * t_0) - t_1); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0055], N[(N[Cos[x], $MachinePrecision] * t$95$0 + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00375], N[(N[(N[Cos[x], $MachinePrecision] * N[(0.041666666666666664 * N[Power[eps, 4.0], $MachinePrecision] + N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
t_1 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.0055:\\
\;\;\;\;\mathsf{fma}\left(\cos x, t_0, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00375:\\
\;\;\;\;\cos x \cdot \mathsf{fma}\left(0.041666666666666664, {\varepsilon}^{4}, -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot t_0 - t_1\\
\end{array}
\end{array}
if eps < -0.0054999999999999997Initial program 51.8%
sub-neg51.8%
cos-sum98.9%
associate-+l-99.0%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg99.0%
*-commutative99.0%
*-commutative99.0%
fma-neg99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in eps around inf 99.0%
*-commutative99.0%
associate--r+98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
fma-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
if -0.0054999999999999997 < eps < 0.0037499999999999999Initial program 20.5%
sub-neg20.5%
cos-sum22.3%
associate-+l-22.3%
fma-neg22.3%
Applied egg-rr22.3%
fma-neg22.3%
*-commutative22.3%
*-commutative22.3%
fma-neg22.3%
remove-double-neg22.3%
Simplified22.3%
Taylor expanded in eps around inf 22.3%
*-commutative22.3%
associate--r+80.0%
*-commutative80.0%
*-rgt-identity80.0%
distribute-lft-out--80.0%
sub-neg80.0%
metadata-eval80.0%
+-commutative80.0%
Simplified80.0%
Taylor expanded in eps around 0 99.8%
fma-def99.8%
unpow299.8%
Simplified99.8%
if 0.0037499999999999999 < eps Initial program 47.8%
sub-neg47.8%
cos-sum98.9%
associate-+l-98.9%
fma-neg98.8%
Applied egg-rr98.8%
fma-neg98.9%
*-commutative98.9%
*-commutative98.9%
fma-neg98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
*-commutative98.9%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))) (t_1 (+ -1.0 (cos eps))))
(if (<= eps -0.00017)
(fma (cos x) t_1 (* (sin eps) (- (sin x))))
(if (<= eps 0.00018)
(- (* (cos x) (* -0.5 (* eps eps))) t_0)
(- (* (cos x) t_1) t_0)))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double t_1 = -1.0 + cos(eps);
double tmp;
if (eps <= -0.00017) {
tmp = fma(cos(x), t_1, (sin(eps) * -sin(x)));
} else if (eps <= 0.00018) {
tmp = (cos(x) * (-0.5 * (eps * eps))) - t_0;
} else {
tmp = (cos(x) * t_1) - t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) t_1 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -0.00017) tmp = fma(cos(x), t_1, Float64(sin(eps) * Float64(-sin(x)))); elseif (eps <= 0.00018) tmp = Float64(Float64(cos(x) * Float64(-0.5 * Float64(eps * eps))) - t_0); else tmp = Float64(Float64(cos(x) * t_1) - t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00017], N[(N[Cos[x], $MachinePrecision] * t$95$1 + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00018], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
t_1 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.00017:\\
\;\;\;\;\mathsf{fma}\left(\cos x, t_1, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00018:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot t_1 - t_0\\
\end{array}
\end{array}
if eps < -1.7e-4Initial program 51.8%
sub-neg51.8%
cos-sum98.9%
associate-+l-99.0%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg99.0%
*-commutative99.0%
*-commutative99.0%
fma-neg99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in eps around inf 99.0%
*-commutative99.0%
associate--r+98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
fma-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
if -1.7e-4 < eps < 1.80000000000000011e-4Initial program 20.6%
sub-neg20.6%
cos-sum21.8%
associate-+l-21.8%
fma-neg21.8%
Applied egg-rr21.8%
fma-neg21.8%
*-commutative21.8%
*-commutative21.8%
fma-neg21.8%
remove-double-neg21.8%
Simplified21.8%
Taylor expanded in eps around inf 21.8%
*-commutative21.8%
associate--r+79.9%
*-commutative79.9%
*-rgt-identity79.9%
distribute-lft-out--79.9%
sub-neg79.9%
metadata-eval79.9%
+-commutative79.9%
Simplified79.9%
Taylor expanded in eps around 0 99.6%
unpow299.7%
Simplified99.7%
if 1.80000000000000011e-4 < eps Initial program 47.0%
sub-neg47.0%
cos-sum98.7%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
fma-neg98.7%
*-commutative98.7%
*-commutative98.7%
fma-neg98.7%
remove-double-neg98.7%
Simplified98.7%
Taylor expanded in eps around inf 98.7%
*-commutative98.7%
associate--r+98.7%
*-commutative98.7%
*-rgt-identity98.7%
distribute-lft-out--98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ x eps)) (cos x)) -5e-12) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (- (* -0.5 (* eps (* (cos x) eps))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((x + eps)) - cos(x)) <= -5e-12) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((x + eps)) - cos(x)) <= (-5d-12)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = ((-0.5d0) * (eps * (cos(x) * eps))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((x + eps)) - Math.cos(x)) <= -5e-12) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = (-0.5 * (eps * (Math.cos(x) * eps))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((x + eps)) - math.cos(x)) <= -5e-12: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = (-0.5 * (eps * (math.cos(x) * eps))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(x + eps)) - cos(x)) <= -5e-12) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(cos(x) * eps))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((x + eps)) - cos(x)) <= -5e-12) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(N[Cos[x], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(x + \varepsilon\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\cos x \cdot \varepsilon\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 73.2%
diff-cos74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
+-commutative74.4%
metadata-eval74.4%
Applied egg-rr74.4%
*-commutative74.4%
+-commutative74.4%
associate--l+74.4%
*-commutative74.4%
associate-+r+74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in x around 0 74.2%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.0%
Taylor expanded in eps around 0 75.4%
mul-1-neg75.4%
unsub-neg75.4%
unpow275.4%
associate-*l*75.4%
Simplified75.4%
Final simplification75.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (or (<= eps -0.00017) (not (<= eps 0.00018)))
(- (* (cos x) (+ -1.0 (cos eps))) t_0)
(- (* (cos x) (* -0.5 (* eps eps))) t_0))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.00018)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - t_0;
} else {
tmp = (cos(x) * (-0.5 * (eps * eps))) - t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin(eps) * sin(x)
if ((eps <= (-0.00017d0)) .or. (.not. (eps <= 0.00018d0))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - t_0
else
tmp = (cos(x) * ((-0.5d0) * (eps * eps))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) * Math.sin(x);
double tmp;
if ((eps <= -0.00017) || !(eps <= 0.00018)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - t_0;
} else {
tmp = (Math.cos(x) * (-0.5 * (eps * eps))) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) * math.sin(x) tmp = 0 if (eps <= -0.00017) or not (eps <= 0.00018): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - t_0 else: tmp = (math.cos(x) * (-0.5 * (eps * eps))) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if ((eps <= -0.00017) || !(eps <= 0.00018)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - t_0); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * Float64(eps * eps))) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) * sin(x); tmp = 0.0; if ((eps <= -0.00017) || ~((eps <= 0.00018))) tmp = (cos(x) * (-1.0 + cos(eps))) - t_0; else tmp = (cos(x) * (-0.5 * (eps * eps))) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.00017], N[Not[LessEqual[eps, 0.00018]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -0.00017 \lor \neg \left(\varepsilon \leq 0.00018\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - t_0\\
\end{array}
\end{array}
if eps < -1.7e-4 or 1.80000000000000011e-4 < eps Initial program 49.7%
sub-neg49.7%
cos-sum98.8%
associate-+l-98.9%
fma-neg98.8%
Applied egg-rr98.8%
fma-neg98.9%
*-commutative98.9%
*-commutative98.9%
fma-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around inf 98.9%
*-commutative98.9%
associate--r+98.8%
*-commutative98.8%
*-rgt-identity98.8%
distribute-lft-out--98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
if -1.7e-4 < eps < 1.80000000000000011e-4Initial program 20.6%
sub-neg20.6%
cos-sum21.8%
associate-+l-21.8%
fma-neg21.8%
Applied egg-rr21.8%
fma-neg21.8%
*-commutative21.8%
*-commutative21.8%
fma-neg21.8%
remove-double-neg21.8%
Simplified21.8%
Taylor expanded in eps around inf 21.8%
*-commutative21.8%
associate--r+79.9%
*-commutative79.9%
*-rgt-identity79.9%
distribute-lft-out--79.9%
sub-neg79.9%
metadata-eval79.9%
+-commutative79.9%
Simplified79.9%
Taylor expanded in eps around 0 99.6%
unpow299.7%
Simplified99.7%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ x eps)) (cos x)) -5e-12) (+ -1.0 (* (cos x) (cos eps))) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((cos((x + eps)) - cos(x)) <= -5e-12) {
tmp = -1.0 + (cos(x) * cos(eps));
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((x + eps)) - cos(x)) <= (-5d-12)) then
tmp = (-1.0d0) + (cos(x) * cos(eps))
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((x + eps)) - Math.cos(x)) <= -5e-12) {
tmp = -1.0 + (Math.cos(x) * Math.cos(eps));
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((x + eps)) - math.cos(x)) <= -5e-12: tmp = -1.0 + (math.cos(x) * math.cos(eps)) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(x + eps)) - cos(x)) <= -5e-12) tmp = Float64(-1.0 + Float64(cos(x) * cos(eps))); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((x + eps)) - cos(x)) <= -5e-12) tmp = -1.0 + (cos(x) * cos(eps)); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(-1.0 + N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(x + \varepsilon\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-1 + \cos x \cdot \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 73.2%
sub-neg73.2%
cos-sum98.4%
associate-+l-98.4%
fma-neg98.4%
Applied egg-rr98.4%
fma-neg98.4%
*-commutative98.4%
*-commutative98.4%
fma-neg98.4%
remove-double-neg98.4%
Simplified98.4%
Taylor expanded in x around 0 73.5%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.0%
Taylor expanded in eps around 0 60.4%
associate-*r*60.4%
mul-1-neg60.4%
Simplified60.4%
Final simplification64.5%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ x eps)) (cos x)) -5e-12) (+ -1.0 (cos eps)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((cos((x + eps)) - cos(x)) <= -5e-12) {
tmp = -1.0 + cos(eps);
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((x + eps)) - cos(x)) <= (-5d-12)) then
tmp = (-1.0d0) + cos(eps)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((x + eps)) - Math.cos(x)) <= -5e-12) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((x + eps)) - math.cos(x)) <= -5e-12: tmp = -1.0 + math.cos(eps) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(x + eps)) - cos(x)) <= -5e-12) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((x + eps)) - cos(x)) <= -5e-12) tmp = -1.0 + cos(eps); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(x + \varepsilon\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 73.2%
Taylor expanded in x around 0 73.3%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.0%
Taylor expanded in eps around 0 60.4%
associate-*r*60.4%
mul-1-neg60.4%
Simplified60.4%
Final simplification64.5%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.66e-85) (not (<= x 6000.0))) (* -2.0 (* (sin x) (sin (* 0.5 (+ eps (- x x)))))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -1.66e-85) || !(x <= 6000.0)) {
tmp = -2.0 * (sin(x) * sin((0.5 * (eps + (x - 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 <= (-1.66d-85)) .or. (.not. (x <= 6000.0d0))) then
tmp = (-2.0d0) * (sin(x) * sin((0.5d0 * (eps + (x - 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 <= -1.66e-85) || !(x <= 6000.0)) {
tmp = -2.0 * (Math.sin(x) * Math.sin((0.5 * (eps + (x - x)))));
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.66e-85) or not (x <= 6000.0): tmp = -2.0 * (math.sin(x) * math.sin((0.5 * (eps + (x - 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 <= -1.66e-85) || !(x <= 6000.0)) tmp = Float64(-2.0 * Float64(sin(x) * sin(Float64(0.5 * Float64(eps + Float64(x - 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 <= -1.66e-85) || ~((x <= 6000.0))) tmp = -2.0 * (sin(x) * sin((0.5 * (eps + (x - x))))); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.66e-85], N[Not[LessEqual[x, 6000.0]], $MachinePrecision]], N[(-2.0 * N[(N[Sin[x], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;x \leq -1.66 \cdot 10^{-85} \lor \neg \left(x \leq 6000\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if x < -1.66e-85 or 6e3 < x Initial program 11.1%
diff-cos10.7%
div-inv10.7%
metadata-eval10.7%
div-inv10.7%
+-commutative10.7%
metadata-eval10.7%
Applied egg-rr10.7%
*-commutative10.7%
+-commutative10.7%
associate--l+59.5%
*-commutative59.5%
associate-+r+59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in eps around 0 54.8%
if -1.66e-85 < x < 6e3Initial program 68.8%
diff-cos92.9%
div-inv92.9%
metadata-eval92.9%
div-inv92.9%
+-commutative92.9%
metadata-eval92.9%
Applied egg-rr92.9%
*-commutative92.9%
+-commutative92.9%
associate--l+98.7%
*-commutative98.7%
associate-+r+98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 92.7%
Final simplification70.3%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* 0.5 (- eps (* x -2.0)))) (sin (* eps 0.5)))))
double code(double x, double eps) {
return -2.0 * (sin((0.5 * (eps - (x * -2.0)))) * sin((eps * 0.5)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((0.5d0 * (eps - (x * (-2.0d0))))) * sin((eps * 0.5d0)))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((0.5 * (eps - (x * -2.0)))) * Math.sin((eps * 0.5)));
}
def code(x, eps): return -2.0 * (math.sin((0.5 * (eps - (x * -2.0)))) * math.sin((eps * 0.5)))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(0.5 * Float64(eps - Float64(x * -2.0)))) * sin(Float64(eps * 0.5)))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((0.5 * (eps - (x * -2.0)))) * sin((eps * 0.5))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(0.5 * N[(eps - N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon - x \cdot -2\right)\right) \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 34.8%
diff-cos44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
+-commutative44.4%
metadata-eval44.4%
Applied egg-rr44.4%
*-commutative44.4%
+-commutative44.4%
associate--l+75.6%
*-commutative75.6%
associate-+r+75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in x around -inf 75.7%
Final simplification75.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.6e-85) (not (<= x 82000000000000.0))) (* (sin x) (- eps)) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -1.6e-85) || !(x <= 82000000000000.0)) {
tmp = sin(x) * -eps;
} 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 <= (-1.6d-85)) .or. (.not. (x <= 82000000000000.0d0))) then
tmp = sin(x) * -eps
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 <= -1.6e-85) || !(x <= 82000000000000.0)) {
tmp = Math.sin(x) * -eps;
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.6e-85) or not (x <= 82000000000000.0): tmp = math.sin(x) * -eps else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.6e-85) || !(x <= 82000000000000.0)) tmp = Float64(sin(x) * Float64(-eps)); 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 <= -1.6e-85) || ~((x <= 82000000000000.0))) tmp = sin(x) * -eps; else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.6e-85], N[Not[LessEqual[x, 82000000000000.0]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * (-eps)), $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 -1.6 \cdot 10^{-85} \lor \neg \left(x \leq 82000000000000\right):\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if x < -1.60000000000000014e-85 or 8.2e13 < x Initial program 11.1%
Taylor expanded in eps around 0 52.7%
associate-*r*52.7%
mul-1-neg52.7%
Simplified52.7%
if -1.60000000000000014e-85 < x < 8.2e13Initial program 68.3%
diff-cos92.0%
div-inv92.0%
metadata-eval92.0%
div-inv92.0%
+-commutative92.0%
metadata-eval92.0%
Applied egg-rr92.0%
*-commutative92.0%
+-commutative92.0%
associate--l+97.8%
*-commutative97.8%
associate-+r+97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 91.9%
Final simplification68.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.000118) (not (<= eps 0.000165))) (+ -1.0 (cos eps)) (* eps (- (* eps -0.5) x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.000118) || !(eps <= 0.000165)) {
tmp = -1.0 + cos(eps);
} else {
tmp = eps * ((eps * -0.5) - 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.000118d0)) .or. (.not. (eps <= 0.000165d0))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = eps * ((eps * (-0.5d0)) - x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.000118) || !(eps <= 0.000165)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = eps * ((eps * -0.5) - x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.000118) or not (eps <= 0.000165): tmp = -1.0 + math.cos(eps) else: tmp = eps * ((eps * -0.5) - x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.000118) || !(eps <= 0.000165)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(eps * Float64(Float64(eps * -0.5) - x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.000118) || ~((eps <= 0.000165))) tmp = -1.0 + cos(eps); else tmp = eps * ((eps * -0.5) - x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.000118], N[Not[LessEqual[eps, 0.000165]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(eps * N[(N[(eps * -0.5), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.000118 \lor \neg \left(\varepsilon \leq 0.000165\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5 - x\right)\\
\end{array}
\end{array}
if eps < -1.18e-4 or 1.65e-4 < eps Initial program 49.7%
Taylor expanded in x around 0 49.8%
if -1.18e-4 < eps < 1.65e-4Initial program 20.6%
Taylor expanded in eps around 0 21.8%
associate-+r+21.7%
mul-1-neg21.7%
unsub-neg21.7%
associate-*r*21.7%
distribute-rgt1-in21.8%
unpow221.8%
associate-*r*21.8%
Simplified21.8%
Taylor expanded in x around 0 49.8%
+-commutative49.8%
mul-1-neg49.8%
unsub-neg49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in eps around 0 49.8%
unpow249.8%
neg-mul-149.8%
sub-neg49.8%
associate-*r*49.8%
*-commutative49.8%
distribute-rgt-out--49.8%
*-commutative49.8%
Simplified49.8%
Final simplification49.8%
(FPCore (x eps) :precision binary64 (if (<= x -2.2e-111) (* eps (- x)) (* -0.5 (* eps eps))))
double code(double x, double eps) {
double tmp;
if (x <= -2.2e-111) {
tmp = eps * -x;
} else {
tmp = -0.5 * (eps * eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2.2d-111)) then
tmp = eps * -x
else
tmp = (-0.5d0) * (eps * eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.2e-111) {
tmp = eps * -x;
} else {
tmp = -0.5 * (eps * eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.2e-111: tmp = eps * -x else: tmp = -0.5 * (eps * eps) return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.2e-111) tmp = Float64(eps * Float64(-x)); else tmp = Float64(-0.5 * Float64(eps * eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.2e-111) tmp = eps * -x; else tmp = -0.5 * (eps * eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.2e-111], N[(eps * (-x)), $MachinePrecision], N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{-111}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\end{array}
\end{array}
if x < -2.2e-111Initial program 19.3%
Taylor expanded in eps around 0 7.8%
associate-+r+7.8%
mul-1-neg7.8%
unsub-neg7.8%
associate-*r*7.8%
distribute-rgt1-in7.8%
unpow27.8%
associate-*r*7.8%
Simplified7.8%
Taylor expanded in x around 0 15.9%
+-commutative15.9%
mul-1-neg15.9%
unsub-neg15.9%
unpow215.9%
Simplified15.9%
Taylor expanded in eps around 0 15.6%
neg-mul-115.6%
distribute-rgt-neg-in15.6%
Simplified15.6%
if -2.2e-111 < x Initial program 42.9%
Taylor expanded in x around 0 42.4%
Taylor expanded in eps around 0 29.9%
*-commutative29.9%
unpow229.9%
Simplified29.9%
Final simplification25.0%
(FPCore (x eps) :precision binary64 (* eps (- (* eps -0.5) x)))
double code(double x, double eps) {
return eps * ((eps * -0.5) - x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((eps * (-0.5d0)) - x)
end function
public static double code(double x, double eps) {
return eps * ((eps * -0.5) - x);
}
def code(x, eps): return eps * ((eps * -0.5) - x)
function code(x, eps) return Float64(eps * Float64(Float64(eps * -0.5) - x)) end
function tmp = code(x, eps) tmp = eps * ((eps * -0.5) - x); end
code[x_, eps_] := N[(eps * N[(N[(eps * -0.5), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\varepsilon \cdot -0.5 - x\right)
\end{array}
Initial program 34.8%
Taylor expanded in eps around 0 13.3%
associate-+r+13.3%
mul-1-neg13.3%
unsub-neg13.3%
associate-*r*13.3%
distribute-rgt1-in13.3%
unpow213.3%
associate-*r*13.3%
Simplified13.3%
Taylor expanded in x around 0 26.9%
+-commutative26.9%
mul-1-neg26.9%
unsub-neg26.9%
unpow227.0%
Simplified27.0%
Taylor expanded in eps around 0 26.9%
unpow227.0%
neg-mul-127.0%
sub-neg27.0%
associate-*r*27.0%
*-commutative27.0%
distribute-rgt-out--27.1%
*-commutative27.1%
Simplified27.1%
Final simplification27.1%
(FPCore (x eps) :precision binary64 (* eps (- x)))
double code(double x, double eps) {
return eps * -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * -x
end function
public static double code(double x, double eps) {
return eps * -x;
}
def code(x, eps): return eps * -x
function code(x, eps) return Float64(eps * Float64(-x)) end
function tmp = code(x, eps) tmp = eps * -x; end
code[x_, eps_] := N[(eps * (-x)), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(-x\right)
\end{array}
Initial program 34.8%
Taylor expanded in eps around 0 13.3%
associate-+r+13.3%
mul-1-neg13.3%
unsub-neg13.3%
associate-*r*13.3%
distribute-rgt1-in13.3%
unpow213.3%
associate-*r*13.3%
Simplified13.3%
Taylor expanded in x around 0 26.9%
+-commutative26.9%
mul-1-neg26.9%
unsub-neg26.9%
unpow227.0%
Simplified27.0%
Taylor expanded in eps around 0 16.8%
neg-mul-116.8%
distribute-rgt-neg-in16.8%
Simplified16.8%
Final simplification16.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 34.8%
add-cube-cbrt34.3%
pow334.3%
Applied egg-rr34.3%
Taylor expanded in eps around 0 11.7%
pow-base-111.7%
*-rgt-identity11.7%
+-inverses11.7%
Simplified11.7%
Final simplification11.7%
herbie shell --seed 2023279
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))