
(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 -2.95e-5)
(- (- (* (cos x) (cos eps)) (cos x)) (* (sin eps) (sin x)))
(if (<= eps 3.7e-5)
(- (* -0.5 (* eps (* (cos x) eps))) (* eps (sin x)))
(- (fma (cos x) (cos eps) (* (sin x) (- (sin eps)))) (cos x)))))
double code(double x, double eps) {
double tmp;
if (eps <= -2.95e-5) {
tmp = ((cos(x) * cos(eps)) - cos(x)) - (sin(eps) * sin(x));
} else if (eps <= 3.7e-5) {
tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x));
} else {
tmp = fma(cos(x), cos(eps), (sin(x) * -sin(eps))) - cos(x);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -2.95e-5) tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - cos(x)) - Float64(sin(eps) * sin(x))); elseif (eps <= 3.7e-5) tmp = Float64(Float64(-0.5 * Float64(eps * Float64(cos(x) * eps))) - Float64(eps * sin(x))); else tmp = Float64(fma(cos(x), cos(eps), Float64(sin(x) * Float64(-sin(eps)))) - cos(x)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -2.95e-5], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.7e-5], N[(N[(-0.5 * N[(eps * N[(N[Cos[x], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.95 \cdot 10^{-5}:\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \cos x\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{elif}\;\varepsilon \leq 3.7 \cdot 10^{-5}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\cos x \cdot \varepsilon\right)\right) - \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon, \sin x \cdot \left(-\sin \varepsilon\right)\right) - \cos x\\
\end{array}
\end{array}
if eps < -2.9499999999999999e-5Initial program 45.3%
sub-neg45.3%
cos-sum98.6%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
Taylor expanded in x around -inf 98.5%
associate--r+98.8%
cancel-sign-sub-inv98.8%
*-commutative98.8%
*-un-lft-identity98.8%
distribute-rgt-out--98.7%
Applied egg-rr98.7%
sub-neg98.7%
metadata-eval98.7%
distribute-lft-in98.8%
Applied egg-rr98.8%
if -2.9499999999999999e-5 < eps < 3.69999999999999981e-5Initial program 25.3%
Taylor expanded in eps around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
unpow299.7%
associate-*l*99.7%
Simplified99.7%
if 3.69999999999999981e-5 < eps Initial program 47.2%
cos-sum99.0%
cancel-sign-sub-inv99.0%
fma-def99.0%
Applied egg-rr99.0%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (- (* (- (cos x)) (/ (pow (sin eps) 2.0) (+ (cos eps) 1.0))) (* (sin eps) (sin x))))
double code(double x, double eps) {
return (-cos(x) * (pow(sin(eps), 2.0) / (cos(eps) + 1.0))) - (sin(eps) * sin(x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-cos(x) * ((sin(eps) ** 2.0d0) / (cos(eps) + 1.0d0))) - (sin(eps) * sin(x))
end function
public static double code(double x, double eps) {
return (-Math.cos(x) * (Math.pow(Math.sin(eps), 2.0) / (Math.cos(eps) + 1.0))) - (Math.sin(eps) * Math.sin(x));
}
def code(x, eps): return (-math.cos(x) * (math.pow(math.sin(eps), 2.0) / (math.cos(eps) + 1.0))) - (math.sin(eps) * math.sin(x))
function code(x, eps) return Float64(Float64(Float64(-cos(x)) * Float64((sin(eps) ^ 2.0) / Float64(cos(eps) + 1.0))) - Float64(sin(eps) * sin(x))) end
function tmp = code(x, eps) tmp = (-cos(x) * ((sin(eps) ^ 2.0) / (cos(eps) + 1.0))) - (sin(eps) * sin(x)); end
code[x_, eps_] := N[(N[((-N[Cos[x], $MachinePrecision]) * N[(N[Power[N[Sin[eps], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[Cos[eps], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-\cos x\right) \cdot \frac{{\sin \varepsilon}^{2}}{\cos \varepsilon + 1} - \sin \varepsilon \cdot \sin x
\end{array}
Initial program 34.8%
sub-neg34.8%
cos-sum58.7%
associate-+l-58.7%
fma-neg58.7%
Applied egg-rr58.7%
Taylor expanded in x around -inf 58.7%
associate--r+88.8%
cancel-sign-sub-inv88.8%
*-commutative88.8%
*-un-lft-identity88.8%
distribute-rgt-out--88.9%
Applied egg-rr88.9%
flip--88.5%
metadata-eval88.5%
fma-neg88.8%
metadata-eval88.8%
Applied egg-rr88.8%
fma-udef88.5%
-1-add-cos99.1%
unpow299.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin eps) (sin x))))
(if (<= eps -3e-5)
(- (- (* (cos x) (cos eps)) (cos x)) t_0)
(if (<= eps 2.7e-5)
(- (* -0.5 (* eps (* (cos x) eps))) (* eps (sin x)))
(- (* (cos x) (+ (cos eps) -1.0)) t_0)))))
double code(double x, double eps) {
double t_0 = sin(eps) * sin(x);
double tmp;
if (eps <= -3e-5) {
tmp = ((cos(x) * cos(eps)) - cos(x)) - t_0;
} else if (eps <= 2.7e-5) {
tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x));
} else {
tmp = (cos(x) * (cos(eps) + -1.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) * sin(x)
if (eps <= (-3d-5)) then
tmp = ((cos(x) * cos(eps)) - cos(x)) - t_0
else if (eps <= 2.7d-5) then
tmp = ((-0.5d0) * (eps * (cos(x) * eps))) - (eps * sin(x))
else
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(eps) * Math.sin(x);
double tmp;
if (eps <= -3e-5) {
tmp = ((Math.cos(x) * Math.cos(eps)) - Math.cos(x)) - t_0;
} else if (eps <= 2.7e-5) {
tmp = (-0.5 * (eps * (Math.cos(x) * eps))) - (eps * Math.sin(x));
} else {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(eps) * math.sin(x) tmp = 0 if eps <= -3e-5: tmp = ((math.cos(x) * math.cos(eps)) - math.cos(x)) - t_0 elif eps <= 2.7e-5: tmp = (-0.5 * (eps * (math.cos(x) * eps))) - (eps * math.sin(x)) else: tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - t_0 return tmp
function code(x, eps) t_0 = Float64(sin(eps) * sin(x)) tmp = 0.0 if (eps <= -3e-5) tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - cos(x)) - t_0); elseif (eps <= 2.7e-5) tmp = Float64(Float64(-0.5 * Float64(eps * Float64(cos(x) * eps))) - Float64(eps * sin(x))); else tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(eps) * sin(x); tmp = 0.0; if (eps <= -3e-5) tmp = ((cos(x) * cos(eps)) - cos(x)) - t_0; elseif (eps <= 2.7e-5) tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x)); else tmp = (cos(x) * (cos(eps) + -1.0)) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -3e-5], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[eps, 2.7e-5], N[(N[(-0.5 * N[(eps * N[(N[Cos[x], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \varepsilon \cdot \sin x\\
\mathbf{if}\;\varepsilon \leq -3 \cdot 10^{-5}:\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \cos x\right) - t_0\\
\mathbf{elif}\;\varepsilon \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\cos x \cdot \varepsilon\right)\right) - \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - t_0\\
\end{array}
\end{array}
if eps < -3.00000000000000008e-5Initial program 45.3%
sub-neg45.3%
cos-sum98.6%
associate-+l-98.5%
fma-neg98.5%
Applied egg-rr98.5%
Taylor expanded in x around -inf 98.5%
associate--r+98.8%
cancel-sign-sub-inv98.8%
*-commutative98.8%
*-un-lft-identity98.8%
distribute-rgt-out--98.7%
Applied egg-rr98.7%
sub-neg98.7%
metadata-eval98.7%
distribute-lft-in98.8%
Applied egg-rr98.8%
if -3.00000000000000008e-5 < eps < 2.6999999999999999e-5Initial program 25.3%
Taylor expanded in eps around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
unpow299.7%
associate-*l*99.7%
Simplified99.7%
if 2.6999999999999999e-5 < eps Initial program 47.2%
sub-neg47.2%
cos-sum99.0%
associate-+l-98.8%
fma-neg98.8%
Applied egg-rr98.8%
Taylor expanded in x around -inf 98.8%
associate--r+98.9%
cancel-sign-sub-inv98.9%
*-commutative98.9%
*-un-lft-identity98.9%
distribute-rgt-out--99.0%
Applied egg-rr99.0%
distribute-lft-neg-out99.0%
unsub-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Applied egg-rr99.0%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ x eps)) (cos x)) -5e-14) (* -2.0 (pow (sin (* eps 0.5)) 2.0)) (- (* -0.5 (* eps (* (cos x) eps))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((x + eps)) - cos(x)) <= -5e-14) {
tmp = -2.0 * pow(sin((eps * 0.5)), 2.0);
} else {
tmp = (-0.5 * (eps * (cos(x) * 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((x + eps)) - cos(x)) <= (-5d-14)) then
tmp = (-2.0d0) * (sin((eps * 0.5d0)) ** 2.0d0)
else
tmp = ((-0.5d0) * (eps * (cos(x) * eps))) - (eps * sin(x))
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-14) {
tmp = -2.0 * Math.pow(Math.sin((eps * 0.5)), 2.0);
} else {
tmp = (-0.5 * (eps * (Math.cos(x) * eps))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((x + eps)) - math.cos(x)) <= -5e-14: tmp = -2.0 * math.pow(math.sin((eps * 0.5)), 2.0) else: tmp = (-0.5 * (eps * (math.cos(x) * eps))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(x + eps)) - cos(x)) <= -5e-14) tmp = Float64(-2.0 * (sin(Float64(eps * 0.5)) ^ 2.0)); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(cos(x) * eps))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((x + eps)) - cos(x)) <= -5e-14) tmp = -2.0 * (sin((eps * 0.5)) ^ 2.0); else tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-14], N[(-2.0 * N[Power[N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(N[Cos[x], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(x + \varepsilon\right) - \cos x \leq -5 \cdot 10^{-14}:\\
\;\;\;\;-2 \cdot {\sin \left(\varepsilon \cdot 0.5\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\cos x \cdot \varepsilon\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -5.0000000000000002e-14Initial program 73.2%
diff-cos74.0%
div-inv74.0%
metadata-eval74.0%
div-inv74.0%
+-commutative74.0%
metadata-eval74.0%
Applied egg-rr74.0%
*-commutative74.0%
+-commutative74.0%
associate--l+74.3%
+-inverses74.3%
distribute-lft-in74.3%
metadata-eval74.3%
*-commutative74.3%
+-commutative74.3%
Simplified74.3%
Taylor expanded in x around 0 74.4%
if -5.0000000000000002e-14 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 20.3%
Taylor expanded in eps around 0 75.7%
mul-1-neg75.7%
unsub-neg75.7%
unpow275.7%
associate-*l*75.7%
Simplified75.7%
Final simplification75.3%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.8e-5) (not (<= eps 3.3e-5))) (- (* (cos x) (+ (cos eps) -1.0)) (* (sin eps) (sin x))) (- (* -0.5 (* eps (* (cos x) eps))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.8e-5) || !(eps <= 3.3e-5)) {
tmp = (cos(x) * (cos(eps) + -1.0)) - (sin(eps) * sin(x));
} else {
tmp = (-0.5 * (eps * (cos(x) * 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 ((eps <= (-2.8d-5)) .or. (.not. (eps <= 3.3d-5))) then
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - (sin(eps) * sin(x))
else
tmp = ((-0.5d0) * (eps * (cos(x) * eps))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2.8e-5) || !(eps <= 3.3e-5)) {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - (Math.sin(eps) * Math.sin(x));
} else {
tmp = (-0.5 * (eps * (Math.cos(x) * eps))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.8e-5) or not (eps <= 3.3e-5): tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - (math.sin(eps) * math.sin(x)) else: tmp = (-0.5 * (eps * (math.cos(x) * eps))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.8e-5) || !(eps <= 3.3e-5)) tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - Float64(sin(eps) * sin(x))); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(cos(x) * eps))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.8e-5) || ~((eps <= 3.3e-5))) tmp = (cos(x) * (cos(eps) + -1.0)) - (sin(eps) * sin(x)); else tmp = (-0.5 * (eps * (cos(x) * eps))) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.8e-5], N[Not[LessEqual[eps, 3.3e-5]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(N[Cos[x], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.8 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 3.3 \cdot 10^{-5}\right):\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\cos x \cdot \varepsilon\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -2.79999999999999996e-5 or 3.3000000000000003e-5 < eps Initial program 46.3%
sub-neg46.3%
cos-sum98.8%
associate-+l-98.7%
fma-neg98.7%
Applied egg-rr98.7%
Taylor expanded in x around -inf 98.7%
associate--r+98.8%
cancel-sign-sub-inv98.8%
*-commutative98.8%
*-un-lft-identity98.8%
distribute-rgt-out--98.9%
Applied egg-rr98.9%
distribute-lft-neg-out98.9%
unsub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
Applied egg-rr98.9%
if -2.79999999999999996e-5 < eps < 3.3000000000000003e-5Initial program 25.3%
Taylor expanded in eps around 0 99.7%
mul-1-neg99.7%
unsub-neg99.7%
unpow299.7%
associate-*l*99.7%
Simplified99.7%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* eps 0.5)) (sin (* 0.5 (+ x (+ x eps)))))))
double code(double x, double eps) {
return -2.0 * (sin((eps * 0.5)) * sin((0.5 * (x + (x + eps)))));
}
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 + (x + eps)))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((eps * 0.5)) * Math.sin((0.5 * (x + (x + eps)))));
}
def code(x, eps): return -2.0 * (math.sin((eps * 0.5)) * math.sin((0.5 * (x + (x + eps)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(eps * 0.5)) * sin(Float64(0.5 * Float64(x + Float64(x + eps)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((eps * 0.5)) * sin((0.5 * (x + (x + eps))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(x + N[(x + eps), $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(x + \varepsilon\right)\right)\right)\right)
\end{array}
Initial program 34.8%
diff-cos45.2%
div-inv45.2%
metadata-eval45.2%
div-inv45.2%
+-commutative45.2%
metadata-eval45.2%
Applied egg-rr45.2%
*-commutative45.2%
+-commutative45.2%
associate--l+76.3%
+-inverses76.3%
distribute-lft-in76.3%
metadata-eval76.3%
*-commutative76.3%
+-commutative76.3%
Simplified76.3%
Final simplification76.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.00019)
(- (cos eps) (cos x))
(if (<= eps -6e-51)
(* eps (* eps -0.5))
(if (<= eps 4.9e-7) (* eps (- (sin x))) (+ (* (cos x) (cos eps)) -1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00019) {
tmp = cos(eps) - cos(x);
} else if (eps <= -6e-51) {
tmp = eps * (eps * -0.5);
} else if (eps <= 4.9e-7) {
tmp = eps * -sin(x);
} else {
tmp = (cos(x) * cos(eps)) + -1.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.00019d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= (-6d-51)) then
tmp = eps * (eps * (-0.5d0))
else if (eps <= 4.9d-7) then
tmp = eps * -sin(x)
else
tmp = (cos(x) * cos(eps)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.00019) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= -6e-51) {
tmp = eps * (eps * -0.5);
} else if (eps <= 4.9e-7) {
tmp = eps * -Math.sin(x);
} else {
tmp = (Math.cos(x) * Math.cos(eps)) + -1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.00019: tmp = math.cos(eps) - math.cos(x) elif eps <= -6e-51: tmp = eps * (eps * -0.5) elif eps <= 4.9e-7: tmp = eps * -math.sin(x) else: tmp = (math.cos(x) * math.cos(eps)) + -1.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.00019) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= -6e-51) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 4.9e-7) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(Float64(cos(x) * cos(eps)) + -1.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.00019) tmp = cos(eps) - cos(x); elseif (eps <= -6e-51) tmp = eps * (eps * -0.5); elseif (eps <= 4.9e-7) tmp = eps * -sin(x); else tmp = (cos(x) * cos(eps)) + -1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.00019], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, -6e-51], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.9e-7], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00019:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq -6 \cdot 10^{-51}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 4.9 \cdot 10^{-7}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon + -1\\
\end{array}
\end{array}
if eps < -1.9000000000000001e-4Initial program 45.3%
Taylor expanded in x around 0 47.8%
if -1.9000000000000001e-4 < eps < -6.00000000000000005e-51Initial program 8.5%
Taylor expanded in x around 0 8.5%
Taylor expanded in eps around 0 82.2%
*-commutative82.2%
unpow282.2%
associate-*l*82.2%
Simplified82.2%
if -6.00000000000000005e-51 < eps < 4.8999999999999997e-7Initial program 26.7%
Taylor expanded in eps around 0 85.4%
associate-*r*85.4%
mul-1-neg85.4%
Simplified85.4%
if 4.8999999999999997e-7 < eps Initial program 47.2%
sub-neg47.2%
cos-sum99.0%
associate-+l-98.8%
fma-neg98.8%
Applied egg-rr98.8%
Taylor expanded in x around 0 50.3%
Taylor expanded in x around -inf 50.3%
Final simplification68.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -8.4e-8) (not (<= x 6.8e-72)))
(* -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.4e-8) || !(x <= 6.8e-72)) {
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.4d-8)) .or. (.not. (x <= 6.8d-72))) 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.4e-8) || !(x <= 6.8e-72)) {
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.4e-8) or not (x <= 6.8e-72): 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.4e-8) || !(x <= 6.8e-72)) 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.4e-8) || ~((x <= 6.8e-72))) 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.4e-8], N[Not[LessEqual[x, 6.8e-72]], $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.4 \cdot 10^{-8} \lor \neg \left(x \leq 6.8 \cdot 10^{-72}\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -8.39999999999999978e-8 or 6.7999999999999997e-72 < x Initial program 9.3%
diff-cos9.6%
div-inv9.6%
metadata-eval9.6%
div-inv9.6%
+-commutative9.6%
metadata-eval9.6%
Applied egg-rr9.6%
*-commutative9.6%
+-commutative9.6%
associate--l+60.6%
+-inverses60.6%
distribute-lft-in60.6%
metadata-eval60.6%
*-commutative60.6%
+-commutative60.6%
Simplified60.6%
Taylor expanded in eps around 0 58.1%
if -8.39999999999999978e-8 < x < 6.7999999999999997e-72Initial program 70.9%
diff-cos95.5%
div-inv95.5%
metadata-eval95.5%
div-inv95.5%
+-commutative95.5%
metadata-eval95.5%
Applied egg-rr95.5%
*-commutative95.5%
+-commutative95.5%
associate--l+98.5%
+-inverses98.5%
distribute-lft-in98.5%
metadata-eval98.5%
*-commutative98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 94.8%
Final simplification73.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -1e-7) (not (<= x 5.1e-57))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -1e-7) || !(x <= 5.1e-57)) {
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 <= (-1d-7)) .or. (.not. (x <= 5.1d-57))) 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 <= -1e-7) || !(x <= 5.1e-57)) {
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 <= -1e-7) or not (x <= 5.1e-57): 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 <= -1e-7) || !(x <= 5.1e-57)) 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 <= -1e-7) || ~((x <= 5.1e-57))) 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, -1e-7], N[Not[LessEqual[x, 5.1e-57]], $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 -1 \cdot 10^{-7} \lor \neg \left(x \leq 5.1 \cdot 10^{-57}\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 < -9.9999999999999995e-8 or 5.1e-57 < x Initial program 8.1%
Taylor expanded in eps around 0 54.4%
associate-*r*54.4%
mul-1-neg54.4%
Simplified54.4%
if -9.9999999999999995e-8 < x < 5.1e-57Initial program 70.8%
diff-cos94.8%
div-inv94.8%
metadata-eval94.8%
div-inv94.8%
+-commutative94.8%
metadata-eval94.8%
Applied egg-rr94.8%
*-commutative94.8%
+-commutative94.8%
associate--l+98.5%
+-inverses98.5%
distribute-lft-in98.5%
metadata-eval98.5%
*-commutative98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 94.1%
Final simplification71.3%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.00011)
(- (cos eps) (cos x))
(if (<= eps -4.4e-50)
(* eps (* eps -0.5))
(if (<= eps 8e-8) (* eps (- (sin x))) (+ (cos eps) -1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.00011) {
tmp = cos(eps) - cos(x);
} else if (eps <= -4.4e-50) {
tmp = eps * (eps * -0.5);
} else if (eps <= 8e-8) {
tmp = eps * -sin(x);
} else {
tmp = cos(eps) + -1.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= (-0.00011d0)) then
tmp = cos(eps) - cos(x)
else if (eps <= (-4.4d-50)) then
tmp = eps * (eps * (-0.5d0))
else if (eps <= 8d-8) then
tmp = eps * -sin(x)
else
tmp = cos(eps) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.00011) {
tmp = Math.cos(eps) - Math.cos(x);
} else if (eps <= -4.4e-50) {
tmp = eps * (eps * -0.5);
} else if (eps <= 8e-8) {
tmp = eps * -Math.sin(x);
} else {
tmp = Math.cos(eps) + -1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.00011: tmp = math.cos(eps) - math.cos(x) elif eps <= -4.4e-50: tmp = eps * (eps * -0.5) elif eps <= 8e-8: tmp = eps * -math.sin(x) else: tmp = math.cos(eps) + -1.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.00011) tmp = Float64(cos(eps) - cos(x)); elseif (eps <= -4.4e-50) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 8e-8) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(cos(eps) + -1.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.00011) tmp = cos(eps) - cos(x); elseif (eps <= -4.4e-50) tmp = eps * (eps * -0.5); elseif (eps <= 8e-8) tmp = eps * -sin(x); else tmp = cos(eps) + -1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.00011], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, -4.4e-50], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e-8], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00011:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{elif}\;\varepsilon \leq -4.4 \cdot 10^{-50}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{-8}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \varepsilon + -1\\
\end{array}
\end{array}
if eps < -1.10000000000000004e-4Initial program 45.3%
Taylor expanded in x around 0 47.8%
if -1.10000000000000004e-4 < eps < -4.3999999999999998e-50Initial program 8.5%
Taylor expanded in x around 0 8.5%
Taylor expanded in eps around 0 82.2%
*-commutative82.2%
unpow282.2%
associate-*l*82.2%
Simplified82.2%
if -4.3999999999999998e-50 < eps < 8.0000000000000002e-8Initial program 26.7%
Taylor expanded in eps around 0 85.4%
associate-*r*85.4%
mul-1-neg85.4%
Simplified85.4%
if 8.0000000000000002e-8 < eps Initial program 47.2%
Taylor expanded in x around 0 50.2%
Final simplification68.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)))
(if (<= eps -0.000165)
t_0
(if (<= eps -7.6e-56)
(* eps (* eps -0.5))
(if (<= eps 2.4e-6) (* eps (- (sin x))) t_0)))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double tmp;
if (eps <= -0.000165) {
tmp = t_0;
} else if (eps <= -7.6e-56) {
tmp = eps * (eps * -0.5);
} else if (eps <= 2.4e-6) {
tmp = eps * -sin(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.000165d0)) then
tmp = t_0
else if (eps <= (-7.6d-56)) then
tmp = eps * (eps * (-0.5d0))
else if (eps <= 2.4d-6) then
tmp = eps * -sin(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.000165) {
tmp = t_0;
} else if (eps <= -7.6e-56) {
tmp = eps * (eps * -0.5);
} else if (eps <= 2.4e-6) {
tmp = eps * -Math.sin(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 tmp = 0 if eps <= -0.000165: tmp = t_0 elif eps <= -7.6e-56: tmp = eps * (eps * -0.5) elif eps <= 2.4e-6: tmp = eps * -math.sin(x) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) tmp = 0.0 if (eps <= -0.000165) tmp = t_0; elseif (eps <= -7.6e-56) tmp = Float64(eps * Float64(eps * -0.5)); elseif (eps <= 2.4e-6) tmp = Float64(eps * Float64(-sin(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.000165) tmp = t_0; elseif (eps <= -7.6e-56) tmp = eps * (eps * -0.5); elseif (eps <= 2.4e-6) tmp = eps * -sin(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.000165], t$95$0, If[LessEqual[eps, -7.6e-56], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 2.4e-6], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
\mathbf{if}\;\varepsilon \leq -0.000165:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -7.6 \cdot 10^{-56}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{elif}\;\varepsilon \leq 2.4 \cdot 10^{-6}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.65e-4 or 2.3999999999999999e-6 < eps Initial program 46.3%
Taylor expanded in x around 0 48.1%
if -1.65e-4 < eps < -7.6000000000000004e-56Initial program 8.5%
Taylor expanded in x around 0 8.5%
Taylor expanded in eps around 0 82.2%
*-commutative82.2%
unpow282.2%
associate-*l*82.2%
Simplified82.2%
if -7.6000000000000004e-56 < eps < 2.3999999999999999e-6Initial program 26.7%
Taylor expanded in eps around 0 85.4%
associate-*r*85.4%
mul-1-neg85.4%
Simplified85.4%
Final simplification68.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.000165) (not (<= eps 0.000145))) (+ (cos eps) -1.0) (* eps (* eps -0.5))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.000165) || !(eps <= 0.000145)) {
tmp = cos(eps) + -1.0;
} else {
tmp = eps * (eps * -0.5);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.000165d0)) .or. (.not. (eps <= 0.000145d0))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = eps * (eps * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.000165) || !(eps <= 0.000145)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * (eps * -0.5);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.000165) or not (eps <= 0.000145): tmp = math.cos(eps) + -1.0 else: tmp = eps * (eps * -0.5) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.000165) || !(eps <= 0.000145)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(eps * Float64(eps * -0.5)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.000165) || ~((eps <= 0.000145))) tmp = cos(eps) + -1.0; else tmp = eps * (eps * -0.5); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.000165], N[Not[LessEqual[eps, 0.000145]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.000165 \lor \neg \left(\varepsilon \leq 0.000145\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\end{array}
\end{array}
if eps < -1.65e-4 or 1.45e-4 < eps Initial program 46.3%
Taylor expanded in x around 0 48.1%
if -1.65e-4 < eps < 1.45e-4Initial program 25.3%
Taylor expanded in x around 0 25.3%
Taylor expanded in eps around 0 43.5%
*-commutative43.5%
unpow243.5%
associate-*l*43.5%
Simplified43.5%
Final simplification45.6%
(FPCore (x eps) :precision binary64 (* eps (* eps -0.5)))
double code(double x, double eps) {
return eps * (eps * -0.5);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * (eps * (-0.5d0))
end function
public static double code(double x, double eps) {
return eps * (eps * -0.5);
}
def code(x, eps): return eps * (eps * -0.5)
function code(x, eps) return Float64(eps * Float64(eps * -0.5)) end
function tmp = code(x, eps) tmp = eps * (eps * -0.5); end
code[x_, eps_] := N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)
\end{array}
Initial program 34.8%
Taylor expanded in x around 0 35.6%
Taylor expanded in eps around 0 25.5%
*-commutative25.5%
unpow225.5%
associate-*l*25.5%
Simplified25.5%
Final simplification25.5%
(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 34.8%
add-cube-cbrt34.4%
pow334.4%
Applied egg-rr34.4%
Taylor expanded in eps around 0 15.0%
pow-base-115.0%
*-rgt-identity15.0%
+-inverses15.0%
Simplified15.0%
Final simplification15.0%
herbie shell --seed 2023252
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))