
(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 (* 0.5 (+ x x))))
(*
-2.0
(log1p
(expm1
(*
(sin (fma 0.5 eps 0.0))
(fma (sin (* 0.5 eps)) (cos t_0) (* (cos (* 0.5 eps)) (sin t_0)))))))))
double code(double x, double eps) {
double t_0 = 0.5 * (x + x);
return -2.0 * log1p(expm1((sin(fma(0.5, eps, 0.0)) * fma(sin((0.5 * eps)), cos(t_0), (cos((0.5 * eps)) * sin(t_0))))));
}
function code(x, eps) t_0 = Float64(0.5 * Float64(x + x)) return Float64(-2.0 * log1p(expm1(Float64(sin(fma(0.5, eps, 0.0)) * fma(sin(Float64(0.5 * eps)), cos(t_0), Float64(cos(Float64(0.5 * eps)) * sin(t_0))))))) end
code[x_, eps_] := Block[{t$95$0 = N[(0.5 * N[(x + x), $MachinePrecision]), $MachinePrecision]}, N[(-2.0 * N[Log[1 + N[(Exp[N[(N[Sin[N[(0.5 * eps + 0.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision] + N[(N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x + x\right)\\
-2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(\mathsf{fma}\left(0.5, \varepsilon, 0\right)\right) \cdot \mathsf{fma}\left(\sin \left(0.5 \cdot \varepsilon\right), \cos t_0, \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin t_0\right)\right)\right)
\end{array}
\end{array}
Initial program 34.5%
diff-cos46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
+-commutative46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
+-commutative46.4%
associate--l+73.7%
*-commutative73.7%
associate-+r+73.7%
+-commutative73.7%
Simplified73.7%
distribute-lft-in73.7%
sin-sum99.4%
Applied egg-rr99.4%
fma-def99.4%
Simplified99.4%
log1p-expm1-u99.4%
distribute-lft-in99.4%
+-inverses99.4%
metadata-eval99.4%
+-inverses99.4%
fma-def99.4%
+-inverses99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (fma (cos x) t_0 (* (cos (* 0.5 eps)) (sin x)))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * fma(cos(x), t_0, (cos((0.5 * eps)) * sin(x))));
}
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * fma(cos(x), t_0, Float64(cos(Float64(0.5 * eps)) * sin(x))))) 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[Cos[x], $MachinePrecision] * t$95$0 + N[(N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[x], $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 \mathsf{fma}\left(\cos x, t_0, \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin x\right)\right)
\end{array}
\end{array}
Initial program 34.5%
diff-cos46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
+-commutative46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
+-commutative46.4%
associate--l+73.7%
*-commutative73.7%
associate-+r+73.7%
+-commutative73.7%
Simplified73.7%
distribute-lft-in73.7%
sin-sum99.4%
Applied egg-rr99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in eps around inf 99.4%
*-commutative99.4%
*-commutative99.4%
fma-def99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (+ (* (cos (* 0.5 eps)) (sin x)) (* t_0 (cos x)))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * ((cos((0.5 * eps)) * sin(x)) + (t_0 * cos(x))));
}
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((0.5d0 * eps)) * sin(x)) + (t_0 * cos(x))))
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((0.5 * eps)) * Math.sin(x)) + (t_0 * Math.cos(x))));
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) return -2.0 * (t_0 * ((math.cos((0.5 * eps)) * math.sin(x)) + (t_0 * math.cos(x))))
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * Float64(Float64(cos(Float64(0.5 * eps)) * sin(x)) + Float64(t_0 * cos(x))))) end
function tmp = code(x, eps) t_0 = sin((0.5 * eps)); tmp = -2.0 * (t_0 * ((cos((0.5 * eps)) * sin(x)) + (t_0 * cos(x)))); 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[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[x], $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 \left(0.5 \cdot \varepsilon\right) \cdot \sin x + t_0 \cdot \cos x\right)\right)
\end{array}
\end{array}
Initial program 34.5%
diff-cos46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
+-commutative46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
+-commutative46.4%
associate--l+73.7%
*-commutative73.7%
associate-+r+73.7%
+-commutative73.7%
Simplified73.7%
distribute-lft-in73.7%
sin-sum99.4%
Applied egg-rr99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in eps around inf 99.4%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (+ -1.0 (cos eps)))))
(if (<= x -3.4e-12)
(- t_0 (* (sin x) (sin eps)))
(if (<= x 1.05e-31)
(* (* -2.0 (sin (/ eps 2.0))) (sin (/ (+ eps (+ x x)) 2.0)))
(fma (sin x) (- (sin eps)) t_0)))))
double code(double x, double eps) {
double t_0 = cos(x) * (-1.0 + cos(eps));
double tmp;
if (x <= -3.4e-12) {
tmp = t_0 - (sin(x) * sin(eps));
} else if (x <= 1.05e-31) {
tmp = (-2.0 * sin((eps / 2.0))) * sin(((eps + (x + x)) / 2.0));
} else {
tmp = fma(sin(x), -sin(eps), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(cos(x) * Float64(-1.0 + cos(eps))) tmp = 0.0 if (x <= -3.4e-12) tmp = Float64(t_0 - Float64(sin(x) * sin(eps))); elseif (x <= 1.05e-31) tmp = Float64(Float64(-2.0 * sin(Float64(eps / 2.0))) * sin(Float64(Float64(eps + Float64(x + x)) / 2.0))); else tmp = fma(sin(x), Float64(-sin(eps)), t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.4e-12], N[(t$95$0 - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e-31], N[(N[(-2.0 * N[Sin[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision]) + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \left(-1 + \cos \varepsilon\right)\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{-12}:\\
\;\;\;\;t_0 - \sin x \cdot \sin \varepsilon\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-31}:\\
\;\;\;\;\left(-2 \cdot \sin \left(\frac{\varepsilon}{2}\right)\right) \cdot \sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin x, -\sin \varepsilon, t_0\right)\\
\end{array}
\end{array}
if x < -3.4000000000000001e-12Initial program 9.8%
sub-neg9.8%
cos-sum56.7%
associate-+l-56.7%
fma-neg56.7%
Applied egg-rr56.7%
Taylor expanded in x around inf 56.7%
associate--r+99.5%
*-commutative99.5%
*-rgt-identity99.5%
distribute-lft-out--99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
if -3.4000000000000001e-12 < x < 1.04999999999999996e-31Initial program 64.1%
add-sqr-sqrt46.7%
sqrt-unprod49.7%
pow249.7%
Applied egg-rr49.7%
sqrt-pow164.1%
metadata-eval64.1%
pow164.1%
diff-cos91.7%
+-commutative91.7%
associate-+r-99.6%
+-inverses99.6%
+-commutative99.6%
Applied egg-rr99.6%
associate-*r*99.6%
+-rgt-identity99.6%
associate-+l+99.7%
Simplified99.7%
if 1.04999999999999996e-31 < x Initial program 10.7%
cos-sum58.2%
cancel-sign-sub-inv58.2%
fma-def58.3%
Applied egg-rr58.3%
Taylor expanded in x around inf 58.2%
*-commutative58.2%
neg-mul-158.2%
distribute-lft-neg-in58.2%
associate--l+98.8%
*-commutative98.8%
distribute-lft-neg-in98.8%
distribute-rgt-neg-in98.8%
fma-def98.9%
*-commutative98.9%
*-rgt-identity98.9%
distribute-lft-out--98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.4e-12) (not (<= x 6.5e-32))) (- (* (cos x) (+ -1.0 (cos eps))) (* (sin x) (sin eps))) (* (* -2.0 (sin (/ eps 2.0))) (sin (/ (+ eps (+ x x)) 2.0)))))
double code(double x, double eps) {
double tmp;
if ((x <= -3.4e-12) || !(x <= 6.5e-32)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps));
} else {
tmp = (-2.0 * sin((eps / 2.0))) * sin(((eps + (x + x)) / 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 <= (-3.4d-12)) .or. (.not. (x <= 6.5d-32))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(x) * sin(eps))
else
tmp = ((-2.0d0) * sin((eps / 2.0d0))) * sin(((eps + (x + x)) / 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -3.4e-12) || !(x <= 6.5e-32)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(x) * Math.sin(eps));
} else {
tmp = (-2.0 * Math.sin((eps / 2.0))) * Math.sin(((eps + (x + x)) / 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -3.4e-12) or not (x <= 6.5e-32): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(x) * math.sin(eps)) else: tmp = (-2.0 * math.sin((eps / 2.0))) * math.sin(((eps + (x + x)) / 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -3.4e-12) || !(x <= 6.5e-32)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(x) * sin(eps))); else tmp = Float64(Float64(-2.0 * sin(Float64(eps / 2.0))) * sin(Float64(Float64(eps + Float64(x + x)) / 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -3.4e-12) || ~((x <= 6.5e-32))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps)); else tmp = (-2.0 * sin((eps / 2.0))) * sin(((eps + (x + x)) / 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -3.4e-12], N[Not[LessEqual[x, 6.5e-32]], $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[(N[(-2.0 * N[Sin[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{-12} \lor \neg \left(x \leq 6.5 \cdot 10^{-32}\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot \sin \left(\frac{\varepsilon}{2}\right)\right) \cdot \sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right)\\
\end{array}
\end{array}
if x < -3.4000000000000001e-12 or 6.49999999999999988e-32 < x Initial program 10.3%
sub-neg10.3%
cos-sum57.5%
associate-+l-57.6%
fma-neg57.6%
Applied egg-rr57.6%
Taylor expanded in x around inf 57.6%
associate--r+99.1%
*-commutative99.1%
*-rgt-identity99.1%
distribute-lft-out--99.1%
sub-neg99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
if -3.4000000000000001e-12 < x < 6.49999999999999988e-32Initial program 64.1%
add-sqr-sqrt46.7%
sqrt-unprod49.7%
pow249.7%
Applied egg-rr49.7%
sqrt-pow164.1%
metadata-eval64.1%
pow164.1%
diff-cos91.7%
+-commutative91.7%
associate-+r-99.6%
+-inverses99.6%
+-commutative99.6%
Applied egg-rr99.6%
associate-*r*99.6%
+-rgt-identity99.6%
associate-+l+99.7%
Simplified99.7%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.1e-31) (not (<= x 5.8e-30))) (* -2.0 (* (sin x) (sin (* 0.5 (+ eps (- x x)))))) (* -2.0 (pow (sin (* 0.5 eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.1e-31) || !(x <= 5.8e-30)) {
tmp = -2.0 * (sin(x) * sin((0.5 * (eps + (x - x)))));
} else {
tmp = -2.0 * pow(sin((0.5 * 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 <= (-2.1d-31)) .or. (.not. (x <= 5.8d-30))) then
tmp = (-2.0d0) * (sin(x) * sin((0.5d0 * (eps + (x - x)))))
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -2.1e-31) || !(x <= 5.8e-30)) {
tmp = -2.0 * (Math.sin(x) * Math.sin((0.5 * (eps + (x - x)))));
} else {
tmp = -2.0 * Math.pow(Math.sin((0.5 * eps)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2.1e-31) or not (x <= 5.8e-30): tmp = -2.0 * (math.sin(x) * math.sin((0.5 * (eps + (x - x))))) else: tmp = -2.0 * math.pow(math.sin((0.5 * eps)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2.1e-31) || !(x <= 5.8e-30)) tmp = Float64(-2.0 * Float64(sin(x) * sin(Float64(0.5 * Float64(eps + Float64(x - x)))))); else tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -2.1e-31) || ~((x <= 5.8e-30))) tmp = -2.0 * (sin(x) * sin((0.5 * (eps + (x - x))))); else tmp = -2.0 * (sin((0.5 * eps)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.1e-31], N[Not[LessEqual[x, 5.8e-30]], $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[(0.5 * eps), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-31} \lor \neg \left(x \leq 5.8 \cdot 10^{-30}\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(0.5 \cdot \varepsilon\right)}^{2}\\
\end{array}
\end{array}
if x < -2.09999999999999991e-31 or 5.79999999999999978e-30 < x Initial program 10.6%
diff-cos10.6%
div-inv10.6%
metadata-eval10.6%
div-inv10.6%
+-commutative10.6%
metadata-eval10.6%
Applied egg-rr10.6%
*-commutative10.6%
+-commutative10.6%
associate--l+54.8%
*-commutative54.8%
associate-+r+54.8%
+-commutative54.8%
Simplified54.8%
Taylor expanded in eps around 0 51.9%
if -2.09999999999999991e-31 < x < 5.79999999999999978e-30Initial program 67.1%
diff-cos95.5%
div-inv95.5%
metadata-eval95.5%
div-inv95.5%
+-commutative95.5%
metadata-eval95.5%
Applied egg-rr95.5%
*-commutative95.5%
+-commutative95.5%
associate--l+99.6%
*-commutative99.6%
associate-+r+99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around 0 94.4%
Final simplification69.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.0024) (not (<= eps 10000.0))) (- (cos eps) (cos x)) (- (* -0.5 (* eps (* eps (cos x)))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0024) || !(eps <= 10000.0)) {
tmp = cos(eps) - cos(x);
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) - (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.0024d0)) .or. (.not. (eps <= 10000.0d0))) then
tmp = cos(eps) - cos(x)
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0024) || !(eps <= 10000.0)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0024) or not (eps <= 10000.0): tmp = math.cos(eps) - math.cos(x) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0024) || !(eps <= 10000.0)) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0024) || ~((eps <= 10000.0))) tmp = cos(eps) - cos(x); else tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0024], N[Not[LessEqual[eps, 10000.0]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0024 \lor \neg \left(\varepsilon \leq 10000\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -0.00239999999999999979 or 1e4 < eps Initial program 48.8%
Taylor expanded in x around 0 51.1%
if -0.00239999999999999979 < eps < 1e4Initial program 19.6%
Taylor expanded in eps around 0 98.3%
mul-1-neg98.3%
unsub-neg98.3%
unpow298.3%
associate-*l*98.3%
Simplified98.3%
Final simplification74.3%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* 0.5 eps)) (sin (* 0.5 (- eps (* -2.0 x)))))))
double code(double x, double eps) {
return -2.0 * (sin((0.5 * eps)) * sin((0.5 * (eps - (-2.0 * x)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((0.5d0 * eps)) * sin((0.5d0 * (eps - ((-2.0d0) * x)))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((0.5 * eps)) * Math.sin((0.5 * (eps - (-2.0 * x)))));
}
def code(x, eps): return -2.0 * (math.sin((0.5 * eps)) * math.sin((0.5 * (eps - (-2.0 * x)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * sin(Float64(0.5 * Float64(eps - Float64(-2.0 * x)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((0.5 * eps)) * sin((0.5 * (eps - (-2.0 * x))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon - -2 \cdot x\right)\right)\right)
\end{array}
Initial program 34.5%
diff-cos46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
+-commutative46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
+-commutative46.4%
associate--l+73.7%
*-commutative73.7%
associate-+r+73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in x around -inf 73.7%
Final simplification73.7%
(FPCore (x eps) :precision binary64 (* (* -2.0 (sin (/ eps 2.0))) (sin (/ (+ eps (+ x x)) 2.0))))
double code(double x, double eps) {
return (-2.0 * sin((eps / 2.0))) * sin(((eps + (x + x)) / 2.0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((-2.0d0) * sin((eps / 2.0d0))) * sin(((eps + (x + x)) / 2.0d0))
end function
public static double code(double x, double eps) {
return (-2.0 * Math.sin((eps / 2.0))) * Math.sin(((eps + (x + x)) / 2.0));
}
def code(x, eps): return (-2.0 * math.sin((eps / 2.0))) * math.sin(((eps + (x + x)) / 2.0))
function code(x, eps) return Float64(Float64(-2.0 * sin(Float64(eps / 2.0))) * sin(Float64(Float64(eps + Float64(x + x)) / 2.0))) end
function tmp = code(x, eps) tmp = (-2.0 * sin((eps / 2.0))) * sin(((eps + (x + x)) / 2.0)); end
code[x_, eps_] := N[(N[(-2.0 * N[Sin[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-2 \cdot \sin \left(\frac{\varepsilon}{2}\right)\right) \cdot \sin \left(\frac{\varepsilon + \left(x + x\right)}{2}\right)
\end{array}
Initial program 34.5%
add-sqr-sqrt23.4%
sqrt-unprod28.2%
pow228.2%
Applied egg-rr28.2%
sqrt-pow134.5%
metadata-eval34.5%
pow134.5%
diff-cos46.4%
+-commutative46.4%
associate-+r-73.7%
+-inverses73.7%
+-commutative73.7%
Applied egg-rr73.7%
associate-*r*73.7%
+-rgt-identity73.7%
associate-+l+73.8%
Simplified73.8%
Final simplification73.8%
(FPCore (x eps) :precision binary64 (if (or (<= x -7e-32) (not (<= x 6.5e-19))) (* (sin x) (- eps)) (* -2.0 (pow (sin (* 0.5 eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -7e-32) || !(x <= 6.5e-19)) {
tmp = sin(x) * -eps;
} else {
tmp = -2.0 * pow(sin((0.5 * 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 <= (-7d-32)) .or. (.not. (x <= 6.5d-19))) then
tmp = sin(x) * -eps
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -7e-32) || !(x <= 6.5e-19)) {
tmp = Math.sin(x) * -eps;
} else {
tmp = -2.0 * Math.pow(Math.sin((0.5 * eps)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -7e-32) or not (x <= 6.5e-19): tmp = math.sin(x) * -eps else: tmp = -2.0 * math.pow(math.sin((0.5 * eps)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -7e-32) || !(x <= 6.5e-19)) tmp = Float64(sin(x) * Float64(-eps)); else tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -7e-32) || ~((x <= 6.5e-19))) tmp = sin(x) * -eps; else tmp = -2.0 * (sin((0.5 * eps)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -7e-32], N[Not[LessEqual[x, 6.5e-19]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * (-eps)), $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}\;x \leq -7 \cdot 10^{-32} \lor \neg \left(x \leq 6.5 \cdot 10^{-19}\right):\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\end{array}
\end{array}
if x < -6.9999999999999997e-32 or 6.5000000000000001e-19 < x Initial program 10.1%
Taylor expanded in eps around 0 47.4%
associate-*r*47.4%
mul-1-neg47.4%
Simplified47.4%
if -6.9999999999999997e-32 < x < 6.5000000000000001e-19Initial program 66.8%
diff-cos94.7%
div-inv94.7%
metadata-eval94.7%
div-inv94.7%
+-commutative94.7%
metadata-eval94.7%
Applied egg-rr94.7%
*-commutative94.7%
+-commutative94.7%
associate--l+99.6%
*-commutative99.6%
associate-+r+99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around 0 93.6%
Final simplification67.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (cos eps) (cos x))))
(if (<= eps -5.2e-7)
t_0
(if (<= eps 4.1e-73)
(* (sin x) (- eps))
(if (<= eps 0.00096) (* eps (* eps -0.5)) t_0)))))
double code(double x, double eps) {
double t_0 = cos(eps) - cos(x);
double tmp;
if (eps <= -5.2e-7) {
tmp = t_0;
} else if (eps <= 4.1e-73) {
tmp = sin(x) * -eps;
} else if (eps <= 0.00096) {
tmp = eps * (eps * -0.5);
} 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) :: tmp
t_0 = cos(eps) - cos(x)
if (eps <= (-5.2d-7)) then
tmp = t_0
else if (eps <= 4.1d-73) then
tmp = sin(x) * -eps
else if (eps <= 0.00096d0) then
tmp = eps * (eps * (-0.5d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(eps) - Math.cos(x);
double tmp;
if (eps <= -5.2e-7) {
tmp = t_0;
} else if (eps <= 4.1e-73) {
tmp = Math.sin(x) * -eps;
} else if (eps <= 0.00096) {
tmp = eps * (eps * -0.5);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) - math.cos(x) tmp = 0 if eps <= -5.2e-7: tmp = t_0 elif eps <= 4.1e-73: tmp = math.sin(x) * -eps elif eps <= 0.00096: tmp = eps * (eps * -0.5) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) - cos(x)) tmp = 0.0 if (eps <= -5.2e-7) tmp = t_0; elseif (eps <= 4.1e-73) tmp = Float64(sin(x) * Float64(-eps)); elseif (eps <= 0.00096) tmp = Float64(eps * Float64(eps * -0.5)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) - cos(x); tmp = 0.0; if (eps <= -5.2e-7) tmp = t_0; elseif (eps <= 4.1e-73) tmp = sin(x) * -eps; elseif (eps <= 0.00096) tmp = eps * (eps * -0.5); else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -5.2e-7], t$95$0, If[LessEqual[eps, 4.1e-73], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], If[LessEqual[eps, 0.00096], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon - \cos x\\
\mathbf{if}\;\varepsilon \leq -5.2 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 4.1 \cdot 10^{-73}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00096:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -5.19999999999999998e-7 or 9.60000000000000024e-4 < eps Initial program 48.1%
Taylor expanded in x around 0 50.4%
if -5.19999999999999998e-7 < eps < 4.10000000000000016e-73Initial program 21.6%
Taylor expanded in eps around 0 81.1%
associate-*r*81.1%
mul-1-neg81.1%
Simplified81.1%
if 4.10000000000000016e-73 < eps < 9.60000000000000024e-4Initial program 3.9%
Taylor expanded in x around 0 3.9%
Taylor expanded in eps around 0 78.7%
*-commutative78.7%
unpow278.7%
associate-*l*78.7%
Simplified78.7%
Final simplification65.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))) (t_1 (* eps (* eps -0.5))))
(if (<= eps -0.000155)
t_0
(if (<= eps -7.3e-181)
t_1
(if (<= eps 7.6e-141) (* eps (- x)) (if (<= eps 0.00017) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double t_1 = eps * (eps * -0.5);
double tmp;
if (eps <= -0.000155) {
tmp = t_0;
} else if (eps <= -7.3e-181) {
tmp = t_1;
} else if (eps <= 7.6e-141) {
tmp = eps * -x;
} else if (eps <= 0.00017) {
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 = (-1.0d0) + cos(eps)
t_1 = eps * (eps * (-0.5d0))
if (eps <= (-0.000155d0)) then
tmp = t_0
else if (eps <= (-7.3d-181)) then
tmp = t_1
else if (eps <= 7.6d-141) then
tmp = eps * -x
else if (eps <= 0.00017d0) 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 = -1.0 + Math.cos(eps);
double t_1 = eps * (eps * -0.5);
double tmp;
if (eps <= -0.000155) {
tmp = t_0;
} else if (eps <= -7.3e-181) {
tmp = t_1;
} else if (eps <= 7.6e-141) {
tmp = eps * -x;
} else if (eps <= 0.00017) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) t_1 = eps * (eps * -0.5) tmp = 0 if eps <= -0.000155: tmp = t_0 elif eps <= -7.3e-181: tmp = t_1 elif eps <= 7.6e-141: tmp = eps * -x elif eps <= 0.00017: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) t_1 = Float64(eps * Float64(eps * -0.5)) tmp = 0.0 if (eps <= -0.000155) tmp = t_0; elseif (eps <= -7.3e-181) tmp = t_1; elseif (eps <= 7.6e-141) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.00017) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = -1.0 + cos(eps); t_1 = eps * (eps * -0.5); tmp = 0.0; if (eps <= -0.000155) tmp = t_0; elseif (eps <= -7.3e-181) tmp = t_1; elseif (eps <= 7.6e-141) tmp = eps * -x; elseif (eps <= 0.00017) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.000155], t$95$0, If[LessEqual[eps, -7.3e-181], t$95$1, If[LessEqual[eps, 7.6e-141], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00017], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
t_1 := \varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{if}\;\varepsilon \leq -0.000155:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -7.3 \cdot 10^{-181}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 7.6 \cdot 10^{-141}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00017:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.55e-4 or 1.7e-4 < eps Initial program 48.2%
Taylor expanded in x around 0 48.4%
if -1.55e-4 < eps < -7.30000000000000028e-181 or 7.59999999999999973e-141 < eps < 1.7e-4Initial program 5.3%
Taylor expanded in x around 0 5.1%
Taylor expanded in eps around 0 44.5%
*-commutative44.5%
unpow244.5%
associate-*l*44.5%
Simplified44.5%
if -7.30000000000000028e-181 < eps < 7.59999999999999973e-141Initial program 38.7%
diff-cos42.6%
div-inv42.6%
metadata-eval42.6%
div-inv42.6%
+-commutative42.6%
metadata-eval42.6%
Applied egg-rr42.6%
*-commutative42.6%
+-commutative42.6%
associate--l+99.7%
*-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in eps around 0 96.2%
mul-1-neg96.2%
*-commutative96.2%
distribute-rgt-neg-in96.2%
Simplified96.2%
Taylor expanded in x around 0 52.1%
associate-*r*52.1%
neg-mul-152.1%
Simplified52.1%
Final simplification48.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ -1.0 (cos eps))))
(if (<= eps -6e-7)
t_0
(if (<= eps 1.95e-72)
(* (sin x) (- eps))
(if (<= eps 0.00017) (* eps (* eps -0.5)) t_0)))))
double code(double x, double eps) {
double t_0 = -1.0 + cos(eps);
double tmp;
if (eps <= -6e-7) {
tmp = t_0;
} else if (eps <= 1.95e-72) {
tmp = sin(x) * -eps;
} else if (eps <= 0.00017) {
tmp = eps * (eps * -0.5);
} 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) :: tmp
t_0 = (-1.0d0) + cos(eps)
if (eps <= (-6d-7)) then
tmp = t_0
else if (eps <= 1.95d-72) then
tmp = sin(x) * -eps
else if (eps <= 0.00017d0) then
tmp = eps * (eps * (-0.5d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = -1.0 + Math.cos(eps);
double tmp;
if (eps <= -6e-7) {
tmp = t_0;
} else if (eps <= 1.95e-72) {
tmp = Math.sin(x) * -eps;
} else if (eps <= 0.00017) {
tmp = eps * (eps * -0.5);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = -1.0 + math.cos(eps) tmp = 0 if eps <= -6e-7: tmp = t_0 elif eps <= 1.95e-72: tmp = math.sin(x) * -eps elif eps <= 0.00017: tmp = eps * (eps * -0.5) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(-1.0 + cos(eps)) tmp = 0.0 if (eps <= -6e-7) tmp = t_0; elseif (eps <= 1.95e-72) tmp = Float64(sin(x) * Float64(-eps)); elseif (eps <= 0.00017) tmp = Float64(eps * Float64(eps * -0.5)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = -1.0 + cos(eps); tmp = 0.0; if (eps <= -6e-7) tmp = t_0; elseif (eps <= 1.95e-72) tmp = sin(x) * -eps; elseif (eps <= 0.00017) tmp = eps * (eps * -0.5); else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -6e-7], t$95$0, If[LessEqual[eps, 1.95e-72], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision], If[LessEqual[eps, 0.00017], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \cos \varepsilon\\
\mathbf{if}\;\varepsilon \leq -6 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.95 \cdot 10^{-72}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00017:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -5.9999999999999997e-7 or 1.7e-4 < eps Initial program 48.1%
Taylor expanded in x around 0 48.3%
if -5.9999999999999997e-7 < eps < 1.95e-72Initial program 21.6%
Taylor expanded in eps around 0 81.1%
associate-*r*81.1%
mul-1-neg81.1%
Simplified81.1%
if 1.95e-72 < eps < 1.7e-4Initial program 3.9%
Taylor expanded in x around 0 3.9%
Taylor expanded in eps around 0 78.7%
*-commutative78.7%
unpow278.7%
associate-*l*78.7%
Simplified78.7%
Final simplification63.9%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.75e-86) (and (not (<= x 2.7e-75)) (<= x 6.2e+17))) (* eps (- x)) (* eps (* eps -0.5))))
double code(double x, double eps) {
double tmp;
if ((x <= -1.75e-86) || (!(x <= 2.7e-75) && (x <= 6.2e+17))) {
tmp = eps * -x;
} else {
tmp = eps * (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 ((x <= (-1.75d-86)) .or. (.not. (x <= 2.7d-75)) .and. (x <= 6.2d+17)) then
tmp = eps * -x
else
tmp = eps * (eps * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -1.75e-86) || (!(x <= 2.7e-75) && (x <= 6.2e+17))) {
tmp = eps * -x;
} else {
tmp = eps * (eps * -0.5);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.75e-86) or (not (x <= 2.7e-75) and (x <= 6.2e+17)): tmp = eps * -x else: tmp = eps * (eps * -0.5) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.75e-86) || (!(x <= 2.7e-75) && (x <= 6.2e+17))) tmp = Float64(eps * Float64(-x)); else tmp = Float64(eps * Float64(eps * -0.5)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.75e-86) || (~((x <= 2.7e-75)) && (x <= 6.2e+17))) tmp = eps * -x; else tmp = eps * (eps * -0.5); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.75e-86], And[N[Not[LessEqual[x, 2.7e-75]], $MachinePrecision], LessEqual[x, 6.2e+17]]], N[(eps * (-x)), $MachinePrecision], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-86} \lor \neg \left(x \leq 2.7 \cdot 10^{-75}\right) \land x \leq 6.2 \cdot 10^{+17}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\end{array}
\end{array}
if x < -1.7500000000000001e-86 or 2.6999999999999998e-75 < x < 6.2e17Initial program 25.6%
diff-cos26.0%
div-inv26.0%
metadata-eval26.0%
div-inv26.0%
+-commutative26.0%
metadata-eval26.0%
Applied egg-rr26.0%
*-commutative26.0%
+-commutative26.0%
associate--l+66.6%
*-commutative66.6%
associate-+r+66.6%
+-commutative66.6%
Simplified66.6%
Taylor expanded in eps around 0 43.9%
mul-1-neg43.9%
*-commutative43.9%
distribute-rgt-neg-in43.9%
Simplified43.9%
Taylor expanded in x around 0 16.1%
associate-*r*16.1%
neg-mul-116.1%
Simplified16.1%
if -1.7500000000000001e-86 < x < 2.6999999999999998e-75 or 6.2e17 < x Initial program 40.5%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around 0 35.1%
*-commutative35.1%
unpow235.1%
associate-*l*35.1%
Simplified35.1%
Final simplification27.3%
(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.5%
diff-cos46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
+-commutative46.4%
metadata-eval46.4%
Applied egg-rr46.4%
*-commutative46.4%
+-commutative46.4%
associate--l+73.7%
*-commutative73.7%
associate-+r+73.7%
+-commutative73.7%
Simplified73.7%
Taylor expanded in eps around 0 37.9%
mul-1-neg37.9%
*-commutative37.9%
distribute-rgt-neg-in37.9%
Simplified37.9%
Taylor expanded in x around 0 15.9%
associate-*r*15.9%
neg-mul-115.9%
Simplified15.9%
Final simplification15.9%
herbie shell --seed 2023192
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))