
(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 (fma (sin x) (- (sin eps)) (* (cos x) (* (/ (sin eps) -1.0) (tan (/ eps 2.0))))))
double code(double x, double eps) {
return fma(sin(x), -sin(eps), (cos(x) * ((sin(eps) / -1.0) * tan((eps / 2.0)))));
}
function code(x, eps) return fma(sin(x), Float64(-sin(eps)), Float64(cos(x) * Float64(Float64(sin(eps) / -1.0) * tan(Float64(eps / 2.0))))) end
code[x_, eps_] := N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision]) + N[(N[Cos[x], $MachinePrecision] * N[(N[(N[Sin[eps], $MachinePrecision] / -1.0), $MachinePrecision] * N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin x, -\sin \varepsilon, \cos x \cdot \left(\frac{\sin \varepsilon}{-1} \cdot \tan \left(\frac{\varepsilon}{2}\right)\right)\right)
\end{array}
Initial program 37.2%
cos-sum61.1%
cancel-sign-sub-inv61.1%
fma-def61.1%
Applied egg-rr61.1%
Taylor expanded in x around inf 61.1%
associate--l+90.6%
*-commutative90.6%
neg-mul-190.6%
distribute-rgt-neg-in90.6%
fma-def90.6%
*-rgt-identity90.6%
distribute-lft-out--90.6%
sub-neg90.6%
metadata-eval90.6%
+-commutative90.6%
Simplified90.6%
flip-+90.2%
metadata-eval90.2%
1-sub-cos99.1%
pow299.1%
Applied egg-rr99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-neg-in99.1%
+-commutative99.1%
metadata-eval99.1%
sub-neg99.1%
unpow299.1%
neg-mul-199.1%
times-frac99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
hang-0p-tan99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (fma (* (sin eps) (- (cos x))) (tan (* eps 0.5)) (* (sin x) (- (sin eps)))))
double code(double x, double eps) {
return fma((sin(eps) * -cos(x)), tan((eps * 0.5)), (sin(x) * -sin(eps)));
}
function code(x, eps) return fma(Float64(sin(eps) * Float64(-cos(x))), tan(Float64(eps * 0.5)), Float64(sin(x) * Float64(-sin(eps)))) end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * (-N[Cos[x], $MachinePrecision])), $MachinePrecision] * N[Tan[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \varepsilon \cdot \left(-\cos x\right), \tan \left(\varepsilon \cdot 0.5\right), \sin x \cdot \left(-\sin \varepsilon\right)\right)
\end{array}
Initial program 37.2%
cos-sum61.1%
cancel-sign-sub-inv61.1%
fma-def61.1%
Applied egg-rr61.1%
Taylor expanded in x around inf 61.1%
associate--l+90.6%
*-commutative90.6%
neg-mul-190.6%
distribute-rgt-neg-in90.6%
fma-def90.6%
*-rgt-identity90.6%
distribute-lft-out--90.6%
sub-neg90.6%
metadata-eval90.6%
+-commutative90.6%
Simplified90.6%
flip-+90.2%
metadata-eval90.2%
1-sub-cos99.1%
pow299.1%
Applied egg-rr99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-neg-in99.1%
+-commutative99.1%
metadata-eval99.1%
sub-neg99.1%
unpow299.1%
neg-mul-199.1%
times-frac99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
hang-0p-tan99.5%
Simplified99.5%
fma-udef99.5%
div-inv99.5%
metadata-eval99.5%
div-inv99.5%
metadata-eval99.5%
Applied egg-rr99.5%
distribute-rgt-neg-in99.5%
+-commutative99.5%
associate-*r*99.5%
fma-def99.5%
*-commutative99.5%
neg-mul-199.5%
*-commutative99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (- (* (sin x) (- (sin eps))) (* (cos x) (* (sin eps) (tan (* eps 0.5))))))
double code(double x, double eps) {
return (sin(x) * -sin(eps)) - (cos(x) * (sin(eps) * tan((eps * 0.5))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(x) * -sin(eps)) - (cos(x) * (sin(eps) * tan((eps * 0.5d0))))
end function
public static double code(double x, double eps) {
return (Math.sin(x) * -Math.sin(eps)) - (Math.cos(x) * (Math.sin(eps) * Math.tan((eps * 0.5))));
}
def code(x, eps): return (math.sin(x) * -math.sin(eps)) - (math.cos(x) * (math.sin(eps) * math.tan((eps * 0.5))))
function code(x, eps) return Float64(Float64(sin(x) * Float64(-sin(eps))) - Float64(cos(x) * Float64(sin(eps) * tan(Float64(eps * 0.5))))) end
function tmp = code(x, eps) tmp = (sin(x) * -sin(eps)) - (cos(x) * (sin(eps) * tan((eps * 0.5)))); end
code[x_, eps_] := N[(N[(N[Sin[x], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] * N[(N[Sin[eps], $MachinePrecision] * N[Tan[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \left(-\sin \varepsilon\right) - \cos x \cdot \left(\sin \varepsilon \cdot \tan \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 37.2%
cos-sum61.1%
cancel-sign-sub-inv61.1%
fma-def61.1%
Applied egg-rr61.1%
Taylor expanded in x around inf 61.1%
associate--l+90.6%
*-commutative90.6%
neg-mul-190.6%
distribute-rgt-neg-in90.6%
fma-def90.6%
*-rgt-identity90.6%
distribute-lft-out--90.6%
sub-neg90.6%
metadata-eval90.6%
+-commutative90.6%
Simplified90.6%
flip-+90.2%
metadata-eval90.2%
1-sub-cos99.1%
pow299.1%
Applied egg-rr99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-neg-in99.1%
+-commutative99.1%
metadata-eval99.1%
sub-neg99.1%
unpow299.1%
neg-mul-199.1%
times-frac99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
hang-0p-tan99.5%
Simplified99.5%
fma-udef99.5%
div-inv99.5%
metadata-eval99.5%
div-inv99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ x eps)) (cos x)) -5e-12) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (- (* -0.5 (* eps (* eps (cos x)))) (* (sin x) eps))))
double code(double x, double eps) {
double tmp;
if ((cos((x + eps)) - cos(x)) <= -5e-12) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) - (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((x + eps)) - cos(x)) <= (-5d-12)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) - (sin(x) * eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((x + eps)) - Math.cos(x)) <= -5e-12) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) - (Math.sin(x) * eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((x + eps)) - math.cos(x)) <= -5e-12: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) - (math.sin(x) * eps) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(x + eps)) - cos(x)) <= -5e-12) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) - Float64(sin(x) * eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((x + eps)) - cos(x)) <= -5e-12) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = (-0.5 * (eps * (eps * cos(x)))) - (sin(x) * eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(x + eps), $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[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(x + \varepsilon\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) - \sin x \cdot \varepsilon\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 81.4%
diff-cos82.6%
div-inv82.6%
metadata-eval82.6%
div-inv82.6%
+-commutative82.6%
metadata-eval82.6%
Applied egg-rr82.6%
*-commutative82.6%
+-commutative82.6%
associate--l+82.6%
+-inverses82.6%
distribute-lft-in82.6%
metadata-eval82.6%
*-commutative82.6%
+-commutative82.6%
Simplified82.6%
Taylor expanded in x around 0 82.6%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 14.0%
Taylor expanded in eps around 0 71.9%
mul-1-neg71.9%
unsub-neg71.9%
unpow271.9%
associate-*l*71.9%
Simplified71.9%
Final simplification75.6%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.00015) (not (<= eps 0.000135)))
(- (* (cos x) (+ -1.0 (cos eps))) (* (sin x) (sin eps)))
(+
(* -0.5 (* eps (* eps (cos x))))
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps));
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - 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.00015d0)) .or. (.not. (eps <= 0.000135d0))) then
tmp = (cos(x) * ((-1.0d0) + cos(eps))) - (sin(x) * sin(eps))
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666d0 * (eps ** 3.0d0)) - eps))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = (Math.cos(x) * (-1.0 + Math.cos(eps))) - (Math.sin(x) * Math.sin(eps));
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) + (Math.sin(x) * ((0.16666666666666666 * Math.pow(eps, 3.0)) - eps));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00015) or not (eps <= 0.000135): tmp = (math.cos(x) * (-1.0 + math.cos(eps))) - (math.sin(x) * math.sin(eps)) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) + (math.sin(x) * ((0.16666666666666666 * math.pow(eps, 3.0)) - eps)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00015) || !(eps <= 0.000135)) tmp = Float64(Float64(cos(x) * Float64(-1.0 + cos(eps))) - Float64(sin(x) * sin(eps))); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) + Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00015) || ~((eps <= 0.000135))) tmp = (cos(x) * (-1.0 + cos(eps))) - (sin(x) * sin(eps)); else tmp = (-0.5 * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666 * (eps ^ 3.0)) - eps)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00015], N[Not[LessEqual[eps, 0.000135]], $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[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00015 \lor \neg \left(\varepsilon \leq 0.000135\right):\\
\;\;\;\;\cos x \cdot \left(-1 + \cos \varepsilon\right) - \sin x \cdot \sin \varepsilon\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) + \sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.49999999999999987e-4 or 1.35000000000000002e-4 < eps Initial program 55.0%
cos-sum99.0%
cancel-sign-sub-inv99.0%
fma-def99.1%
Applied egg-rr99.1%
Taylor expanded in x around inf 99.0%
associate--l+99.1%
*-commutative99.1%
neg-mul-199.1%
distribute-rgt-neg-in99.1%
fma-def99.1%
*-rgt-identity99.1%
distribute-lft-out--99.1%
sub-neg99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in x around inf 99.1%
+-commutative99.1%
sub-neg99.1%
metadata-eval99.1%
+-commutative99.1%
mul-1-neg99.1%
unsub-neg99.1%
+-commutative99.1%
*-commutative99.1%
Simplified99.1%
if -1.49999999999999987e-4 < eps < 1.35000000000000002e-4Initial program 17.3%
Taylor expanded in eps around 0 99.4%
+-commutative99.4%
associate-+l+99.4%
unpow299.4%
associate-*l*99.4%
associate-*r*99.4%
associate-*r*99.4%
distribute-rgt-out99.4%
mul-1-neg99.4%
Simplified99.4%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))) (t_1 (* -2.0 (* (sin x) t_0))))
(if (<= x -0.03)
t_1
(if (<= x -7e-111)
(- (+ -1.0 (cos eps)) (* x (sin eps)))
(if (<= x 8.8e-27) (* -2.0 (pow t_0 2.0)) t_1)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double t_1 = -2.0 * (sin(x) * t_0);
double tmp;
if (x <= -0.03) {
tmp = t_1;
} else if (x <= -7e-111) {
tmp = (-1.0 + cos(eps)) - (x * sin(eps));
} else if (x <= 8.8e-27) {
tmp = -2.0 * pow(t_0, 2.0);
} else {
tmp = t_1;
}
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 = sin((eps * 0.5d0))
t_1 = (-2.0d0) * (sin(x) * t_0)
if (x <= (-0.03d0)) then
tmp = t_1
else if (x <= (-7d-111)) then
tmp = ((-1.0d0) + cos(eps)) - (x * sin(eps))
else if (x <= 8.8d-27) then
tmp = (-2.0d0) * (t_0 ** 2.0d0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps * 0.5));
double t_1 = -2.0 * (Math.sin(x) * t_0);
double tmp;
if (x <= -0.03) {
tmp = t_1;
} else if (x <= -7e-111) {
tmp = (-1.0 + Math.cos(eps)) - (x * Math.sin(eps));
} else if (x <= 8.8e-27) {
tmp = -2.0 * Math.pow(t_0, 2.0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) t_1 = -2.0 * (math.sin(x) * t_0) tmp = 0 if x <= -0.03: tmp = t_1 elif x <= -7e-111: tmp = (-1.0 + math.cos(eps)) - (x * math.sin(eps)) elif x <= 8.8e-27: tmp = -2.0 * math.pow(t_0, 2.0) else: tmp = t_1 return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) t_1 = Float64(-2.0 * Float64(sin(x) * t_0)) tmp = 0.0 if (x <= -0.03) tmp = t_1; elseif (x <= -7e-111) tmp = Float64(Float64(-1.0 + cos(eps)) - Float64(x * sin(eps))); elseif (x <= 8.8e-27) tmp = Float64(-2.0 * (t_0 ^ 2.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); t_1 = -2.0 * (sin(x) * t_0); tmp = 0.0; if (x <= -0.03) tmp = t_1; elseif (x <= -7e-111) tmp = (-1.0 + cos(eps)) - (x * sin(eps)); elseif (x <= 8.8e-27) tmp = -2.0 * (t_0 ^ 2.0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-2.0 * N[(N[Sin[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.03], t$95$1, If[LessEqual[x, -7e-111], N[(N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.8e-27], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
t_1 := -2 \cdot \left(\sin x \cdot t_0\right)\\
\mathbf{if}\;x \leq -0.03:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-111}:\\
\;\;\;\;\left(-1 + \cos \varepsilon\right) - x \cdot \sin \varepsilon\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-27}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -0.029999999999999999 or 8.79999999999999948e-27 < x Initial program 8.1%
diff-cos7.2%
div-inv7.2%
metadata-eval7.2%
div-inv7.2%
+-commutative7.2%
metadata-eval7.2%
Applied egg-rr7.2%
*-commutative7.2%
+-commutative7.2%
associate--l+57.0%
+-inverses57.0%
distribute-lft-in57.0%
metadata-eval57.0%
*-commutative57.0%
+-commutative57.0%
Simplified57.0%
add-exp-log23.0%
*-commutative23.0%
*-commutative23.0%
+-commutative23.0%
+-rgt-identity23.0%
Applied egg-rr23.0%
add-exp-log57.0%
+-commutative57.0%
*-commutative57.0%
Applied egg-rr57.0%
Taylor expanded in eps around 0 56.9%
if -0.029999999999999999 < x < -7.0000000000000001e-111Initial program 38.1%
Taylor expanded in x around 0 41.4%
sub-neg41.4%
metadata-eval41.4%
+-commutative41.4%
associate-+r+91.5%
+-commutative91.5%
+-commutative91.5%
mul-1-neg91.5%
unsub-neg91.5%
*-commutative91.5%
unpow291.5%
associate-*l*91.5%
distribute-lft-out--91.5%
Simplified91.5%
Taylor expanded in x around 0 91.0%
associate-*r*91.0%
mul-1-neg91.0%
Simplified91.0%
if -7.0000000000000001e-111 < x < 8.79999999999999948e-27Initial program 75.5%
diff-cos96.0%
div-inv96.0%
metadata-eval96.0%
div-inv96.0%
+-commutative96.0%
metadata-eval96.0%
Applied egg-rr96.0%
*-commutative96.0%
+-commutative96.0%
associate--l+99.6%
+-inverses99.6%
distribute-lft-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around 0 95.2%
Final simplification74.6%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* eps 0.5)) (sin (* 0.5 (- eps (* x -2.0)))))))
double code(double x, double eps) {
return -2.0 * (sin((eps * 0.5)) * sin((0.5 * (eps - (x * -2.0)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((eps * 0.5d0)) * sin((0.5d0 * (eps - (x * (-2.0d0))))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((eps * 0.5)) * Math.sin((0.5 * (eps - (x * -2.0)))));
}
def code(x, eps): return -2.0 * (math.sin((eps * 0.5)) * math.sin((0.5 * (eps - (x * -2.0)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * sin(Float64(0.5 * Float64(eps - Float64(x * -2.0)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((eps * 0.5)) * sin((0.5 * (eps - (x * -2.0))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps - N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon - x \cdot -2\right)\right)\right)
\end{array}
Initial program 37.2%
diff-cos45.3%
div-inv45.3%
metadata-eval45.3%
div-inv45.3%
+-commutative45.3%
metadata-eval45.3%
Applied egg-rr45.3%
*-commutative45.3%
+-commutative45.3%
associate--l+76.5%
+-inverses76.5%
distribute-lft-in76.5%
metadata-eval76.5%
*-commutative76.5%
+-commutative76.5%
Simplified76.5%
Taylor expanded in x around -inf 76.4%
Final simplification76.4%
(FPCore (x eps) :precision binary64 (* (sin (* eps 0.5)) (* -2.0 (sin (* 0.5 (- eps (* x -2.0)))))))
double code(double x, double eps) {
return sin((eps * 0.5)) * (-2.0 * sin((0.5 * (eps - (x * -2.0)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin((eps * 0.5d0)) * ((-2.0d0) * sin((0.5d0 * (eps - (x * (-2.0d0))))))
end function
public static double code(double x, double eps) {
return Math.sin((eps * 0.5)) * (-2.0 * Math.sin((0.5 * (eps - (x * -2.0)))));
}
def code(x, eps): return math.sin((eps * 0.5)) * (-2.0 * math.sin((0.5 * (eps - (x * -2.0)))))
function code(x, eps) return Float64(sin(Float64(eps * 0.5)) * Float64(-2.0 * sin(Float64(0.5 * Float64(eps - Float64(x * -2.0)))))) end
function tmp = code(x, eps) tmp = sin((eps * 0.5)) * (-2.0 * sin((0.5 * (eps - (x * -2.0))))); end
code[x_, eps_] := N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[Sin[N[(0.5 * N[(eps - N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(\varepsilon \cdot 0.5\right) \cdot \left(-2 \cdot \sin \left(0.5 \cdot \left(\varepsilon - x \cdot -2\right)\right)\right)
\end{array}
Initial program 37.2%
diff-cos45.3%
div-inv45.3%
metadata-eval45.3%
div-inv45.3%
+-commutative45.3%
metadata-eval45.3%
Applied egg-rr45.3%
*-commutative45.3%
+-commutative45.3%
associate--l+76.5%
+-inverses76.5%
distribute-lft-in76.5%
metadata-eval76.5%
*-commutative76.5%
+-commutative76.5%
Simplified76.5%
add-exp-log20.1%
*-commutative20.1%
*-commutative20.1%
+-commutative20.1%
+-rgt-identity20.1%
Applied egg-rr20.1%
Taylor expanded in x around inf 76.4%
*-commutative76.4%
metadata-eval76.4%
cancel-sign-sub-inv76.4%
associate-*r*76.5%
Simplified76.5%
Final simplification76.5%
(FPCore (x eps) :precision binary64 (* (* (sin (* 0.5 (+ x (+ x eps)))) (sin (* eps 0.5))) -2.0))
double code(double x, double eps) {
return (sin((0.5 * (x + (x + eps)))) * sin((eps * 0.5))) * -2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin((0.5d0 * (x + (x + eps)))) * sin((eps * 0.5d0))) * (-2.0d0)
end function
public static double code(double x, double eps) {
return (Math.sin((0.5 * (x + (x + eps)))) * Math.sin((eps * 0.5))) * -2.0;
}
def code(x, eps): return (math.sin((0.5 * (x + (x + eps)))) * math.sin((eps * 0.5))) * -2.0
function code(x, eps) return Float64(Float64(sin(Float64(0.5 * Float64(x + Float64(x + eps)))) * sin(Float64(eps * 0.5))) * -2.0) end
function tmp = code(x, eps) tmp = (sin((0.5 * (x + (x + eps)))) * sin((eps * 0.5))) * -2.0; end
code[x_, eps_] := N[(N[(N[Sin[N[(0.5 * N[(x + N[(x + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin \left(0.5 \cdot \left(x + \left(x + \varepsilon\right)\right)\right) \cdot \sin \left(\varepsilon \cdot 0.5\right)\right) \cdot -2
\end{array}
Initial program 37.2%
diff-cos45.3%
div-inv45.3%
metadata-eval45.3%
div-inv45.3%
+-commutative45.3%
metadata-eval45.3%
Applied egg-rr45.3%
*-commutative45.3%
+-commutative45.3%
associate--l+76.5%
+-inverses76.5%
distribute-lft-in76.5%
metadata-eval76.5%
*-commutative76.5%
+-commutative76.5%
Simplified76.5%
add-exp-log20.1%
*-commutative20.1%
*-commutative20.1%
+-commutative20.1%
+-rgt-identity20.1%
Applied egg-rr20.1%
add-exp-log76.5%
+-commutative76.5%
*-commutative76.5%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -8.5e-92) (not (<= x 8.8e-27)))
(* -2.0 (* (sin x) t_0))
(* -2.0 (pow t_0 2.0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((x <= -8.5e-92) || !(x <= 8.8e-27)) {
tmp = -2.0 * (sin(x) * t_0);
} else {
tmp = -2.0 * pow(t_0, 2.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin((eps * 0.5d0))
if ((x <= (-8.5d-92)) .or. (.not. (x <= 8.8d-27))) then
tmp = (-2.0d0) * (sin(x) * t_0)
else
tmp = (-2.0d0) * (t_0 ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps * 0.5));
double tmp;
if ((x <= -8.5e-92) || !(x <= 8.8e-27)) {
tmp = -2.0 * (Math.sin(x) * t_0);
} else {
tmp = -2.0 * Math.pow(t_0, 2.0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (x <= -8.5e-92) or not (x <= 8.8e-27): tmp = -2.0 * (math.sin(x) * t_0) else: tmp = -2.0 * math.pow(t_0, 2.0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if ((x <= -8.5e-92) || !(x <= 8.8e-27)) tmp = Float64(-2.0 * Float64(sin(x) * t_0)); else tmp = Float64(-2.0 * (t_0 ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps * 0.5)); tmp = 0.0; if ((x <= -8.5e-92) || ~((x <= 8.8e-27))) tmp = -2.0 * (sin(x) * t_0); else tmp = -2.0 * (t_0 ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x, -8.5e-92], N[Not[LessEqual[x, 8.8e-27]], $MachinePrecision]], N[(-2.0 * N[(N[Sin[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{-92} \lor \neg \left(x \leq 8.8 \cdot 10^{-27}\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -8.50000000000000067e-92 or 8.79999999999999948e-27 < x Initial program 10.3%
diff-cos10.1%
div-inv10.1%
metadata-eval10.1%
div-inv10.1%
+-commutative10.1%
metadata-eval10.1%
Applied egg-rr10.1%
*-commutative10.1%
+-commutative10.1%
associate--l+60.0%
+-inverses60.0%
distribute-lft-in60.0%
metadata-eval60.0%
*-commutative60.0%
+-commutative60.0%
Simplified60.0%
add-exp-log24.0%
*-commutative24.0%
*-commutative24.0%
+-commutative24.0%
+-rgt-identity24.0%
Applied egg-rr24.0%
add-exp-log60.0%
+-commutative60.0%
*-commutative60.0%
Applied egg-rr60.0%
Taylor expanded in eps around 0 56.8%
if -8.50000000000000067e-92 < x < 8.79999999999999948e-27Initial program 74.7%
diff-cos94.4%
div-inv94.4%
metadata-eval94.4%
div-inv94.4%
+-commutative94.4%
metadata-eval94.4%
Applied egg-rr94.4%
*-commutative94.4%
+-commutative94.4%
associate--l+99.5%
+-inverses99.5%
distribute-lft-in99.5%
metadata-eval99.5%
*-commutative99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in x around 0 93.7%
Final simplification72.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -8.5e-92) (not (<= x 1.2e-21))) (* (sin x) (- eps)) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -8.5e-92) || !(x <= 1.2e-21)) {
tmp = sin(x) * -eps;
} 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 <= (-8.5d-92)) .or. (.not. (x <= 1.2d-21))) then
tmp = sin(x) * -eps
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 <= -8.5e-92) || !(x <= 1.2e-21)) {
tmp = Math.sin(x) * -eps;
} else {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -8.5e-92) or not (x <= 1.2e-21): tmp = math.sin(x) * -eps else: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -8.5e-92) || !(x <= 1.2e-21)) tmp = Float64(sin(x) * Float64(-eps)); 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 <= -8.5e-92) || ~((x <= 1.2e-21))) tmp = sin(x) * -eps; else tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -8.5e-92], N[Not[LessEqual[x, 1.2e-21]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * (-eps)), $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 -8.5 \cdot 10^{-92} \lor \neg \left(x \leq 1.2 \cdot 10^{-21}\right):\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\end{array}
\end{array}
if x < -8.50000000000000067e-92 or 1.2e-21 < x Initial program 10.3%
Taylor expanded in eps around 0 53.5%
associate-*r*53.5%
mul-1-neg53.5%
Simplified53.5%
if -8.50000000000000067e-92 < x < 1.2e-21Initial program 74.7%
diff-cos94.4%
div-inv94.4%
metadata-eval94.4%
div-inv94.4%
+-commutative94.4%
metadata-eval94.4%
Applied egg-rr94.4%
*-commutative94.4%
+-commutative94.4%
associate--l+99.5%
+-inverses99.5%
distribute-lft-in99.5%
metadata-eval99.5%
*-commutative99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in x around 0 93.7%
Final simplification70.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.7e-11) (not (<= eps 1.9e-6))) (- (cos eps) (cos x)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.7e-11) || !(eps <= 1.9e-6)) {
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 <= (-2.7d-11)) .or. (.not. (eps <= 1.9d-6))) 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 <= -2.7e-11) || !(eps <= 1.9e-6)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.7e-11) or not (eps <= 1.9e-6): tmp = math.cos(eps) - math.cos(x) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.7e-11) || !(eps <= 1.9e-6)) 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 <= -2.7e-11) || ~((eps <= 1.9e-6))) tmp = cos(eps) - cos(x); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.7e-11], N[Not[LessEqual[eps, 1.9e-6]], $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 -2.7 \cdot 10^{-11} \lor \neg \left(\varepsilon \leq 1.9 \cdot 10^{-6}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -2.70000000000000005e-11 or 1.9e-6 < eps Initial program 54.2%
Taylor expanded in x around 0 56.2%
if -2.70000000000000005e-11 < eps < 1.9e-6Initial program 17.0%
Taylor expanded in eps around 0 82.9%
associate-*r*82.9%
mul-1-neg82.9%
Simplified82.9%
Final simplification68.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.7e-11) (not (<= eps 2.7e-6))) (+ -1.0 (cos eps)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.7e-11) || !(eps <= 2.7e-6)) {
tmp = -1.0 + cos(eps);
} 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 <= (-2.7d-11)) .or. (.not. (eps <= 2.7d-6))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2.7e-11) || !(eps <= 2.7e-6)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.7e-11) or not (eps <= 2.7e-6): tmp = -1.0 + math.cos(eps) else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.7e-11) || !(eps <= 2.7e-6)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.7e-11) || ~((eps <= 2.7e-6))) tmp = -1.0 + cos(eps); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.7e-11], N[Not[LessEqual[eps, 2.7e-6]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.7 \cdot 10^{-11} \lor \neg \left(\varepsilon \leq 2.7 \cdot 10^{-6}\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -2.70000000000000005e-11 or 2.69999999999999998e-6 < eps Initial program 54.2%
Taylor expanded in x around 0 55.0%
if -2.70000000000000005e-11 < eps < 2.69999999999999998e-6Initial program 17.0%
Taylor expanded in eps around 0 82.9%
associate-*r*82.9%
mul-1-neg82.9%
Simplified82.9%
Final simplification67.8%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00015) (not (<= eps 0.000135))) (+ -1.0 (cos eps)) (* -0.5 (* eps eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = -1.0 + cos(eps);
} else {
tmp = -0.5 * (eps * eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.00015d0)) .or. (.not. (eps <= 0.000135d0))) then
tmp = (-1.0d0) + cos(eps)
else
tmp = (-0.5d0) * (eps * eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00015) || !(eps <= 0.000135)) {
tmp = -1.0 + Math.cos(eps);
} else {
tmp = -0.5 * (eps * eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00015) or not (eps <= 0.000135): tmp = -1.0 + math.cos(eps) else: tmp = -0.5 * (eps * eps) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00015) || !(eps <= 0.000135)) tmp = Float64(-1.0 + cos(eps)); else tmp = Float64(-0.5 * Float64(eps * eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00015) || ~((eps <= 0.000135))) tmp = -1.0 + cos(eps); else tmp = -0.5 * (eps * eps); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00015], N[Not[LessEqual[eps, 0.000135]], $MachinePrecision]], N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00015 \lor \neg \left(\varepsilon \leq 0.000135\right):\\
\;\;\;\;-1 + \cos \varepsilon\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\end{array}
\end{array}
if eps < -1.49999999999999987e-4 or 1.35000000000000002e-4 < eps Initial program 55.0%
Taylor expanded in x around 0 55.8%
if -1.49999999999999987e-4 < eps < 1.35000000000000002e-4Initial program 17.3%
Taylor expanded in x around 0 17.3%
Taylor expanded in eps around 0 34.2%
unpow234.2%
Simplified34.2%
Final simplification45.6%
(FPCore (x eps) :precision binary64 (* -0.5 (* eps eps)))
double code(double x, double eps) {
return -0.5 * (eps * eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-0.5d0) * (eps * eps)
end function
public static double code(double x, double eps) {
return -0.5 * (eps * eps);
}
def code(x, eps): return -0.5 * (eps * eps)
function code(x, eps) return Float64(-0.5 * Float64(eps * eps)) end
function tmp = code(x, eps) tmp = -0.5 * (eps * eps); end
code[x_, eps_] := N[(-0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)
\end{array}
Initial program 37.2%
Taylor expanded in x around 0 37.6%
Taylor expanded in eps around 0 18.1%
unpow218.1%
Simplified18.1%
Final simplification18.1%
herbie shell --seed 2023273
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))