
(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 (* 0.5 eps)))) (* (fma (cos x) t_0 (* (sin x) (cos (* eps -0.5)))) (* t_0 -2.0))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return fma(cos(x), t_0, (sin(x) * cos((eps * -0.5)))) * (t_0 * -2.0);
}
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(fma(cos(x), t_0, Float64(sin(x) * cos(Float64(eps * -0.5)))) * Float64(t_0 * -2.0)) end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[Cos[x], $MachinePrecision] * t$95$0 + N[(N[Sin[x], $MachinePrecision] * N[Cos[N[(eps * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
\mathsf{fma}\left(\cos x, t_0, \sin x \cdot \cos \left(\varepsilon \cdot -0.5\right)\right) \cdot \left(t_0 \cdot -2\right)
\end{array}
\end{array}
Initial program 38.2%
diff-cos44.5%
div-inv44.5%
metadata-eval44.5%
div-inv44.5%
+-commutative44.5%
metadata-eval44.5%
Applied egg-rr44.5%
*-commutative44.5%
+-commutative44.5%
associate--l+74.2%
+-inverses74.2%
distribute-lft-in74.2%
metadata-eval74.2%
*-commutative74.2%
+-commutative74.2%
Simplified74.2%
Taylor expanded in x around 0 74.6%
sin-sum99.4%
Applied egg-rr99.4%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in eps around inf 99.4%
*-commutative99.4%
*-commutative99.4%
*-commutative99.4%
fma-def99.5%
*-commutative99.5%
associate-*l*99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (+ (* (cos x) t_0) (* (sin x) (cos (* 0.5 eps))))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * ((cos(x) * t_0) + (sin(x) * cos((0.5 * eps)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = sin((0.5d0 * eps))
code = (-2.0d0) * (t_0 * ((cos(x) * t_0) + (sin(x) * cos((0.5d0 * eps)))))
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((0.5 * eps));
return -2.0 * (t_0 * ((Math.cos(x) * t_0) + (Math.sin(x) * Math.cos((0.5 * eps)))));
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) return -2.0 * (t_0 * ((math.cos(x) * t_0) + (math.sin(x) * math.cos((0.5 * eps)))))
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * Float64(Float64(cos(x) * t_0) + Float64(sin(x) * cos(Float64(0.5 * eps)))))) end
function tmp = code(x, eps) t_0 = sin((0.5 * eps)); tmp = -2.0 * (t_0 * ((cos(x) * t_0) + (sin(x) * cos((0.5 * eps))))); end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[(N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
-2 \cdot \left(t_0 \cdot \left(\cos x \cdot t_0 + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)\right)
\end{array}
\end{array}
Initial program 38.2%
diff-cos44.5%
div-inv44.5%
metadata-eval44.5%
div-inv44.5%
+-commutative44.5%
metadata-eval44.5%
Applied egg-rr44.5%
*-commutative44.5%
+-commutative44.5%
associate--l+74.2%
+-inverses74.2%
distribute-lft-in74.2%
metadata-eval74.2%
*-commutative74.2%
+-commutative74.2%
Simplified74.2%
Taylor expanded in x around 0 74.6%
sin-sum99.4%
Applied egg-rr99.4%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in eps around inf 99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (sin eps))))
(if (<= eps -0.0037)
(- (* (cos x) (+ -1.0 (cos eps))) t_0)
(if (<= eps 0.0038)
(*
-2.0
(*
(sin (* 0.5 eps))
(+
(* (cos x) (+ (* 0.5 eps) (* (pow eps 3.0) -0.020833333333333332)))
(* (sin x) (+ (* (* eps eps) -0.125) 1.0)))))
(- (- (* (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 <= -0.0037) {
tmp = (cos(x) * (-1.0 + cos(eps))) - t_0;
} else if (eps <= 0.0038) {
tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + (pow(eps, 3.0) * -0.020833333333333332))) + (sin(x) * (((eps * eps) * -0.125) + 1.0))));
} else {
tmp = ((cos(x) * cos(eps)) - t_0) - cos(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin(x) * sin(eps)
if (eps <= (-0.0037d0)) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - t_0
else if (eps <= 0.0038d0) then
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * ((cos(x) * ((0.5d0 * eps) + ((eps ** 3.0d0) * (-0.020833333333333332d0)))) + (sin(x) * (((eps * eps) * (-0.125d0)) + 1.0d0))))
else
tmp = ((cos(x) * cos(eps)) - t_0) - cos(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) * Math.sin(eps);
double tmp;
if (eps <= -0.0037) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - t_0;
} else if (eps <= 0.0038) {
tmp = -2.0 * (Math.sin((0.5 * eps)) * ((Math.cos(x) * ((0.5 * eps) + (Math.pow(eps, 3.0) * -0.020833333333333332))) + (Math.sin(x) * (((eps * eps) * -0.125) + 1.0))));
} else {
tmp = ((Math.cos(x) * Math.cos(eps)) - t_0) - Math.cos(x);
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) * math.sin(eps) tmp = 0 if eps <= -0.0037: tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - t_0 elif eps <= 0.0038: tmp = -2.0 * (math.sin((0.5 * eps)) * ((math.cos(x) * ((0.5 * eps) + (math.pow(eps, 3.0) * -0.020833333333333332))) + (math.sin(x) * (((eps * eps) * -0.125) + 1.0)))) else: tmp = ((math.cos(x) * math.cos(eps)) - t_0) - math.cos(x) return tmp
function code(x, eps) t_0 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.0037) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - t_0); elseif (eps <= 0.0038) tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * Float64(Float64(cos(x) * Float64(Float64(0.5 * eps) + Float64((eps ^ 3.0) * -0.020833333333333332))) + Float64(sin(x) * Float64(Float64(Float64(eps * eps) * -0.125) + 1.0))))); else tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - t_0) - cos(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) * sin(eps); tmp = 0.0; if (eps <= -0.0037) tmp = (cos(x) * (-1.0 + cos(eps))) - t_0; elseif (eps <= 0.0038) tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + ((eps ^ 3.0) * -0.020833333333333332))) + (sin(x) * (((eps * eps) * -0.125) + 1.0)))); else tmp = ((cos(x) * cos(eps)) - t_0) - cos(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.0037], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[eps, 0.0038], N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(0.5 * eps), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(N[(eps * eps), $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.0037:\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - t_0\\
\mathbf{elif}\;\varepsilon \leq 0.0038:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \left(\cos x \cdot \left(0.5 \cdot \varepsilon + {\varepsilon}^{3} \cdot -0.020833333333333332\right) + \sin x \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot -0.125 + 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - t_0\right) - \cos x\\
\end{array}
\end{array}
if eps < -0.0037000000000000002Initial program 47.4%
cos-sum99.3%
Applied egg-rr99.3%
Taylor expanded in x around inf 99.3%
*-commutative99.3%
associate--r+99.3%
*-rgt-identity99.3%
distribute-lft-out--99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
if -0.0037000000000000002 < eps < 0.00379999999999999999Initial program 20.1%
diff-cos33.6%
div-inv33.6%
metadata-eval33.6%
div-inv33.6%
+-commutative33.6%
metadata-eval33.6%
Applied egg-rr33.6%
*-commutative33.6%
+-commutative33.6%
associate--l+98.4%
+-inverses98.4%
distribute-lft-in98.4%
metadata-eval98.4%
*-commutative98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 99.3%
sin-sum99.8%
Applied egg-rr99.8%
fma-def99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-+r+99.8%
associate-+l+99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
associate-*r*99.8%
distribute-rgt1-in99.8%
*-commutative99.8%
unpow299.8%
Simplified99.8%
if 0.00379999999999999999 < eps Initial program 57.7%
cos-sum98.8%
Applied egg-rr98.8%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.0034) (not (<= eps 0.0038)))
(- (* (cos x) (+ -1.0 (cos eps))) (* (sin x) (sin eps)))
(*
-2.0
(*
(sin (* 0.5 eps))
(+
(* (cos x) (+ (* 0.5 eps) (* (pow eps 3.0) -0.020833333333333332)))
(* (sin x) (+ (* (* eps eps) -0.125) 1.0)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0034) || !(eps <= 0.0038)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps));
} else {
tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + (pow(eps, 3.0) * -0.020833333333333332))) + (sin(x) * (((eps * eps) * -0.125) + 1.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.0034d0)) .or. (.not. (eps <= 0.0038d0))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(x) * sin(eps))
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * ((cos(x) * ((0.5d0 * eps) + ((eps ** 3.0d0) * (-0.020833333333333332d0)))) + (sin(x) * (((eps * eps) * (-0.125d0)) + 1.0d0))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0034) || !(eps <= 0.0038)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(x) * Math.sin(eps));
} else {
tmp = -2.0 * (Math.sin((0.5 * eps)) * ((Math.cos(x) * ((0.5 * eps) + (Math.pow(eps, 3.0) * -0.020833333333333332))) + (Math.sin(x) * (((eps * eps) * -0.125) + 1.0))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0034) or not (eps <= 0.0038): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(x) * math.sin(eps)) else: tmp = -2.0 * (math.sin((0.5 * eps)) * ((math.cos(x) * ((0.5 * eps) + (math.pow(eps, 3.0) * -0.020833333333333332))) + (math.sin(x) * (((eps * eps) * -0.125) + 1.0)))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0034) || !(eps <= 0.0038)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(x) * sin(eps))); else tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * Float64(Float64(cos(x) * Float64(Float64(0.5 * eps) + Float64((eps ^ 3.0) * -0.020833333333333332))) + Float64(sin(x) * Float64(Float64(Float64(eps * eps) * -0.125) + 1.0))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0034) || ~((eps <= 0.0038))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps)); else tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + ((eps ^ 3.0) * -0.020833333333333332))) + (sin(x) * (((eps * eps) * -0.125) + 1.0)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0034], N[Not[LessEqual[eps, 0.0038]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(0.5 * eps), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(N[(eps * eps), $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0034 \lor \neg \left(\varepsilon \leq 0.0038\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \left(\cos x \cdot \left(0.5 \cdot \varepsilon + {\varepsilon}^{3} \cdot -0.020833333333333332\right) + \sin x \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot -0.125 + 1\right)\right)\right)\\
\end{array}
\end{array}
if eps < -0.00339999999999999981 or 0.00379999999999999999 < eps Initial program 52.8%
cos-sum99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 98.9%
*-commutative98.9%
associate--r+99.0%
*-rgt-identity99.0%
distribute-lft-out--99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
if -0.00339999999999999981 < eps < 0.00379999999999999999Initial program 20.1%
diff-cos33.6%
div-inv33.6%
metadata-eval33.6%
div-inv33.6%
+-commutative33.6%
metadata-eval33.6%
Applied egg-rr33.6%
*-commutative33.6%
+-commutative33.6%
associate--l+98.4%
+-inverses98.4%
distribute-lft-in98.4%
metadata-eval98.4%
*-commutative98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 99.3%
sin-sum99.8%
Applied egg-rr99.8%
fma-def99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-+r+99.8%
associate-+l+99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-commutative99.8%
associate-*r*99.8%
distribute-rgt1-in99.8%
*-commutative99.8%
unpow299.8%
Simplified99.8%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -4.1e-41) (not (<= x 6.6e-93))) (- (* (cos x) (+ -1.0 (cos eps))) (* (sin x) (sin eps))) (* -2.0 (* (sin (* 0.5 eps)) (sin (+ x (* 0.5 eps)))))))
double code(double x, double eps) {
double tmp;
if ((x <= -4.1e-41) || !(x <= 6.6e-93)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps));
} else {
tmp = -2.0 * (sin((0.5 * eps)) * sin((x + (0.5 * eps))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-4.1d-41)) .or. (.not. (x <= 6.6d-93))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(x) * sin(eps))
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * sin((x + (0.5d0 * eps))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -4.1e-41) || !(x <= 6.6e-93)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(x) * Math.sin(eps));
} else {
tmp = -2.0 * (Math.sin((0.5 * eps)) * Math.sin((x + (0.5 * eps))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -4.1e-41) or not (x <= 6.6e-93): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(x) * math.sin(eps)) else: tmp = -2.0 * (math.sin((0.5 * eps)) * math.sin((x + (0.5 * eps)))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -4.1e-41) || !(x <= 6.6e-93)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(x) * sin(eps))); else tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * sin(Float64(x + Float64(0.5 * eps))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -4.1e-41) || ~((x <= 6.6e-93))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps)); else tmp = -2.0 * (sin((0.5 * eps)) * sin((x + (0.5 * eps)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -4.1e-41], N[Not[LessEqual[x, 6.6e-93]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(x + N[(0.5 * eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{-41} \lor \neg \left(x \leq 6.6 \cdot 10^{-93}\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(x + 0.5 \cdot \varepsilon\right)\right)\\
\end{array}
\end{array}
if x < -4.10000000000000014e-41 or 6.6000000000000003e-93 < x Initial program 14.4%
cos-sum55.2%
Applied egg-rr55.2%
Taylor expanded in x around inf 55.1%
*-commutative55.1%
associate--r+99.3%
*-rgt-identity99.3%
distribute-lft-out--99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
if -4.10000000000000014e-41 < x < 6.6000000000000003e-93Initial program 80.0%
diff-cos96.7%
div-inv96.7%
metadata-eval96.7%
div-inv96.7%
+-commutative96.7%
metadata-eval96.7%
Applied egg-rr96.7%
*-commutative96.7%
+-commutative96.7%
associate--l+99.4%
+-inverses99.4%
distribute-lft-in99.4%
metadata-eval99.4%
*-commutative99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
Taylor expanded in eps around inf 99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (cos (+ x eps)) (cos x)))) (if (<= t_0 -0.001) t_0 (* -2.0 (* (sin (* 0.5 eps)) (sin x))))))
double code(double x, double eps) {
double t_0 = cos((x + eps)) - cos(x);
double tmp;
if (t_0 <= -0.001) {
tmp = t_0;
} else {
tmp = -2.0 * (sin((0.5 * eps)) * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = cos((x + eps)) - cos(x)
if (t_0 <= (-0.001d0)) then
tmp = t_0
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos((x + eps)) - Math.cos(x);
double tmp;
if (t_0 <= -0.001) {
tmp = t_0;
} else {
tmp = -2.0 * (Math.sin((0.5 * eps)) * Math.sin(x));
}
return tmp;
}
def code(x, eps): t_0 = math.cos((x + eps)) - math.cos(x) tmp = 0 if t_0 <= -0.001: tmp = t_0 else: tmp = -2.0 * (math.sin((0.5 * eps)) * math.sin(x)) return tmp
function code(x, eps) t_0 = Float64(cos(Float64(x + eps)) - cos(x)) tmp = 0.0 if (t_0 <= -0.001) tmp = t_0; else tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * sin(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos((x + eps)) - cos(x); tmp = 0.0; if (t_0 <= -0.001) tmp = t_0; else tmp = -2.0 * (sin((0.5 * eps)) * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.001], t$95$0, N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(x + \varepsilon\right) - \cos x\\
\mathbf{if}\;t_0 \leq -0.001:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin x\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -1e-3Initial program 78.5%
if -1e-3 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 15.6%
diff-cos25.3%
div-inv25.3%
metadata-eval25.3%
div-inv25.3%
+-commutative25.3%
metadata-eval25.3%
Applied egg-rr25.3%
*-commutative25.3%
+-commutative25.3%
associate--l+71.7%
+-inverses71.7%
distribute-lft-in71.7%
metadata-eval71.7%
*-commutative71.7%
+-commutative71.7%
Simplified71.7%
Taylor expanded in eps around 0 63.2%
Final simplification68.7%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (cos (+ x eps)) (cos x)))) (if (<= t_0 -0.001) t_0 (expm1 (* eps (- (sin x)))))))
double code(double x, double eps) {
double t_0 = cos((x + eps)) - cos(x);
double tmp;
if (t_0 <= -0.001) {
tmp = t_0;
} else {
tmp = expm1((eps * -sin(x)));
}
return tmp;
}
public static double code(double x, double eps) {
double t_0 = Math.cos((x + eps)) - Math.cos(x);
double tmp;
if (t_0 <= -0.001) {
tmp = t_0;
} else {
tmp = Math.expm1((eps * -Math.sin(x)));
}
return tmp;
}
def code(x, eps): t_0 = math.cos((x + eps)) - math.cos(x) tmp = 0 if t_0 <= -0.001: tmp = t_0 else: tmp = math.expm1((eps * -math.sin(x))) return tmp
function code(x, eps) t_0 = Float64(cos(Float64(x + eps)) - cos(x)) tmp = 0.0 if (t_0 <= -0.001) tmp = t_0; else tmp = expm1(Float64(eps * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.001], t$95$0, N[(Exp[N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(x + \varepsilon\right) - \cos x\\
\mathbf{if}\;t_0 \leq -0.001:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -1e-3Initial program 78.5%
if -1e-3 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 15.6%
expm1-log1p-u15.6%
Applied egg-rr15.6%
Taylor expanded in eps around 0 61.9%
associate-*r*61.9%
mul-1-neg61.9%
Simplified61.9%
Final simplification67.9%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* 0.5 eps)) (sin (+ x (* 0.5 eps))))))
double code(double x, double eps) {
return -2.0 * (sin((0.5 * eps)) * sin((x + (0.5 * eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((0.5d0 * eps)) * sin((x + (0.5d0 * eps))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((0.5 * eps)) * Math.sin((x + (0.5 * eps))));
}
def code(x, eps): return -2.0 * (math.sin((0.5 * eps)) * math.sin((x + (0.5 * eps))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * sin(Float64(x + Float64(0.5 * eps))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((0.5 * eps)) * sin((x + (0.5 * eps)))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(x + N[(0.5 * eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(x + 0.5 \cdot \varepsilon\right)\right)
\end{array}
Initial program 38.2%
diff-cos44.5%
div-inv44.5%
metadata-eval44.5%
div-inv44.5%
+-commutative44.5%
metadata-eval44.5%
Applied egg-rr44.5%
*-commutative44.5%
+-commutative44.5%
associate--l+74.2%
+-inverses74.2%
distribute-lft-in74.2%
metadata-eval74.2%
*-commutative74.2%
+-commutative74.2%
Simplified74.2%
Taylor expanded in x around 0 74.6%
Taylor expanded in eps around inf 74.6%
Final simplification74.6%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.00042)
(- (cos eps) (cos x))
(if (<= eps 1.45e-29)
(expm1 (* eps (- (sin x))))
(* -2.0 (pow (sin (* 0.5 eps)) 2.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00042) {
tmp = cos(eps) - cos(x);
} else if (eps <= 1.45e-29) {
tmp = expm1((eps * -sin(x)));
} else {
tmp = -2.0 * pow(sin((0.5 * eps)), 2.0);
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.00042) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= 1.45e-29) {
tmp = Math.expm1((eps * -Math.sin(x)));
} else {
tmp = -2.0 * Math.pow(Math.sin((0.5 * eps)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.00042: tmp = math.cos(eps) - math.cos(x) elif eps <= 1.45e-29: tmp = math.expm1((eps * -math.sin(x))) else: tmp = -2.0 * math.pow(math.sin((0.5 * eps)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.00042) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= 1.45e-29) tmp = expm1(Float64(eps * Float64(-sin(x)))); else tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -0.00042], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.45e-29], N[(Exp[N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]] - 1), $MachinePrecision], N[(-2.0 * N[Power[N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00042:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq 1.45 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{expm1}\left(\varepsilon \cdot \left(-\sin x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\end{array}
\end{array}
if eps < -4.2000000000000002e-4Initial program 47.4%
Taylor expanded in x around 0 49.4%
if -4.2000000000000002e-4 < eps < 1.45000000000000012e-29Initial program 20.6%
expm1-log1p-u20.6%
Applied egg-rr20.6%
Taylor expanded in eps around 0 88.3%
associate-*r*88.3%
mul-1-neg88.3%
Simplified88.3%
if 1.45000000000000012e-29 < eps Initial program 55.6%
diff-cos59.4%
div-inv59.4%
metadata-eval59.4%
div-inv59.4%
+-commutative59.4%
metadata-eval59.4%
Applied egg-rr59.4%
*-commutative59.4%
+-commutative59.4%
associate--l+60.6%
+-inverses60.6%
distribute-lft-in60.6%
metadata-eval60.6%
*-commutative60.6%
+-commutative60.6%
Simplified60.6%
Taylor expanded in x around 0 61.4%
Final simplification69.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00042) (not (<= eps 270000000000.0))) (- (cos eps) (cos x)) (expm1 (* eps (- (sin x))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00042) || !(eps <= 270000000000.0)) {
tmp = cos(eps) - cos(x);
} else {
tmp = expm1((eps * -sin(x)));
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00042) || !(eps <= 270000000000.0)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = Math.expm1((eps * -Math.sin(x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00042) or not (eps <= 270000000000.0): tmp = math.cos(eps) - math.cos(x) else: tmp = math.expm1((eps * -math.sin(x))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00042) || !(eps <= 270000000000.0)) tmp = Float64(cos(eps) - cos(x)); else tmp = expm1(Float64(eps * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00042], N[Not[LessEqual[eps, 270000000000.0]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(Exp[N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]] - 1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00042 \lor \neg \left(\varepsilon \leq 270000000000\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if eps < -4.2000000000000002e-4 or 2.7e11 < eps Initial program 53.1%
Taylor expanded in x around 0 55.4%
if -4.2000000000000002e-4 < eps < 2.7e11Initial program 20.0%
expm1-log1p-u20.0%
Applied egg-rr20.0%
Taylor expanded in eps around 0 85.5%
associate-*r*85.5%
mul-1-neg85.5%
Simplified85.5%
Final simplification68.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00042) (not (<= eps 5.5e-5))) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00042) || !(eps <= 5.5e-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 <= (-0.00042d0)) .or. (.not. (eps <= 5.5d-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 <= -0.00042) || !(eps <= 5.5e-5)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00042) or not (eps <= 5.5e-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 <= -0.00042) || !(eps <= 5.5e-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 <= -0.00042) || ~((eps <= 5.5e-5))) tmp = cos(eps) - cos(x); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00042], N[Not[LessEqual[eps, 5.5e-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 -0.00042 \lor \neg \left(\varepsilon \leq 5.5 \cdot 10^{-5}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -4.2000000000000002e-4 or 5.5000000000000002e-5 < eps Initial program 52.8%
Taylor expanded in x around 0 55.1%
if -4.2000000000000002e-4 < eps < 5.5000000000000002e-5Initial program 20.1%
Taylor expanded in eps around 0 86.1%
associate-*r*86.1%
mul-1-neg86.1%
Simplified86.1%
Final simplification68.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00096) (not (<= eps 0.00041))) (+ -1.0 (cos eps)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00096) || !(eps <= 0.00041)) {
tmp = -1.0 + cos(eps);
} 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 <= (-0.00096d0)) .or. (.not. (eps <= 0.00041d0))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00096) || !(eps <= 0.00041)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00096) or not (eps <= 0.00041): tmp = -1.0 + math.cos(eps) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00096) || !(eps <= 0.00041)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00096) || ~((eps <= 0.00041))) tmp = -1.0 + cos(eps); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00096], N[Not[LessEqual[eps, 0.00041]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00096 \lor \neg \left(\varepsilon \leq 0.00041\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -9.60000000000000024e-4 or 4.0999999999999999e-4 < eps Initial program 52.8%
Taylor expanded in x around 0 54.7%
if -9.60000000000000024e-4 < eps < 4.0999999999999999e-4Initial program 20.1%
Taylor expanded in eps around 0 86.1%
associate-*r*86.1%
mul-1-neg86.1%
Simplified86.1%
Final simplification68.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.1e-29) (not (<= eps 0.00018))) (+ -1.0 (cos eps)) (* -0.5 (* eps eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-29) || !(eps <= 0.00018)) {
tmp = -1.0 + cos(eps);
} 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 ((eps <= (-1.1d-29)) .or. (.not. (eps <= 0.00018d0))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = (-0.5d0) * (eps * eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-29) || !(eps <= 0.00018)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = -0.5 * (eps * eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.1e-29) or not (eps <= 0.00018): tmp = -1.0 + math.cos(eps) else: tmp = -0.5 * (eps * eps) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.1e-29) || !(eps <= 0.00018)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(-0.5 * Float64(eps * eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.1e-29) || ~((eps <= 0.00018))) tmp = -1.0 + cos(eps); else tmp = -0.5 * (eps * eps); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.1e-29], N[Not[LessEqual[eps, 0.00018]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-29} \lor \neg \left(\varepsilon \leq 0.00018\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.09999999999999995e-29 or 1.80000000000000011e-4 < eps Initial program 52.1%
Taylor expanded in x around 0 53.9%
if -1.09999999999999995e-29 < eps < 1.80000000000000011e-4Initial program 20.4%
Taylor expanded in x around 0 20.4%
Taylor expanded in eps around 0 33.3%
unpow233.3%
Simplified33.3%
Final simplification44.9%
(FPCore (x eps) :precision binary64 (* -0.5 (* eps eps)))
double code(double x, double eps) {
return -0.5 * (eps * eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-0.5d0) * (eps * eps)
end function
public static double code(double x, double eps) {
return -0.5 * (eps * eps);
}
def code(x, eps): return -0.5 * (eps * eps)
function code(x, eps) return Float64(-0.5 * Float64(eps * eps)) end
function tmp = code(x, eps) tmp = -0.5 * (eps * eps); end
code[x_, eps_] := N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)
\end{array}
Initial program 38.2%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around 0 16.4%
unpow216.4%
Simplified16.4%
Final simplification16.4%
(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 38.2%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around 0 10.7%
Final simplification10.7%
herbie shell --seed 2023196
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))