
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= eps -3.1e-5)
(- (fma (cos x) (cos eps) (* (- (sin x)) (sin eps))) (cos x))
(if (<= eps 4.2e-5)
(- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))
(fma (cos x) (cos eps) (- (fma (sin x) (sin eps) (cos x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -3.1e-5) {
tmp = fma(cos(x), cos(eps), (-sin(x) * sin(eps))) - cos(x);
} else if (eps <= 4.2e-5) {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
} else {
tmp = fma(cos(x), cos(eps), -fma(sin(x), sin(eps), cos(x)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -3.1e-5) tmp = Float64(fma(cos(x), cos(eps), Float64(Float64(-sin(x)) * sin(eps))) - cos(x)); elseif (eps <= 4.2e-5) tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); else tmp = fma(cos(x), cos(eps), Float64(-fma(sin(x), sin(eps), cos(x)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -3.1e-5], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[((-N[Sin[x], $MachinePrecision]) * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.2e-5], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + (-N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.1 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\sin x\right) \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 4.2 \cdot 10^{-5}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, -\mathsf{fma}\left(\sin x, \sin \varepsilon, \cos x\right)\right)\\
\end{array}
\end{array}
if eps < -3.10000000000000014e-5Initial program 53.1%
cos-sum98.7%
cancel-sign-sub-inv98.7%
fma-def98.7%
Applied egg-rr98.7%
if -3.10000000000000014e-5 < eps < 4.19999999999999977e-5Initial program 28.9%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
if 4.19999999999999977e-5 < eps Initial program 46.4%
cos-sum98.7%
associate--l-98.5%
fma-neg98.7%
fma-def98.8%
Applied egg-rr98.8%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.6e-5) (not (<= eps 3.3e-5))) (- (fma (cos x) (cos eps) (* (- (sin x)) (sin eps))) (cos x)) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.6e-5) || !(eps <= 3.3e-5)) {
tmp = fma(cos(x), cos(eps), (-sin(x) * sin(eps))) - cos(x);
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -2.6e-5) || !(eps <= 3.3e-5)) tmp = Float64(fma(cos(x), cos(eps), Float64(Float64(-sin(x)) * sin(eps))) - cos(x)); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -2.6e-5], N[Not[LessEqual[eps, 3.3e-5]], $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[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.6 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 3.3 \cdot 10^{-5}\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\sin x\right) \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -2.59999999999999984e-5 or 3.3000000000000003e-5 < eps Initial program 49.8%
cos-sum98.7%
cancel-sign-sub-inv98.7%
fma-def98.7%
Applied egg-rr98.7%
if -2.59999999999999984e-5 < eps < 3.3000000000000003e-5Initial program 28.9%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-5) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-5) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((eps + x)) - cos(x)) <= (-5d-5)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-5) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-5: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-5) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -5e-5) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-5], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-5}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -5.00000000000000024e-5Initial program 78.4%
diff-cos77.9%
div-inv77.9%
associate--l+77.9%
metadata-eval77.9%
div-inv77.9%
+-commutative77.9%
associate-+l+78.4%
metadata-eval78.4%
Applied egg-rr78.4%
associate-*r*78.4%
*-commutative78.4%
*-commutative78.4%
+-commutative78.4%
count-278.4%
fma-def78.4%
sub-neg78.4%
mul-1-neg78.4%
+-commutative78.4%
associate-+r+78.0%
mul-1-neg78.0%
sub-neg78.0%
+-inverses78.0%
remove-double-neg78.0%
mul-1-neg78.0%
sub-neg78.0%
neg-sub078.0%
mul-1-neg78.0%
remove-double-neg78.0%
Simplified78.0%
Taylor expanded in x around 0 78.8%
if -5.00000000000000024e-5 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.8%
Taylor expanded in eps around 0 75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
associate-*r*75.1%
*-commutative75.1%
Simplified75.1%
Final simplification76.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -4.5e-5) (not (<= eps 3.3e-5))) (- (- (* (cos x) (cos eps)) (* (sin x) (sin eps))) (cos x)) (- (* (cos x) (* -0.5 (pow eps 2.0))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -4.5e-5) || !(eps <= 3.3e-5)) {
tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
} else {
tmp = (cos(x) * (-0.5 * pow(eps, 2.0))) - (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 <= (-4.5d-5)) .or. (.not. (eps <= 3.3d-5))) then
tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x)
else
tmp = (cos(x) * ((-0.5d0) * (eps ** 2.0d0))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -4.5e-5) || !(eps <= 3.3e-5)) {
tmp = ((Math.cos(x) * Math.cos(eps)) - (Math.sin(x) * Math.sin(eps))) - Math.cos(x);
} else {
tmp = (Math.cos(x) * (-0.5 * Math.pow(eps, 2.0))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -4.5e-5) or not (eps <= 3.3e-5): tmp = ((math.cos(x) * math.cos(eps)) - (math.sin(x) * math.sin(eps))) - math.cos(x) else: tmp = (math.cos(x) * (-0.5 * math.pow(eps, 2.0))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -4.5e-5) || !(eps <= 3.3e-5)) tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - Float64(sin(x) * sin(eps))) - cos(x)); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * (eps ^ 2.0))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -4.5e-5) || ~((eps <= 3.3e-5))) tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x); else tmp = (cos(x) * (-0.5 * (eps ^ 2.0))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -4.5e-5], N[Not[LessEqual[eps, 3.3e-5]], $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[Cos[x], $MachinePrecision] * N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -4.5 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 3.3 \cdot 10^{-5}\right):\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot {\varepsilon}^{2}\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -4.50000000000000028e-5 or 3.3000000000000003e-5 < eps Initial program 49.8%
cos-sum98.7%
Applied egg-rr98.7%
if -4.50000000000000028e-5 < eps < 3.3000000000000003e-5Initial program 28.9%
Taylor expanded in eps around 0 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-12) (* -2.0 (* (sin (* 0.5 (+ x (- eps x)))) (sin (* 0.5 (+ eps (+ x x)))))) (* (sin x) (* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-12) {
tmp = -2.0 * (sin((0.5 * (x + (eps - x)))) * sin((0.5 * (eps + (x + x)))));
} else {
tmp = sin(x) * (-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 ((cos((eps + x)) - cos(x)) <= (-5d-12)) then
tmp = (-2.0d0) * (sin((0.5d0 * (x + (eps - x)))) * sin((0.5d0 * (eps + (x + x)))))
else
tmp = sin(x) * ((-2.0d0) * sin((eps * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-12) {
tmp = -2.0 * (Math.sin((0.5 * (x + (eps - x)))) * Math.sin((0.5 * (eps + (x + x)))));
} else {
tmp = Math.sin(x) * (-2.0 * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-12: tmp = -2.0 * (math.sin((0.5 * (x + (eps - x)))) * math.sin((0.5 * (eps + (x + x))))) else: tmp = math.sin(x) * (-2.0 * math.sin((eps * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-12) tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * Float64(x + Float64(eps - x)))) * sin(Float64(0.5 * Float64(eps + Float64(x + x)))))); else tmp = Float64(sin(x) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -5e-12) tmp = -2.0 * (sin((0.5 * (x + (eps - x)))) * sin((0.5 * (eps + (x + x))))); else tmp = sin(x) * (-2.0 * sin((eps * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(-2.0 * N[(N[Sin[N[(0.5 * N[(x + N[(eps - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \left(x + \left(\varepsilon - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 77.9%
diff-cos78.2%
*-commutative78.2%
div-inv78.2%
associate--l+78.2%
metadata-eval78.2%
div-inv78.2%
+-commutative78.2%
associate-+l+78.7%
metadata-eval78.7%
Applied egg-rr78.7%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.7%
diff-cos30.5%
div-inv30.5%
associate--l+30.5%
metadata-eval30.5%
div-inv30.5%
+-commutative30.5%
associate-+l+30.3%
metadata-eval30.3%
Applied egg-rr30.3%
associate-*r*30.3%
*-commutative30.3%
*-commutative30.3%
+-commutative30.3%
count-230.3%
fma-def30.3%
sub-neg30.3%
mul-1-neg30.3%
+-commutative30.3%
associate-+r+75.4%
mul-1-neg75.4%
sub-neg75.4%
+-inverses75.4%
remove-double-neg75.4%
mul-1-neg75.4%
sub-neg75.4%
neg-sub075.4%
mul-1-neg75.4%
remove-double-neg75.4%
Simplified75.4%
Taylor expanded in eps around 0 68.4%
Final simplification71.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (<= (- (cos (+ eps x)) (cos x)) -5e-12)
(* -2.0 (pow t_0 2.0))
(* (sin x) (* -2.0 t_0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-12) {
tmp = -2.0 * pow(t_0, 2.0);
} else {
tmp = sin(x) * (-2.0 * t_0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin((eps * 0.5d0))
if ((cos((eps + x)) - cos(x)) <= (-5d-12)) then
tmp = (-2.0d0) * (t_0 ** 2.0d0)
else
tmp = sin(x) * ((-2.0d0) * t_0)
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 ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-12) {
tmp = -2.0 * Math.pow(t_0, 2.0);
} else {
tmp = Math.sin(x) * (-2.0 * t_0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-12: tmp = -2.0 * math.pow(t_0, 2.0) else: tmp = math.sin(x) * (-2.0 * t_0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-12) tmp = Float64(-2.0 * (t_0 ^ 2.0)); else tmp = Float64(sin(x) * Float64(-2.0 * t_0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -5e-12) tmp = -2.0 * (t_0 ^ 2.0); else tmp = sin(x) * (-2.0 * t_0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-2 \cdot t_0\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 77.9%
diff-cos78.2%
div-inv78.2%
associate--l+78.2%
metadata-eval78.2%
div-inv78.2%
+-commutative78.2%
associate-+l+78.7%
metadata-eval78.7%
Applied egg-rr78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
+-commutative78.7%
count-278.7%
fma-def78.7%
sub-neg78.7%
mul-1-neg78.7%
+-commutative78.7%
associate-+r+78.3%
mul-1-neg78.3%
sub-neg78.3%
+-inverses78.3%
remove-double-neg78.3%
mul-1-neg78.3%
sub-neg78.3%
neg-sub078.3%
mul-1-neg78.3%
remove-double-neg78.3%
Simplified78.3%
Taylor expanded in x around 0 78.0%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.7%
diff-cos30.5%
div-inv30.5%
associate--l+30.5%
metadata-eval30.5%
div-inv30.5%
+-commutative30.5%
associate-+l+30.3%
metadata-eval30.3%
Applied egg-rr30.3%
associate-*r*30.3%
*-commutative30.3%
*-commutative30.3%
+-commutative30.3%
count-230.3%
fma-def30.3%
sub-neg30.3%
mul-1-neg30.3%
+-commutative30.3%
associate-+r+75.4%
mul-1-neg75.4%
sub-neg75.4%
+-inverses75.4%
remove-double-neg75.4%
mul-1-neg75.4%
sub-neg75.4%
neg-sub075.4%
mul-1-neg75.4%
remove-double-neg75.4%
Simplified75.4%
Taylor expanded in eps around 0 68.4%
Final simplification71.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-12) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-12) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((eps + x)) - cos(x)) <= (-5d-12)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-12) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-12: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-12) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -5e-12) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 77.9%
diff-cos78.2%
div-inv78.2%
associate--l+78.2%
metadata-eval78.2%
div-inv78.2%
+-commutative78.2%
associate-+l+78.7%
metadata-eval78.7%
Applied egg-rr78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
+-commutative78.7%
count-278.7%
fma-def78.7%
sub-neg78.7%
mul-1-neg78.7%
+-commutative78.7%
associate-+r+78.3%
mul-1-neg78.3%
sub-neg78.3%
+-inverses78.3%
remove-double-neg78.3%
mul-1-neg78.3%
sub-neg78.3%
neg-sub078.3%
mul-1-neg78.3%
remove-double-neg78.3%
Simplified78.3%
Taylor expanded in x around 0 78.0%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.7%
Taylor expanded in eps around 0 67.0%
mul-1-neg67.0%
*-commutative67.0%
distribute-rgt-neg-in67.0%
Simplified67.0%
Final simplification70.2%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (cos (+ eps x)) (cos x)))) (if (<= t_0 -5e-12) t_0 (* (sin x) (- eps)))))
double code(double x, double eps) {
double t_0 = cos((eps + x)) - cos(x);
double tmp;
if (t_0 <= -5e-12) {
tmp = t_0;
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = cos((eps + x)) - cos(x)
if (t_0 <= (-5d-12)) then
tmp = t_0
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos((eps + x)) - Math.cos(x);
double tmp;
if (t_0 <= -5e-12) {
tmp = t_0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): t_0 = math.cos((eps + x)) - math.cos(x) tmp = 0 if t_0 <= -5e-12: tmp = t_0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) t_0 = Float64(cos(Float64(eps + x)) - cos(x)) tmp = 0.0 if (t_0 <= -5e-12) tmp = t_0; else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos((eps + x)) - cos(x); tmp = 0.0; if (t_0 <= -5e-12) tmp = t_0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-12], t$95$0, N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\varepsilon + x\right) - \cos x\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 77.9%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.7%
Taylor expanded in eps around 0 67.0%
mul-1-neg67.0%
*-commutative67.0%
distribute-rgt-neg-in67.0%
Simplified67.0%
Final simplification70.2%
(FPCore (x eps) :precision binary64 (* (sin (* 0.5 (fma 2.0 x eps))) (* -2.0 (sin (* eps 0.5)))))
double code(double x, double eps) {
return sin((0.5 * fma(2.0, x, eps))) * (-2.0 * sin((eps * 0.5)));
}
function code(x, eps) return Float64(sin(Float64(0.5 * fma(2.0, x, eps))) * Float64(-2.0 * sin(Float64(eps * 0.5)))) end
code[x_, eps_] := N[(N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 38.9%
diff-cos44.5%
div-inv44.5%
associate--l+44.5%
metadata-eval44.5%
div-inv44.5%
+-commutative44.5%
associate-+l+44.5%
metadata-eval44.5%
Applied egg-rr44.5%
associate-*r*44.5%
*-commutative44.5%
*-commutative44.5%
+-commutative44.5%
count-244.5%
fma-def44.5%
sub-neg44.5%
mul-1-neg44.5%
+-commutative44.5%
associate-+r+76.3%
mul-1-neg76.3%
sub-neg76.3%
+-inverses76.3%
remove-double-neg76.3%
mul-1-neg76.3%
sub-neg76.3%
neg-sub076.3%
mul-1-neg76.3%
remove-double-neg76.3%
Simplified76.3%
Final simplification76.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.106) (not (<= eps 125.0))) (- (cos eps) (cos x)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.106) || !(eps <= 125.0)) {
tmp = cos(eps) - cos(x);
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.106d0)) .or. (.not. (eps <= 125.0d0))) then
tmp = cos(eps) - cos(x)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.106) || !(eps <= 125.0)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.106) or not (eps <= 125.0): tmp = math.cos(eps) - math.cos(x) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.106) || !(eps <= 125.0)) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.106) || ~((eps <= 125.0))) tmp = cos(eps) - cos(x); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.106], N[Not[LessEqual[eps, 125.0]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.106 \lor \neg \left(\varepsilon \leq 125\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.105999999999999997 or 125 < eps Initial program 51.4%
Taylor expanded in x around 0 54.0%
if -0.105999999999999997 < eps < 125Initial program 28.2%
Taylor expanded in eps around 0 86.7%
mul-1-neg86.7%
*-commutative86.7%
distribute-rgt-neg-in86.7%
Simplified86.7%
Final simplification71.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)))
(if (<= eps -0.00016)
t_0
(if (<= eps -7.4e-155)
(* -0.5 (pow eps 2.0))
(if (<= eps 2.5e-46) (* eps (- x)) t_0)))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double tmp;
if (eps <= -0.00016) {
tmp = t_0;
} else if (eps <= -7.4e-155) {
tmp = -0.5 * pow(eps, 2.0);
} else if (eps <= 2.5e-46) {
tmp = eps * -x;
} 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) + (-1.0d0)
if (eps <= (-0.00016d0)) then
tmp = t_0
else if (eps <= (-7.4d-155)) then
tmp = (-0.5d0) * (eps ** 2.0d0)
else if (eps <= 2.5d-46) then
tmp = eps * -x
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 tmp;
if (eps <= -0.00016) {
tmp = t_0;
} else if (eps <= -7.4e-155) {
tmp = -0.5 * Math.pow(eps, 2.0);
} else if (eps <= 2.5e-46) {
tmp = eps * -x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 tmp = 0 if eps <= -0.00016: tmp = t_0 elif eps <= -7.4e-155: tmp = -0.5 * math.pow(eps, 2.0) elif eps <= 2.5e-46: tmp = eps * -x else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) tmp = 0.0 if (eps <= -0.00016) tmp = t_0; elseif (eps <= -7.4e-155) tmp = Float64(-0.5 * (eps ^ 2.0)); elseif (eps <= 2.5e-46) tmp = Float64(eps * Float64(-x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) + -1.0; tmp = 0.0; if (eps <= -0.00016) tmp = t_0; elseif (eps <= -7.4e-155) tmp = -0.5 * (eps ^ 2.0); elseif (eps <= 2.5e-46) tmp = eps * -x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[eps, -0.00016], t$95$0, If[LessEqual[eps, -7.4e-155], N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.5e-46], N[(eps * (-x)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -0.00016:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -7.4 \cdot 10^{-155}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2}\\
\mathbf{elif}\;\varepsilon \leq 2.5 \cdot 10^{-46}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.60000000000000013e-4 or 2.49999999999999996e-46 < eps Initial program 47.3%
Taylor expanded in x around 0 48.0%
if -1.60000000000000013e-4 < eps < -7.4000000000000001e-155Initial program 4.3%
Taylor expanded in x around 0 4.3%
Taylor expanded in eps around 0 25.7%
if -7.4000000000000001e-155 < eps < 2.49999999999999996e-46Initial program 39.1%
Taylor expanded in x around 0 38.8%
associate--l+38.8%
associate-*r*38.8%
fma-neg38.8%
mul-1-neg38.8%
metadata-eval38.8%
Simplified38.8%
Taylor expanded in eps around 0 53.9%
mul-1-neg53.9%
distribute-rgt-neg-in53.9%
Simplified53.9%
Final simplification47.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.106) (not (<= eps 125.0))) (+ (cos eps) -1.0) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.106) || !(eps <= 125.0)) {
tmp = cos(eps) + -1.0;
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.106d0)) .or. (.not. (eps <= 125.0d0))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.106) || !(eps <= 125.0)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.106) or not (eps <= 125.0): tmp = math.cos(eps) + -1.0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.106) || !(eps <= 125.0)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.106) || ~((eps <= 125.0))) tmp = cos(eps) + -1.0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.106], N[Not[LessEqual[eps, 125.0]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.106 \lor \neg \left(\varepsilon \leq 125\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -0.105999999999999997 or 125 < eps Initial program 51.4%
Taylor expanded in x around 0 52.2%
if -0.105999999999999997 < eps < 125Initial program 28.2%
Taylor expanded in eps around 0 86.7%
mul-1-neg86.7%
*-commutative86.7%
distribute-rgt-neg-in86.7%
Simplified86.7%
Final simplification70.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.2e-27) (not (<= eps 2.5e-46))) (+ (cos eps) -1.0) (* eps (- x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.2e-27) || !(eps <= 2.5e-46)) {
tmp = cos(eps) + -1.0;
} else {
tmp = eps * -x;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.2d-27)) .or. (.not. (eps <= 2.5d-46))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = eps * -x
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.2e-27) || !(eps <= 2.5e-46)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -x;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.2e-27) or not (eps <= 2.5e-46): tmp = math.cos(eps) + -1.0 else: tmp = eps * -x return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.2e-27) || !(eps <= 2.5e-46)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(eps * Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.2e-27) || ~((eps <= 2.5e-46))) tmp = cos(eps) + -1.0; else tmp = eps * -x; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.2e-27], N[Not[LessEqual[eps, 2.5e-46]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.2 \cdot 10^{-27} \lor \neg \left(\varepsilon \leq 2.5 \cdot 10^{-46}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\end{array}
\end{array}
if eps < -1.20000000000000001e-27 or 2.49999999999999996e-46 < eps Initial program 46.0%
Taylor expanded in x around 0 46.6%
if -1.20000000000000001e-27 < eps < 2.49999999999999996e-46Initial program 31.1%
Taylor expanded in x around 0 30.9%
associate--l+30.9%
associate-*r*30.9%
fma-neg30.9%
mul-1-neg30.9%
metadata-eval30.9%
Simplified30.9%
Taylor expanded in eps around 0 43.4%
mul-1-neg43.4%
distribute-rgt-neg-in43.4%
Simplified43.4%
Final simplification45.1%
(FPCore (x eps) :precision binary64 (* eps (- x)))
double code(double x, double eps) {
return eps * -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * -x
end function
public static double code(double x, double eps) {
return eps * -x;
}
def code(x, eps): return eps * -x
function code(x, eps) return Float64(eps * Float64(-x)) end
function tmp = code(x, eps) tmp = eps * -x; end
code[x_, eps_] := N[(eps * (-x)), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(-x\right)
\end{array}
Initial program 38.9%
Taylor expanded in x around 0 37.5%
associate--l+37.5%
associate-*r*37.5%
fma-neg37.5%
mul-1-neg37.5%
metadata-eval37.5%
Simplified37.5%
Taylor expanded in eps around 0 22.3%
mul-1-neg22.3%
distribute-rgt-neg-in22.3%
Simplified22.3%
Final simplification22.3%
herbie shell --seed 2023318
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))