
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (- (sin x)))))
(if (<= eps -0.00019)
(fma (cos x) (cos eps) (- t_0 (cos x)))
(if (<= eps 0.0002)
(*
(+
(* (cos x) (* eps 0.5))
(* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0)))
(* -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(eps) * -sin(x);
double tmp;
if (eps <= -0.00019) {
tmp = fma(cos(x), cos(eps), (t_0 - cos(x)));
} else if (eps <= 0.0002) {
tmp = ((cos(x) * (eps * 0.5)) + (sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0))) * (-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(eps) * Float64(-sin(x))) tmp = 0.0 if (eps <= -0.00019) tmp = fma(cos(x), cos(eps), Float64(t_0 - cos(x))); elseif (eps <= 0.0002) tmp = Float64(Float64(Float64(cos(x) * Float64(eps * 0.5)) + Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); 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.00019], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[(t$95$0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0002], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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] + 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.00019:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, t_0 - \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0002:\\
\;\;\;\;\left(\cos x \cdot \left(\varepsilon \cdot 0.5\right) + \sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\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\right) - \cos x\\
\end{array}
\end{array}
if eps < -1.9000000000000001e-4Initial program 58.9%
sub-neg58.9%
cos-sum98.9%
associate-+l-98.8%
fma-neg98.9%
Applied egg-rr98.9%
if -1.9000000000000001e-4 < eps < 2.0000000000000001e-4Initial program 18.5%
diff-cos37.9%
div-inv37.9%
associate--l+37.9%
metadata-eval37.9%
div-inv37.9%
+-commutative37.9%
associate-+l+37.9%
metadata-eval37.9%
Applied egg-rr37.9%
associate-*r*37.9%
*-commutative37.9%
*-commutative37.9%
+-commutative37.9%
count-237.9%
fma-def37.9%
sub-neg37.9%
mul-1-neg37.9%
+-commutative37.9%
associate-+r+98.8%
mul-1-neg98.8%
sub-neg98.8%
+-inverses98.8%
remove-double-neg98.8%
mul-1-neg98.8%
sub-neg98.8%
neg-sub098.8%
mul-1-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around 0 99.4%
associate-+r+99.4%
+-commutative99.4%
associate-*r*99.4%
associate-*r*99.4%
distribute-rgt1-in99.4%
Simplified99.4%
if 2.0000000000000001e-4 < eps Initial program 60.1%
cos-sum99.1%
cancel-sign-sub-inv99.1%
fma-def99.1%
Applied egg-rr99.1%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.0002) (not (<= eps 0.00021)))
(- (fma (cos x) (cos eps) (* (sin x) (- (sin eps)))) (cos x))
(*
(+ (* (cos x) (* eps 0.5)) (* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0)))
(* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0002) || !(eps <= 0.00021)) {
tmp = fma(cos(x), cos(eps), (sin(x) * -sin(eps))) - cos(x);
} else {
tmp = ((cos(x) * (eps * 0.5)) + (sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0))) * (-2.0 * sin((eps * 0.5)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -0.0002) || !(eps <= 0.00021)) tmp = Float64(fma(cos(x), cos(eps), Float64(sin(x) * Float64(-sin(eps)))) - cos(x)); else tmp = Float64(Float64(Float64(cos(x) * Float64(eps * 0.5)) + Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0002], N[Not[LessEqual[eps, 0.00021]], $MachinePrecision]], 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], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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 -0.0002 \lor \neg \left(\varepsilon \leq 0.00021\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right) - \cos x\\
\mathbf{else}:\\
\;\;\;\;\left(\cos x \cdot \left(\varepsilon \cdot 0.5\right) + \sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if eps < -2.0000000000000001e-4 or 2.1000000000000001e-4 < eps Initial program 59.5%
cos-sum99.0%
cancel-sign-sub-inv99.0%
fma-def99.0%
Applied egg-rr99.0%
if -2.0000000000000001e-4 < eps < 2.1000000000000001e-4Initial program 18.5%
diff-cos37.9%
div-inv37.9%
associate--l+37.9%
metadata-eval37.9%
div-inv37.9%
+-commutative37.9%
associate-+l+37.9%
metadata-eval37.9%
Applied egg-rr37.9%
associate-*r*37.9%
*-commutative37.9%
*-commutative37.9%
+-commutative37.9%
count-237.9%
fma-def37.9%
sub-neg37.9%
mul-1-neg37.9%
+-commutative37.9%
associate-+r+98.8%
mul-1-neg98.8%
sub-neg98.8%
+-inverses98.8%
remove-double-neg98.8%
mul-1-neg98.8%
sub-neg98.8%
neg-sub098.8%
mul-1-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around 0 99.4%
associate-+r+99.4%
+-commutative99.4%
associate-*r*99.4%
associate-*r*99.4%
distribute-rgt1-in99.4%
Simplified99.4%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.0002) (not (<= eps 0.00021)))
(- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps))))
(*
(+ (* (cos x) (* eps 0.5)) (* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0)))
(* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0002) || !(eps <= 0.00021)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
} else {
tmp = ((cos(x) * (eps * 0.5)) + (sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0))) * (-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 <= (-0.0002d0)) .or. (.not. (eps <= 0.00021d0))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
else
tmp = ((cos(x) * (eps * 0.5d0)) + (sin(x) * (((-0.125d0) * (eps ** 2.0d0)) + 1.0d0))) * ((-2.0d0) * sin((eps * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0002) || !(eps <= 0.00021)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
} else {
tmp = ((Math.cos(x) * (eps * 0.5)) + (Math.sin(x) * ((-0.125 * Math.pow(eps, 2.0)) + 1.0))) * (-2.0 * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0002) or not (eps <= 0.00021): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps))) else: tmp = ((math.cos(x) * (eps * 0.5)) + (math.sin(x) * ((-0.125 * math.pow(eps, 2.0)) + 1.0))) * (-2.0 * math.sin((eps * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0002) || !(eps <= 0.00021)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); else tmp = Float64(Float64(Float64(cos(x) * Float64(eps * 0.5)) + Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0002) || ~((eps <= 0.00021))) tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps))); else tmp = ((cos(x) * (eps * 0.5)) + (sin(x) * ((-0.125 * (eps ^ 2.0)) + 1.0))) * (-2.0 * sin((eps * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0002], N[Not[LessEqual[eps, 0.00021]], $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[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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 -0.0002 \lor \neg \left(\varepsilon \leq 0.00021\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\cos x \cdot \left(\varepsilon \cdot 0.5\right) + \sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if eps < -2.0000000000000001e-4 or 2.1000000000000001e-4 < eps Initial program 59.5%
cos-sum99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 98.9%
if -2.0000000000000001e-4 < eps < 2.1000000000000001e-4Initial program 18.5%
diff-cos37.9%
div-inv37.9%
associate--l+37.9%
metadata-eval37.9%
div-inv37.9%
+-commutative37.9%
associate-+l+37.9%
metadata-eval37.9%
Applied egg-rr37.9%
associate-*r*37.9%
*-commutative37.9%
*-commutative37.9%
+-commutative37.9%
count-237.9%
fma-def37.9%
sub-neg37.9%
mul-1-neg37.9%
+-commutative37.9%
associate-+r+98.8%
mul-1-neg98.8%
sub-neg98.8%
+-inverses98.8%
remove-double-neg98.8%
mul-1-neg98.8%
sub-neg98.8%
neg-sub098.8%
mul-1-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around 0 99.4%
associate-+r+99.4%
+-commutative99.4%
associate-*r*99.4%
associate-*r*99.4%
distribute-rgt1-in99.4%
Simplified99.4%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.0002) (not (<= eps 0.000205)))
(- (- (* (cos x) (cos eps)) (* (sin x) (sin eps))) (cos x))
(*
(+ (* (cos x) (* eps 0.5)) (* (sin x) (+ (* -0.125 (pow eps 2.0)) 1.0)))
(* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0002) || !(eps <= 0.000205)) {
tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
} else {
tmp = ((cos(x) * (eps * 0.5)) + (sin(x) * ((-0.125 * pow(eps, 2.0)) + 1.0))) * (-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 <= (-0.0002d0)) .or. (.not. (eps <= 0.000205d0))) then
tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x)
else
tmp = ((cos(x) * (eps * 0.5d0)) + (sin(x) * (((-0.125d0) * (eps ** 2.0d0)) + 1.0d0))) * ((-2.0d0) * sin((eps * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0002) || !(eps <= 0.000205)) {
tmp = ((Math.cos(x) * Math.cos(eps)) - (Math.sin(x) * Math.sin(eps))) - Math.cos(x);
} else {
tmp = ((Math.cos(x) * (eps * 0.5)) + (Math.sin(x) * ((-0.125 * Math.pow(eps, 2.0)) + 1.0))) * (-2.0 * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0002) or not (eps <= 0.000205): tmp = ((math.cos(x) * math.cos(eps)) - (math.sin(x) * math.sin(eps))) - math.cos(x) else: tmp = ((math.cos(x) * (eps * 0.5)) + (math.sin(x) * ((-0.125 * math.pow(eps, 2.0)) + 1.0))) * (-2.0 * math.sin((eps * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0002) || !(eps <= 0.000205)) tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - Float64(sin(x) * sin(eps))) - cos(x)); else tmp = Float64(Float64(Float64(cos(x) * Float64(eps * 0.5)) + Float64(sin(x) * Float64(Float64(-0.125 * (eps ^ 2.0)) + 1.0))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0002) || ~((eps <= 0.000205))) tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x); else tmp = ((cos(x) * (eps * 0.5)) + (sin(x) * ((-0.125 * (eps ^ 2.0)) + 1.0))) * (-2.0 * sin((eps * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0002], N[Not[LessEqual[eps, 0.000205]], $MachinePrecision]], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[(eps * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(-0.125 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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 -0.0002 \lor \neg \left(\varepsilon \leq 0.000205\right):\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{else}:\\
\;\;\;\;\left(\cos x \cdot \left(\varepsilon \cdot 0.5\right) + \sin x \cdot \left(-0.125 \cdot {\varepsilon}^{2} + 1\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if eps < -2.0000000000000001e-4 or 2.05e-4 < eps Initial program 59.5%
cos-sum99.0%
Applied egg-rr99.0%
if -2.0000000000000001e-4 < eps < 2.05e-4Initial program 18.5%
diff-cos37.9%
div-inv37.9%
associate--l+37.9%
metadata-eval37.9%
div-inv37.9%
+-commutative37.9%
associate-+l+37.9%
metadata-eval37.9%
Applied egg-rr37.9%
associate-*r*37.9%
*-commutative37.9%
*-commutative37.9%
+-commutative37.9%
count-237.9%
fma-def37.9%
sub-neg37.9%
mul-1-neg37.9%
+-commutative37.9%
associate-+r+98.8%
mul-1-neg98.8%
sub-neg98.8%
+-inverses98.8%
remove-double-neg98.8%
mul-1-neg98.8%
sub-neg98.8%
neg-sub098.8%
mul-1-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in eps around 0 99.4%
associate-+r+99.4%
+-commutative99.4%
associate-*r*99.4%
associate-*r*99.4%
distribute-rgt1-in99.4%
Simplified99.4%
Final simplification99.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 40.1%
diff-cos49.1%
div-inv49.1%
associate--l+49.1%
metadata-eval49.1%
div-inv49.1%
+-commutative49.1%
associate-+l+49.0%
metadata-eval49.0%
Applied egg-rr49.0%
associate-*r*49.0%
*-commutative49.0%
*-commutative49.0%
+-commutative49.0%
count-249.0%
fma-def49.0%
sub-neg49.0%
mul-1-neg49.0%
+-commutative49.0%
associate-+r+79.0%
mul-1-neg79.0%
sub-neg79.0%
+-inverses79.0%
remove-double-neg79.0%
mul-1-neg79.0%
sub-neg79.0%
neg-sub079.0%
mul-1-neg79.0%
remove-double-neg79.0%
Simplified79.0%
Final simplification79.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -1.32e-27) (not (<= x 5e-10)))
(* (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 <= -1.32e-27) || !(x <= 5e-10)) {
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 <= (-1.32d-27)) .or. (.not. (x <= 5d-10))) 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 <= -1.32e-27) || !(x <= 5e-10)) {
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 <= -1.32e-27) or not (x <= 5e-10): 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 <= -1.32e-27) || !(x <= 5e-10)) 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 <= -1.32e-27) || ~((x <= 5e-10))) 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, -1.32e-27], N[Not[LessEqual[x, 5e-10]], $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 -1.32 \cdot 10^{-27} \lor \neg \left(x \leq 5 \cdot 10^{-10}\right):\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -1.3200000000000001e-27 or 5.00000000000000031e-10 < x Initial program 6.0%
diff-cos5.6%
div-inv5.6%
associate--l+5.6%
metadata-eval5.6%
div-inv5.6%
+-commutative5.6%
associate-+l+5.3%
metadata-eval5.3%
Applied egg-rr5.3%
associate-*r*5.3%
*-commutative5.3%
*-commutative5.3%
+-commutative5.3%
count-25.3%
fma-def5.3%
sub-neg5.3%
mul-1-neg5.3%
+-commutative5.3%
associate-+r+58.5%
mul-1-neg58.5%
sub-neg58.5%
+-inverses58.5%
remove-double-neg58.5%
mul-1-neg58.5%
sub-neg58.5%
neg-sub058.5%
mul-1-neg58.5%
remove-double-neg58.5%
Simplified58.5%
Taylor expanded in eps around 0 58.5%
if -1.3200000000000001e-27 < x < 5.00000000000000031e-10Initial program 74.2%
diff-cos92.7%
div-inv92.7%
associate--l+92.7%
metadata-eval92.7%
div-inv92.7%
+-commutative92.7%
associate-+l+92.7%
metadata-eval92.7%
Applied egg-rr92.7%
associate-*r*92.7%
*-commutative92.7%
*-commutative92.7%
+-commutative92.7%
count-292.7%
fma-def92.7%
sub-neg92.7%
mul-1-neg92.7%
+-commutative92.7%
associate-+r+99.5%
mul-1-neg99.5%
sub-neg99.5%
+-inverses99.5%
remove-double-neg99.5%
mul-1-neg99.5%
sub-neg99.5%
neg-sub099.5%
mul-1-neg99.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in x around 0 91.0%
Final simplification74.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.9e-29) (not (<= x 1.02e-10))) (* (sin x) (* -2.0 (sin (* eps 0.5)))) (* (/ (sin eps) -1.0) (tan (/ eps 2.0)))))
double code(double x, double eps) {
double tmp;
if ((x <= -1.9e-29) || !(x <= 1.02e-10)) {
tmp = sin(x) * (-2.0 * sin((eps * 0.5)));
} else {
tmp = (sin(eps) / -1.0) * tan((eps / 2.0));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-1.9d-29)) .or. (.not. (x <= 1.02d-10))) then
tmp = sin(x) * ((-2.0d0) * sin((eps * 0.5d0)))
else
tmp = (sin(eps) / (-1.0d0)) * tan((eps / 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -1.9e-29) || !(x <= 1.02e-10)) {
tmp = Math.sin(x) * (-2.0 * Math.sin((eps * 0.5)));
} else {
tmp = (Math.sin(eps) / -1.0) * Math.tan((eps / 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.9e-29) or not (x <= 1.02e-10): tmp = math.sin(x) * (-2.0 * math.sin((eps * 0.5))) else: tmp = (math.sin(eps) / -1.0) * math.tan((eps / 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.9e-29) || !(x <= 1.02e-10)) tmp = Float64(sin(x) * Float64(-2.0 * sin(Float64(eps * 0.5)))); else tmp = Float64(Float64(sin(eps) / -1.0) * tan(Float64(eps / 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.9e-29) || ~((x <= 1.02e-10))) tmp = sin(x) * (-2.0 * sin((eps * 0.5))); else tmp = (sin(eps) / -1.0) * tan((eps / 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.9e-29], N[Not[LessEqual[x, 1.02e-10]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[eps], $MachinePrecision] / -1.0), $MachinePrecision] * N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-29} \lor \neg \left(x \leq 1.02 \cdot 10^{-10}\right):\\
\;\;\;\;\sin x \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin \varepsilon}{-1} \cdot \tan \left(\frac{\varepsilon}{2}\right)\\
\end{array}
\end{array}
if x < -1.89999999999999988e-29 or 1.01999999999999997e-10 < x Initial program 6.0%
diff-cos5.6%
div-inv5.6%
associate--l+5.6%
metadata-eval5.6%
div-inv5.6%
+-commutative5.6%
associate-+l+5.3%
metadata-eval5.3%
Applied egg-rr5.3%
associate-*r*5.3%
*-commutative5.3%
*-commutative5.3%
+-commutative5.3%
count-25.3%
fma-def5.3%
sub-neg5.3%
mul-1-neg5.3%
+-commutative5.3%
associate-+r+58.5%
mul-1-neg58.5%
sub-neg58.5%
+-inverses58.5%
remove-double-neg58.5%
mul-1-neg58.5%
sub-neg58.5%
neg-sub058.5%
mul-1-neg58.5%
remove-double-neg58.5%
Simplified58.5%
Taylor expanded in eps around 0 58.5%
if -1.89999999999999988e-29 < x < 1.01999999999999997e-10Initial program 74.2%
Taylor expanded in x around 0 74.2%
flip--73.6%
frac-2neg73.6%
metadata-eval73.6%
sub-1-cos90.4%
pow290.4%
Applied egg-rr90.4%
remove-double-neg90.4%
unpow290.4%
neg-mul-190.4%
times-frac90.4%
+-commutative90.4%
hang-0p-tan91.1%
Simplified91.1%
Final simplification74.8%
(FPCore (x eps) :precision binary64 (if (or (<= x -3e-27) (not (<= x 2.2e-8))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -3e-27) || !(x <= 2.2e-8)) {
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 <= (-3d-27)) .or. (.not. (x <= 2.2d-8))) 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 <= -3e-27) || !(x <= 2.2e-8)) {
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 <= -3e-27) or not (x <= 2.2e-8): 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 <= -3e-27) || !(x <= 2.2e-8)) 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 <= -3e-27) || ~((x <= 2.2e-8))) 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, -3e-27], N[Not[LessEqual[x, 2.2e-8]], $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 -3 \cdot 10^{-27} \lor \neg \left(x \leq 2.2 \cdot 10^{-8}\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.0000000000000001e-27 or 2.1999999999999998e-8 < x Initial program 6.0%
Taylor expanded in eps around 0 55.2%
mul-1-neg55.2%
*-commutative55.2%
distribute-rgt-neg-in55.2%
Simplified55.2%
if -3.0000000000000001e-27 < x < 2.1999999999999998e-8Initial program 74.2%
diff-cos92.7%
div-inv92.7%
associate--l+92.7%
metadata-eval92.7%
div-inv92.7%
+-commutative92.7%
associate-+l+92.7%
metadata-eval92.7%
Applied egg-rr92.7%
associate-*r*92.7%
*-commutative92.7%
*-commutative92.7%
+-commutative92.7%
count-292.7%
fma-def92.7%
sub-neg92.7%
mul-1-neg92.7%
+-commutative92.7%
associate-+r+99.5%
mul-1-neg99.5%
sub-neg99.5%
+-inverses99.5%
remove-double-neg99.5%
mul-1-neg99.5%
sub-neg99.5%
neg-sub099.5%
mul-1-neg99.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in x around 0 91.0%
Final simplification73.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -5.6e-6) (not (<= eps 6e-5))) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -5.6e-6) || !(eps <= 6e-5)) {
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 <= (-5.6d-6)) .or. (.not. (eps <= 6d-5))) 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 <= -5.6e-6) || !(eps <= 6e-5)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -5.6e-6) or not (eps <= 6e-5): tmp = math.cos(eps) - math.cos(x) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -5.6e-6) || !(eps <= 6e-5)) 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 <= -5.6e-6) || ~((eps <= 6e-5))) tmp = cos(eps) - cos(x); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -5.6e-6], N[Not[LessEqual[eps, 6e-5]], $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 -5.6 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 6 \cdot 10^{-5}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -5.59999999999999975e-6 or 6.00000000000000015e-5 < eps Initial program 59.4%
Taylor expanded in x around 0 62.1%
if -5.59999999999999975e-6 < eps < 6.00000000000000015e-5Initial program 17.9%
Taylor expanded in eps around 0 80.2%
mul-1-neg80.2%
*-commutative80.2%
distribute-rgt-neg-in80.2%
Simplified80.2%
Final simplification70.5%
(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 40.1%
expm1-log1p-u25.3%
Applied egg-rr25.3%
expm1-log1p-u40.1%
diff-cos49.1%
*-commutative49.1%
div-inv49.1%
+-commutative49.1%
associate--l+79.1%
metadata-eval79.1%
div-inv79.1%
+-commutative79.1%
associate-+l+79.0%
metadata-eval79.0%
Applied egg-rr79.0%
Taylor expanded in x around -inf 79.0%
Final simplification79.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* (pow eps 2.0) -0.5)))
(if (<= eps -0.000145)
t_0
(if (<= eps -4.4e-95)
t_1
(if (<= eps 2.9e-166) (* x (- eps)) (if (<= eps 1.55e-10) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = pow(eps, 2.0) * -0.5;
double tmp;
if (eps <= -0.000145) {
tmp = t_0;
} else if (eps <= -4.4e-95) {
tmp = t_1;
} else if (eps <= 2.9e-166) {
tmp = x * -eps;
} else if (eps <= 1.55e-10) {
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 = (eps ** 2.0d0) * (-0.5d0)
if (eps <= (-0.000145d0)) then
tmp = t_0
else if (eps <= (-4.4d-95)) then
tmp = t_1
else if (eps <= 2.9d-166) then
tmp = x * -eps
else if (eps <= 1.55d-10) 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 = Math.pow(eps, 2.0) * -0.5;
double tmp;
if (eps <= -0.000145) {
tmp = t_0;
} else if (eps <= -4.4e-95) {
tmp = t_1;
} else if (eps <= 2.9e-166) {
tmp = x * -eps;
} else if (eps <= 1.55e-10) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = math.pow(eps, 2.0) * -0.5 tmp = 0 if eps <= -0.000145: tmp = t_0 elif eps <= -4.4e-95: tmp = t_1 elif eps <= 2.9e-166: tmp = x * -eps elif eps <= 1.55e-10: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64((eps ^ 2.0) * -0.5) tmp = 0.0 if (eps <= -0.000145) tmp = t_0; elseif (eps <= -4.4e-95) tmp = t_1; elseif (eps <= 2.9e-166) tmp = Float64(x * Float64(-eps)); elseif (eps <= 1.55e-10) 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 = (eps ^ 2.0) * -0.5; tmp = 0.0; if (eps <= -0.000145) tmp = t_0; elseif (eps <= -4.4e-95) tmp = t_1; elseif (eps <= 2.9e-166) tmp = x * -eps; elseif (eps <= 1.55e-10) 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[(N[Power[eps, 2.0], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[eps, -0.000145], t$95$0, If[LessEqual[eps, -4.4e-95], t$95$1, If[LessEqual[eps, 2.9e-166], N[(x * (-eps)), $MachinePrecision], If[LessEqual[eps, 1.55e-10], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := {\varepsilon}^{2} \cdot -0.5\\
\mathbf{if}\;\varepsilon \leq -0.000145:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -4.4 \cdot 10^{-95}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 2.9 \cdot 10^{-166}:\\
\;\;\;\;x \cdot \left(-\varepsilon\right)\\
\mathbf{elif}\;\varepsilon \leq 1.55 \cdot 10^{-10}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.45e-4 or 1.55000000000000008e-10 < eps Initial program 58.6%
Taylor expanded in x around 0 60.0%
if -1.45e-4 < eps < -4.3999999999999998e-95 or 2.9e-166 < eps < 1.55000000000000008e-10Initial program 7.3%
Taylor expanded in x around 0 7.3%
Taylor expanded in eps around 0 40.7%
if -4.3999999999999998e-95 < eps < 2.9e-166Initial program 30.8%
cos-sum30.8%
Applied egg-rr30.8%
Taylor expanded in x around 0 30.1%
Taylor expanded in eps around 0 44.3%
associate-*r*44.3%
mul-1-neg44.3%
Simplified44.3%
Final simplification51.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.1e-6) (not (<= eps 1.1e-5))) (+ (cos eps) -1.0) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.1e-6) || !(eps <= 1.1e-5)) {
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 <= (-3.1d-6)) .or. (.not. (eps <= 1.1d-5))) 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 <= -3.1e-6) || !(eps <= 1.1e-5)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.1e-6) or not (eps <= 1.1e-5): tmp = math.cos(eps) + -1.0 else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.1e-6) || !(eps <= 1.1e-5)) 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 <= -3.1e-6) || ~((eps <= 1.1e-5))) tmp = cos(eps) + -1.0; else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.1e-6], N[Not[LessEqual[eps, 1.1e-5]], $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 -3.1 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 1.1 \cdot 10^{-5}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -3.1e-6 or 1.1e-5 < eps Initial program 59.4%
Taylor expanded in x around 0 60.7%
if -3.1e-6 < eps < 1.1e-5Initial program 17.9%
Taylor expanded in eps around 0 80.2%
mul-1-neg80.2%
*-commutative80.2%
distribute-rgt-neg-in80.2%
Simplified80.2%
Final simplification69.7%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.7e-22) (not (<= eps 1.25e-25))) (+ (cos eps) -1.0) (* x (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.7e-22) || !(eps <= 1.25e-25)) {
tmp = cos(eps) + -1.0;
} else {
tmp = x * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.7d-22)) .or. (.not. (eps <= 1.25d-25))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = x * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.7e-22) || !(eps <= 1.25e-25)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = x * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.7e-22) or not (eps <= 1.25e-25): tmp = math.cos(eps) + -1.0 else: tmp = x * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.7e-22) || !(eps <= 1.25e-25)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(x * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.7e-22) || ~((eps <= 1.25e-25))) tmp = cos(eps) + -1.0; else tmp = x * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.7e-22], N[Not[LessEqual[eps, 1.25e-25]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(x * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.7 \cdot 10^{-22} \lor \neg \left(\varepsilon \leq 1.25 \cdot 10^{-25}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -3.7e-22 or 1.2499999999999999e-25 < eps Initial program 56.6%
Taylor expanded in x around 0 57.9%
if -3.7e-22 < eps < 1.2499999999999999e-25Initial program 18.8%
cos-sum18.8%
Applied egg-rr18.8%
Taylor expanded in x around 0 18.4%
Taylor expanded in eps around 0 29.3%
associate-*r*29.3%
mul-1-neg29.3%
Simplified29.3%
Final simplification45.4%
(FPCore (x eps) :precision binary64 (* x (- eps)))
double code(double x, double eps) {
return x * -eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = x * -eps
end function
public static double code(double x, double eps) {
return x * -eps;
}
def code(x, eps): return x * -eps
function code(x, eps) return Float64(x * Float64(-eps)) end
function tmp = code(x, eps) tmp = x * -eps; end
code[x_, eps_] := N[(x * (-eps)), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-\varepsilon\right)
\end{array}
Initial program 40.1%
cos-sum61.6%
Applied egg-rr61.6%
Taylor expanded in x around 0 39.1%
Taylor expanded in eps around 0 14.5%
associate-*r*14.5%
mul-1-neg14.5%
Simplified14.5%
Final simplification14.5%
(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 40.1%
add-cube-cbrt39.8%
pow339.8%
Applied egg-rr39.8%
Taylor expanded in eps around 0 10.0%
pow-base-110.0%
*-lft-identity10.0%
+-inverses10.0%
Simplified10.0%
Final simplification10.0%
herbie shell --seed 2024021
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))