
(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
(if (<= eps -3.4e-7)
(- (* (cos eps) (cos x)) (fma (sin eps) (sin x) (cos x)))
(if (<= eps 0.0004)
(* (sin (* 0.5 (+ eps (+ x x)))) (* -2.0 (sin (* eps 0.5))))
(fma (cos x) (cos eps) (- (- (cos x)) (* (sin eps) (sin x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= -3.4e-7) {
tmp = (cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x));
} else if (eps <= 0.0004) {
tmp = sin((0.5 * (eps + (x + x)))) * (-2.0 * sin((eps * 0.5)));
} else {
tmp = fma(cos(x), cos(eps), (-cos(x) - (sin(eps) * sin(x))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -3.4e-7) tmp = Float64(Float64(cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x))); elseif (eps <= 0.0004) tmp = Float64(sin(Float64(0.5 * Float64(eps + Float64(x + x)))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); else tmp = fma(cos(x), cos(eps), Float64(Float64(-cos(x)) - Float64(sin(eps) * sin(x)))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -3.4e-7], N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0004], N[(N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[((-N[Cos[x], $MachinePrecision]) - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-7}:\\
\;\;\;\;\cos \varepsilon \cdot \cos x - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0004:\\
\;\;\;\;\sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \left(-\cos x\right) - \sin \varepsilon \cdot \sin x\right)\\
\end{array}
\end{array}
if eps < -3.39999999999999974e-7Initial program 53.7%
sub-neg53.7%
cos-sum98.0%
associate-+l-98.0%
fma-neg98.2%
Applied egg-rr98.2%
fma-neg98.0%
*-commutative98.0%
*-commutative98.0%
fma-neg98.2%
remove-double-neg98.2%
Simplified98.2%
if -3.39999999999999974e-7 < eps < 4.00000000000000019e-4Initial program 26.0%
diff-cos41.3%
div-inv41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
associate-+r+41.3%
+-commutative41.3%
*-commutative41.3%
+-commutative41.3%
associate--l+99.7%
+-inverses99.7%
Simplified99.7%
if 4.00000000000000019e-4 < eps Initial program 41.5%
sub-neg41.5%
cos-sum98.8%
associate-+l-98.8%
fma-neg98.9%
Applied egg-rr98.9%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(if (<= eps -3.4e-7)
(- (* (cos eps) (cos x)) (fma (sin eps) (sin x) (cos x)))
(if (<= eps 0.00062)
(* (sin (* 0.5 (+ eps (+ x x)))) (* -2.0 (sin (* eps 0.5))))
(- (fma (cos x) (cos eps) (* (sin eps) (- (sin x)))) (cos x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -3.4e-7) {
tmp = (cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x));
} else if (eps <= 0.00062) {
tmp = sin((0.5 * (eps + (x + x)))) * (-2.0 * sin((eps * 0.5)));
} else {
tmp = fma(cos(x), cos(eps), (sin(eps) * -sin(x))) - cos(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -3.4e-7) tmp = Float64(Float64(cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x))); elseif (eps <= 0.00062) tmp = Float64(sin(Float64(0.5 * Float64(eps + Float64(x + x)))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); else tmp = Float64(fma(cos(x), cos(eps), Float64(sin(eps) * Float64(-sin(x)))) - cos(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -3.4e-7], N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.00062], N[(N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-7}:\\
\;\;\;\;\cos \varepsilon \cdot \cos x - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00062:\\
\;\;\;\;\sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \sin \varepsilon \cdot \left(-\sin x\right)\right) - \cos x\\
\end{array}
\end{array}
if eps < -3.39999999999999974e-7Initial program 53.7%
sub-neg53.7%
cos-sum98.0%
associate-+l-98.0%
fma-neg98.2%
Applied egg-rr98.2%
fma-neg98.0%
*-commutative98.0%
*-commutative98.0%
fma-neg98.2%
remove-double-neg98.2%
Simplified98.2%
if -3.39999999999999974e-7 < eps < 6.2e-4Initial program 26.0%
diff-cos41.3%
div-inv41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
associate-+r+41.3%
+-commutative41.3%
*-commutative41.3%
+-commutative41.3%
associate--l+99.7%
+-inverses99.7%
Simplified99.7%
if 6.2e-4 < eps Initial program 41.5%
cos-sum98.8%
cancel-sign-sub-inv98.8%
fma-def98.9%
Applied egg-rr98.9%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.4e-7) (not (<= eps 0.00037))) (- (* (cos eps) (cos x)) (fma (sin eps) (sin x) (cos x))) (* (sin (* 0.5 (+ eps (+ x x)))) (* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.4e-7) || !(eps <= 0.00037)) {
tmp = (cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x));
} else {
tmp = sin((0.5 * (eps + (x + x)))) * (-2.0 * sin((eps * 0.5)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((eps <= -3.4e-7) || !(eps <= 0.00037)) tmp = Float64(Float64(cos(eps) * cos(x)) - fma(sin(eps), sin(x), cos(x))); else tmp = Float64(sin(Float64(0.5 * Float64(eps + Float64(x + x)))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[eps, -3.4e-7], N[Not[LessEqual[eps, 0.00037]], $MachinePrecision]], N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 0.00037\right):\\
\;\;\;\;\cos \varepsilon \cdot \cos x - \mathsf{fma}\left(\sin \varepsilon, \sin x, \cos x\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if eps < -3.39999999999999974e-7 or 3.6999999999999999e-4 < eps Initial program 48.7%
sub-neg48.7%
cos-sum98.4%
associate-+l-98.3%
fma-neg98.5%
Applied egg-rr98.5%
fma-neg98.3%
*-commutative98.3%
*-commutative98.3%
fma-neg98.4%
remove-double-neg98.4%
Simplified98.4%
if -3.39999999999999974e-7 < eps < 3.6999999999999999e-4Initial program 26.0%
diff-cos41.3%
div-inv41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
associate-+r+41.3%
+-commutative41.3%
*-commutative41.3%
+-commutative41.3%
associate--l+99.7%
+-inverses99.7%
Simplified99.7%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.4e-7) (not (<= eps 0.00046))) (- (- (* (cos eps) (cos x)) (* (sin eps) (sin x))) (cos x)) (* (sin (* 0.5 (+ eps (+ x x)))) (* -2.0 (sin (* eps 0.5))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.4e-7) || !(eps <= 0.00046)) {
tmp = ((cos(eps) * cos(x)) - (sin(eps) * sin(x))) - cos(x);
} else {
tmp = sin((0.5 * (eps + (x + 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 ((eps <= (-3.4d-7)) .or. (.not. (eps <= 0.00046d0))) then
tmp = ((cos(eps) * cos(x)) - (sin(eps) * sin(x))) - cos(x)
else
tmp = sin((0.5d0 * (eps + (x + x)))) * ((-2.0d0) * sin((eps * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.4e-7) || !(eps <= 0.00046)) {
tmp = ((Math.cos(eps) * Math.cos(x)) - (Math.sin(eps) * Math.sin(x))) - Math.cos(x);
} else {
tmp = Math.sin((0.5 * (eps + (x + x)))) * (-2.0 * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.4e-7) or not (eps <= 0.00046): tmp = ((math.cos(eps) * math.cos(x)) - (math.sin(eps) * math.sin(x))) - math.cos(x) else: tmp = math.sin((0.5 * (eps + (x + x)))) * (-2.0 * math.sin((eps * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.4e-7) || !(eps <= 0.00046)) tmp = Float64(Float64(Float64(cos(eps) * cos(x)) - Float64(sin(eps) * sin(x))) - cos(x)); else tmp = Float64(sin(Float64(0.5 * Float64(eps + Float64(x + x)))) * Float64(-2.0 * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.4e-7) || ~((eps <= 0.00046))) tmp = ((cos(eps) * cos(x)) - (sin(eps) * sin(x))) - cos(x); else tmp = sin((0.5 * (eps + (x + x)))) * (-2.0 * sin((eps * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.4e-7], N[Not[LessEqual[eps, 0.00046]], $MachinePrecision]], N[(N[(N[(N[Cos[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.4 \cdot 10^{-7} \lor \neg \left(\varepsilon \leq 0.00046\right):\\
\;\;\;\;\left(\cos \varepsilon \cdot \cos x - \sin \varepsilon \cdot \sin x\right) - \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right) \cdot \left(-2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if eps < -3.39999999999999974e-7 or 4.6000000000000001e-4 < eps Initial program 48.7%
cos-sum98.4%
Applied egg-rr98.4%
if -3.39999999999999974e-7 < eps < 4.6000000000000001e-4Initial program 26.0%
diff-cos41.3%
div-inv41.3%
metadata-eval41.3%
div-inv41.3%
+-commutative41.3%
metadata-eval41.3%
Applied egg-rr41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
associate-+r+41.3%
+-commutative41.3%
*-commutative41.3%
+-commutative41.3%
associate--l+99.7%
+-inverses99.7%
Simplified99.7%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -4e-10) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (- (* (cos x) (* -0.5 (* eps eps))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -4e-10) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = (cos(x) * (-0.5 * (eps * eps))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((eps + x)) - cos(x)) <= (-4d-10)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = (cos(x) * ((-0.5d0) * (eps * eps))) - (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)) <= -4e-10) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = (Math.cos(x) * (-0.5 * (eps * eps))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -4e-10: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = (math.cos(x) * (-0.5 * (eps * eps))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -4e-10) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(Float64(cos(x) * Float64(-0.5 * Float64(eps * eps))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -4e-10) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = (cos(x) * (-0.5 * (eps * eps))) - (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], -4e-10], 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[(eps * eps), $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 -4 \cdot 10^{-10}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.00000000000000015e-10Initial program 77.2%
diff-cos78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
+-commutative78.7%
metadata-eval78.7%
Applied egg-rr78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
associate-+r+78.4%
+-commutative78.4%
*-commutative78.4%
+-commutative78.4%
associate--l+78.1%
+-inverses78.1%
Simplified78.1%
Taylor expanded in x around 0 77.9%
if -4.00000000000000015e-10 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.2%
Taylor expanded in eps around 0 72.8%
mul-1-neg72.8%
unsub-neg72.8%
associate-*r*72.8%
*-commutative72.8%
unpow272.8%
Simplified72.8%
Final simplification74.3%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -4e-10) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (* eps (- (sin (fma 0.5 eps x))))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -4e-10) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = eps * -sin(fma(0.5, eps, x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -4e-10) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(eps * Float64(-sin(fma(0.5, eps, x)))); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -4e-10], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[N[(0.5 * eps + x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -4 \cdot 10^{-10}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin \left(\mathsf{fma}\left(0.5, \varepsilon, x\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.00000000000000015e-10Initial program 77.2%
diff-cos78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
+-commutative78.7%
metadata-eval78.7%
Applied egg-rr78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
associate-+r+78.4%
+-commutative78.4%
*-commutative78.4%
+-commutative78.4%
associate--l+78.1%
+-inverses78.1%
Simplified78.1%
Taylor expanded in x around 0 77.9%
if -4.00000000000000015e-10 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.2%
diff-cos30.5%
div-inv30.5%
metadata-eval30.5%
div-inv30.5%
+-commutative30.5%
metadata-eval30.5%
Applied egg-rr30.5%
associate-*r*30.5%
*-commutative30.5%
*-commutative30.5%
associate-+r+30.5%
+-commutative30.5%
*-commutative30.5%
+-commutative30.5%
associate--l+75.2%
+-inverses75.2%
Simplified75.2%
Taylor expanded in eps around inf 75.2%
count-275.2%
associate-+r+75.3%
+-commutative75.3%
Simplified75.3%
add-sqr-sqrt41.0%
sqrt-unprod49.8%
pow249.8%
+-commutative49.8%
Applied egg-rr49.8%
unpow249.8%
rem-sqrt-square49.8%
associate-+r+49.8%
distribute-rgt-in49.8%
count-249.8%
distribute-rgt-in49.8%
+-commutative49.8%
distribute-lft-in49.8%
fma-def49.8%
associate-*r*49.8%
metadata-eval49.8%
*-lft-identity49.8%
Simplified49.8%
Taylor expanded in eps around 0 47.4%
mul-1-neg47.4%
*-commutative47.4%
distribute-rgt-neg-in47.4%
unpow147.4%
sqr-pow39.3%
fabs-sqr39.3%
sqr-pow72.6%
unpow172.6%
Simplified72.6%
Final simplification74.2%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (cos (+ eps x)) (cos x)))) (if (<= t_0 -4e-10) t_0 (* eps (- (sin x))))))
double code(double x, double eps) {
double t_0 = cos((eps + x)) - cos(x);
double tmp;
if (t_0 <= -4e-10) {
tmp = t_0;
} else {
tmp = eps * -sin(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = cos((eps + x)) - cos(x)
if (t_0 <= (-4d-10)) then
tmp = t_0
else
tmp = eps * -sin(x)
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 <= -4e-10) {
tmp = t_0;
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): t_0 = math.cos((eps + x)) - math.cos(x) tmp = 0 if t_0 <= -4e-10: tmp = t_0 else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) t_0 = Float64(cos(Float64(eps + x)) - cos(x)) tmp = 0.0 if (t_0 <= -4e-10) tmp = t_0; else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos((eps + x)) - cos(x); tmp = 0.0; if (t_0 <= -4e-10) tmp = t_0; else tmp = eps * -sin(x); 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, -4e-10], t$95$0, N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\varepsilon + x\right) - \cos x\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-10}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.00000000000000015e-10Initial program 77.2%
if -4.00000000000000015e-10 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.2%
Taylor expanded in eps around 0 62.0%
mul-1-neg62.0%
*-commutative62.0%
distribute-rgt-neg-in62.0%
Simplified62.0%
Final simplification66.5%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* eps 0.5)) (sin (* 0.5 (+ x (+ eps x)))))))
double code(double x, double eps) {
return -2.0 * (sin((eps * 0.5)) * sin((0.5 * (x + (eps + x)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((eps * 0.5d0)) * sin((0.5d0 * (x + (eps + x)))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((eps * 0.5)) * Math.sin((0.5 * (x + (eps + x)))));
}
def code(x, eps): return -2.0 * (math.sin((eps * 0.5)) * math.sin((0.5 * (x + (eps + x)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * sin(Float64(0.5 * Float64(x + Float64(eps + x)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((eps * 0.5)) * sin((0.5 * (x + (eps + x))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \left(x + \left(\varepsilon + x\right)\right)\right)\right)
\end{array}
Initial program 37.1%
diff-cos44.8%
div-inv44.8%
metadata-eval44.8%
div-inv44.8%
+-commutative44.8%
metadata-eval44.8%
Applied egg-rr44.8%
associate-*r*44.8%
*-commutative44.8%
*-commutative44.8%
associate-+r+44.7%
+-commutative44.7%
*-commutative44.7%
+-commutative44.7%
associate--l+76.1%
+-inverses76.1%
Simplified76.1%
Taylor expanded in eps around inf 76.1%
count-276.1%
associate-+r+76.2%
+-commutative76.2%
Simplified76.2%
Final simplification76.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -0.075) (not (<= x 3.5e-34))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -0.075) || !(x <= 3.5e-34)) {
tmp = eps * -sin(x);
} else {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-0.075d0)) .or. (.not. (x <= 3.5d-34))) then
tmp = eps * -sin(x)
else
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -0.075) || !(x <= 3.5e-34)) {
tmp = eps * -Math.sin(x);
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -0.075) or not (x <= 3.5e-34): tmp = eps * -math.sin(x) else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -0.075) || !(x <= 3.5e-34)) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -0.075) || ~((x <= 3.5e-34))) tmp = eps * -sin(x); else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -0.075], N[Not[LessEqual[x, 3.5e-34]], $MachinePrecision]], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.075 \lor \neg \left(x \leq 3.5 \cdot 10^{-34}\right):\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if x < -0.0749999999999999972 or 3.5e-34 < x Initial program 8.5%
Taylor expanded in eps around 0 53.8%
mul-1-neg53.8%
*-commutative53.8%
distribute-rgt-neg-in53.8%
Simplified53.8%
if -0.0749999999999999972 < x < 3.5e-34Initial program 75.8%
diff-cos94.6%
div-inv94.6%
metadata-eval94.6%
div-inv94.6%
+-commutative94.6%
metadata-eval94.6%
Applied egg-rr94.6%
associate-*r*94.6%
*-commutative94.6%
*-commutative94.6%
associate-+r+94.6%
+-commutative94.6%
*-commutative94.6%
+-commutative94.6%
associate--l+98.6%
+-inverses98.6%
Simplified98.6%
Taylor expanded in x around 0 94.1%
Final simplification70.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2000000000000.0) (not (<= eps 5.1e-6))) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2000000000000.0) || !(eps <= 5.1e-6)) {
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 <= (-2000000000000.0d0)) .or. (.not. (eps <= 5.1d-6))) 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 <= -2000000000000.0) || !(eps <= 5.1e-6)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2000000000000.0) or not (eps <= 5.1e-6): tmp = math.cos(eps) - math.cos(x) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2000000000000.0) || !(eps <= 5.1e-6)) 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 <= -2000000000000.0) || ~((eps <= 5.1e-6))) tmp = cos(eps) - cos(x); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2000000000000.0], N[Not[LessEqual[eps, 5.1e-6]], $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 -2000000000000 \lor \neg \left(\varepsilon \leq 5.1 \cdot 10^{-6}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -2e12 or 5.1000000000000003e-6 < eps Initial program 50.7%
Taylor expanded in x around 0 52.1%
if -2e12 < eps < 5.1000000000000003e-6Initial program 24.6%
Taylor expanded in eps around 0 82.3%
mul-1-neg82.3%
*-commutative82.3%
distribute-rgt-neg-in82.3%
Simplified82.3%
Final simplification67.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* -0.5 (* eps eps))))
(if (<= eps -0.63)
t_0
(if (<= eps -1.4e-168)
t_1
(if (<= eps 1.85e-165) (* eps (- x)) (if (<= eps 0.00017) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = -0.5 * (eps * eps);
double tmp;
if (eps <= -0.63) {
tmp = t_0;
} else if (eps <= -1.4e-168) {
tmp = t_1;
} else if (eps <= 1.85e-165) {
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 = cos(eps) + (-1.0d0)
t_1 = (-0.5d0) * (eps * eps)
if (eps <= (-0.63d0)) then
tmp = t_0
else if (eps <= (-1.4d-168)) then
tmp = t_1
else if (eps <= 1.85d-165) 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 = Math.cos(eps) + -1.0;
double t_1 = -0.5 * (eps * eps);
double tmp;
if (eps <= -0.63) {
tmp = t_0;
} else if (eps <= -1.4e-168) {
tmp = t_1;
} else if (eps <= 1.85e-165) {
tmp = eps * -x;
} else if (eps <= 0.00017) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = -0.5 * (eps * eps) tmp = 0 if eps <= -0.63: tmp = t_0 elif eps <= -1.4e-168: tmp = t_1 elif eps <= 1.85e-165: tmp = eps * -x elif eps <= 0.00017: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(-0.5 * Float64(eps * eps)) tmp = 0.0 if (eps <= -0.63) tmp = t_0; elseif (eps <= -1.4e-168) tmp = t_1; elseif (eps <= 1.85e-165) 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 = cos(eps) + -1.0; t_1 = -0.5 * (eps * eps); tmp = 0.0; if (eps <= -0.63) tmp = t_0; elseif (eps <= -1.4e-168) tmp = t_1; elseif (eps <= 1.85e-165) 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[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.63], t$95$0, If[LessEqual[eps, -1.4e-168], t$95$1, If[LessEqual[eps, 1.85e-165], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00017], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := -0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{if}\;\varepsilon \leq -0.63:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -1.4 \cdot 10^{-168}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 1.85 \cdot 10^{-165}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00017:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -0.630000000000000004 or 1.7e-4 < eps Initial program 49.6%
Taylor expanded in x around 0 49.5%
if -0.630000000000000004 < eps < -1.4000000000000001e-168 or 1.85000000000000001e-165 < eps < 1.7e-4Initial program 7.1%
Taylor expanded in x around 0 7.5%
Taylor expanded in eps around 0 37.2%
*-commutative37.2%
unpow237.2%
Simplified37.2%
if -1.4000000000000001e-168 < eps < 1.85000000000000001e-165Initial program 42.6%
Taylor expanded in eps around 0 99.9%
mul-1-neg99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 52.8%
associate-*r*52.8%
neg-mul-152.8%
Simplified52.8%
Final simplification47.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2000000000000.0) (not (<= eps 1.4e-5))) (+ (cos eps) -1.0) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2000000000000.0) || !(eps <= 1.4e-5)) {
tmp = cos(eps) + -1.0;
} else {
tmp = eps * -sin(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-2000000000000.0d0)) .or. (.not. (eps <= 1.4d-5))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2000000000000.0) || !(eps <= 1.4e-5)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2000000000000.0) or not (eps <= 1.4e-5): tmp = math.cos(eps) + -1.0 else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2000000000000.0) || !(eps <= 1.4e-5)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2000000000000.0) || ~((eps <= 1.4e-5))) tmp = cos(eps) + -1.0; else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2000000000000.0], N[Not[LessEqual[eps, 1.4e-5]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2000000000000 \lor \neg \left(\varepsilon \leq 1.4 \cdot 10^{-5}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -2e12 or 1.39999999999999998e-5 < eps Initial program 50.7%
Taylor expanded in x around 0 50.7%
if -2e12 < eps < 1.39999999999999998e-5Initial program 24.6%
Taylor expanded in eps around 0 82.3%
mul-1-neg82.3%
*-commutative82.3%
distribute-rgt-neg-in82.3%
Simplified82.3%
Final simplification67.1%
(FPCore (x eps) :precision binary64 (if (<= x 1.05e-59) (* -0.5 (* eps eps)) (* eps (- x))))
double code(double x, double eps) {
double tmp;
if (x <= 1.05e-59) {
tmp = -0.5 * (eps * eps);
} 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 (x <= 1.05d-59) then
tmp = (-0.5d0) * (eps * eps)
else
tmp = eps * -x
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 1.05e-59) {
tmp = -0.5 * (eps * eps);
} else {
tmp = eps * -x;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 1.05e-59: tmp = -0.5 * (eps * eps) else: tmp = eps * -x return tmp
function code(x, eps) tmp = 0.0 if (x <= 1.05e-59) tmp = Float64(-0.5 * Float64(eps * eps)); else tmp = Float64(eps * Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 1.05e-59) tmp = -0.5 * (eps * eps); else tmp = eps * -x; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 1.05e-59], N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision], N[(eps * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{-59}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\end{array}
\end{array}
if x < 1.04999999999999998e-59Initial program 48.3%
Taylor expanded in x around 0 48.6%
Taylor expanded in eps around 0 30.6%
*-commutative30.6%
unpow230.6%
Simplified30.6%
if 1.04999999999999998e-59 < x Initial program 13.9%
Taylor expanded in eps around 0 57.6%
mul-1-neg57.6%
*-commutative57.6%
distribute-rgt-neg-in57.6%
Simplified57.6%
Taylor expanded in x around 0 12.5%
associate-*r*12.5%
neg-mul-112.5%
Simplified12.5%
Final simplification24.7%
(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 37.1%
Taylor expanded in eps around 0 44.6%
mul-1-neg44.6%
*-commutative44.6%
distribute-rgt-neg-in44.6%
Simplified44.6%
Taylor expanded in x around 0 17.7%
associate-*r*17.7%
neg-mul-117.7%
Simplified17.7%
Final simplification17.7%
(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 37.1%
add-cube-cbrt37.1%
pow337.1%
Applied egg-rr37.1%
Taylor expanded in eps around 0 14.3%
pow-base-114.3%
*-lft-identity14.3%
+-inverses14.3%
Simplified14.3%
Final simplification14.3%
herbie shell --seed 2023187
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))