
(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 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (cos (+ x eps)) (cos x)))
double code(double x, double eps) {
return cos((x + eps)) - cos(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos((x + eps)) - cos(x)
end function
public static double code(double x, double eps) {
return Math.cos((x + eps)) - Math.cos(x);
}
def code(x, eps): return math.cos((x + eps)) - math.cos(x)
function code(x, eps) return Float64(cos(Float64(x + eps)) - cos(x)) end
function tmp = code(x, eps) tmp = cos((x + eps)) - cos(x); end
code[x_, eps_] := N[(N[Cos[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x + \varepsilon\right) - \cos x
\end{array}
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (fma (cos x) t_0 (* (sin x) (cos (* 0.5 eps))))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * fma(cos(x), t_0, (sin(x) * cos((0.5 * eps)))));
}
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * fma(cos(x), t_0, Float64(sin(x) * cos(Float64(0.5 * eps)))))) end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[(N[Cos[x], $MachinePrecision] * t$95$0 + N[(N[Sin[x], $MachinePrecision] * N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
-2 \cdot \left(t_0 \cdot \mathsf{fma}\left(\cos x, t_0, \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)\right)
\end{array}
\end{array}
Initial program 41.7%
diff-cos50.1%
div-inv50.1%
metadata-eval50.1%
div-inv50.1%
+-commutative50.1%
metadata-eval50.1%
Applied egg-rr50.1%
*-commutative50.1%
+-commutative50.1%
associate--l+80.9%
*-commutative80.9%
associate-+r+80.9%
+-commutative80.9%
Simplified80.9%
distribute-lft-in80.9%
sin-sum99.1%
Applied egg-rr99.1%
*-commutative99.1%
count-299.1%
*-commutative99.1%
count-299.1%
count-299.1%
*-commutative99.1%
count-299.1%
fma-def99.2%
Simplified99.6%
Taylor expanded in eps around inf 99.5%
fma-def99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (+ (* (sin x) (cos (* 0.5 eps))) (* t_0 (cos x)))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * ((sin(x) * cos((0.5 * eps))) + (t_0 * cos(x))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
t_0 = sin((0.5d0 * eps))
code = (-2.0d0) * (t_0 * ((sin(x) * cos((0.5d0 * eps))) + (t_0 * cos(x))))
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((0.5 * eps));
return -2.0 * (t_0 * ((Math.sin(x) * Math.cos((0.5 * eps))) + (t_0 * Math.cos(x))));
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) return -2.0 * (t_0 * ((math.sin(x) * math.cos((0.5 * eps))) + (t_0 * math.cos(x))))
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * Float64(Float64(sin(x) * cos(Float64(0.5 * eps))) + Float64(t_0 * cos(x))))) end
function tmp = code(x, eps) t_0 = sin((0.5 * eps)); tmp = -2.0 * (t_0 * ((sin(x) * cos((0.5 * eps))) + (t_0 * cos(x)))); end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, N[(-2.0 * N[(t$95$0 * N[(N[(N[Sin[x], $MachinePrecision] * N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
-2 \cdot \left(t_0 \cdot \left(\sin x \cdot \cos \left(0.5 \cdot \varepsilon\right) + t_0 \cdot \cos x\right)\right)
\end{array}
\end{array}
Initial program 41.7%
diff-cos50.1%
div-inv50.1%
metadata-eval50.1%
div-inv50.1%
+-commutative50.1%
metadata-eval50.1%
Applied egg-rr50.1%
*-commutative50.1%
+-commutative50.1%
associate--l+80.9%
*-commutative80.9%
associate-+r+80.9%
+-commutative80.9%
Simplified80.9%
distribute-lft-in80.9%
sin-sum99.1%
Applied egg-rr99.1%
*-commutative99.1%
count-299.1%
*-commutative99.1%
count-299.1%
count-299.1%
*-commutative99.1%
count-299.1%
fma-def99.2%
Simplified99.6%
Taylor expanded in eps around inf 99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.000165) (not (<= eps 0.00016)))
(- (* (cos x) (cos eps)) (+ (cos x) (* (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.000165) || !(eps <= 0.00016)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (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.000165d0)) .or. (.not. (eps <= 0.00016d0))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (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.000165) || !(eps <= 0.00016)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (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.000165) or not (eps <= 0.00016): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (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.000165) || !(eps <= 0.00016)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + 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.000165) || ~((eps <= 0.00016))) tmp = (cos(x) * cos(eps)) - (cos(x) + (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.000165], N[Not[LessEqual[eps, 0.00016]], $MachinePrecision]], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $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.000165 \lor \neg \left(\varepsilon \leq 0.00016\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\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.65e-4 or 1.60000000000000013e-4 < eps Initial program 58.2%
sub-neg58.2%
cos-sum98.5%
associate-+l-98.4%
fma-neg98.5%
Applied egg-rr98.5%
fma-neg98.4%
*-commutative98.4%
*-commutative98.4%
fma-neg98.5%
remove-double-neg98.5%
Simplified98.5%
Taylor expanded in eps around inf 98.4%
if -1.65e-4 < eps < 1.60000000000000013e-4Initial program 26.9%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-+l+99.8%
unpow299.8%
associate-*l*99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
mul-1-neg99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin x) (sin eps))))
(if (<= eps -0.000155)
(- (- t_0 t_1) (cos x))
(if (<= eps 0.000165)
(+
(* -0.5 (* eps (* eps (cos x))))
(* (sin x) (- (* 0.16666666666666666 (pow eps 3.0)) eps)))
(- t_0 (+ (cos x) t_1))))))
double code(double x, double eps) {
double t_0 = cos(x) * cos(eps);
double t_1 = sin(x) * sin(eps);
double tmp;
if (eps <= -0.000155) {
tmp = (t_0 - t_1) - cos(x);
} else if (eps <= 0.000165) {
tmp = (-0.5 * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666 * pow(eps, 3.0)) - eps));
} else {
tmp = t_0 - (cos(x) + 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 = cos(x) * cos(eps)
t_1 = sin(x) * sin(eps)
if (eps <= (-0.000155d0)) then
tmp = (t_0 - t_1) - cos(x)
else if (eps <= 0.000165d0) then
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666d0 * (eps ** 3.0d0)) - eps))
else
tmp = t_0 - (cos(x) + t_1)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(x) * Math.cos(eps);
double t_1 = Math.sin(x) * Math.sin(eps);
double tmp;
if (eps <= -0.000155) {
tmp = (t_0 - t_1) - Math.cos(x);
} else if (eps <= 0.000165) {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) + (Math.sin(x) * ((0.16666666666666666 * Math.pow(eps, 3.0)) - eps));
} else {
tmp = t_0 - (Math.cos(x) + t_1);
}
return tmp;
}
def code(x, eps): t_0 = math.cos(x) * math.cos(eps) t_1 = math.sin(x) * math.sin(eps) tmp = 0 if eps <= -0.000155: tmp = (t_0 - t_1) - math.cos(x) elif eps <= 0.000165: tmp = (-0.5 * (eps * (eps * math.cos(x)))) + (math.sin(x) * ((0.16666666666666666 * math.pow(eps, 3.0)) - eps)) else: tmp = t_0 - (math.cos(x) + t_1) return tmp
function code(x, eps) t_0 = Float64(cos(x) * cos(eps)) t_1 = Float64(sin(x) * sin(eps)) tmp = 0.0 if (eps <= -0.000155) tmp = Float64(Float64(t_0 - t_1) - cos(x)); elseif (eps <= 0.000165) tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) + Float64(sin(x) * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); else tmp = Float64(t_0 - Float64(cos(x) + t_1)); end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(x) * cos(eps); t_1 = sin(x) * sin(eps); tmp = 0.0; if (eps <= -0.000155) tmp = (t_0 - t_1) - cos(x); elseif (eps <= 0.000165) tmp = (-0.5 * (eps * (eps * cos(x)))) + (sin(x) * ((0.16666666666666666 * (eps ^ 3.0)) - eps)); else tmp = t_0 - (cos(x) + t_1); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.000155], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.000165], 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], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \cos \varepsilon\\
t_1 := \sin x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.000155:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\mathbf{elif}\;\varepsilon \leq 0.000165:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) + \sin x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\end{array}
\end{array}
if eps < -1.55e-4Initial program 57.2%
cos-sum98.1%
Applied egg-rr98.1%
if -1.55e-4 < eps < 1.65e-4Initial program 26.9%
Taylor expanded in eps around 0 99.8%
+-commutative99.8%
associate-+l+99.8%
unpow299.8%
associate-*l*99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
mul-1-neg99.8%
Simplified99.8%
if 1.65e-4 < eps Initial program 59.3%
sub-neg59.3%
cos-sum98.9%
associate-+l-98.9%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg98.9%
*-commutative98.9%
*-commutative98.9%
fma-neg98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -2e-13) (* (/ (sin eps) -1.0) (tan (/ eps 2.0))) (- (* -0.5 (* eps (* eps (cos x)))) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -2e-13) {
tmp = (sin(eps) / -1.0) * tan((eps / 2.0));
} else {
tmp = (-0.5 * (eps * (eps * cos(x)))) - (eps * sin(x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((eps + x)) - cos(x)) <= (-2d-13)) then
tmp = (sin(eps) / (-1.0d0)) * tan((eps / 2.0d0))
else
tmp = ((-0.5d0) * (eps * (eps * cos(x)))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -2e-13) {
tmp = (Math.sin(eps) / -1.0) * Math.tan((eps / 2.0));
} else {
tmp = (-0.5 * (eps * (eps * Math.cos(x)))) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -2e-13: tmp = (math.sin(eps) / -1.0) * math.tan((eps / 2.0)) else: tmp = (-0.5 * (eps * (eps * math.cos(x)))) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -2e-13) tmp = Float64(Float64(sin(eps) / -1.0) * tan(Float64(eps / 2.0))); else tmp = Float64(Float64(-0.5 * Float64(eps * Float64(eps * cos(x)))) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((eps + x)) - cos(x)) <= -2e-13) tmp = (sin(eps) / -1.0) * tan((eps / 2.0)); else tmp = (-0.5 * (eps * (eps * cos(x)))) - (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], -2e-13], N[(N[(N[Sin[eps], $MachinePrecision] / -1.0), $MachinePrecision] * N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(eps * N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -2 \cdot 10^{-13}:\\
\;\;\;\;\frac{\sin \varepsilon}{-1} \cdot \tan \left(\frac{\varepsilon}{2}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \cos x\right)\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -2.0000000000000001e-13Initial program 84.7%
Taylor expanded in x around 0 84.8%
add-log-exp84.4%
sub-neg84.4%
metadata-eval84.4%
Applied egg-rr84.4%
add-log-exp84.8%
flip-+84.4%
frac-2neg84.4%
metadata-eval84.4%
sub-1-cos85.8%
pow285.8%
Applied egg-rr85.8%
remove-double-neg85.8%
unpow285.8%
neg-mul-185.8%
times-frac85.8%
sub-neg85.8%
metadata-eval85.8%
+-commutative85.8%
hang-0p-tan86.5%
Simplified86.5%
if -2.0000000000000001e-13 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.2%
Taylor expanded in eps around 0 77.1%
mul-1-neg77.1%
unsub-neg77.1%
unpow277.1%
associate-*l*77.1%
Simplified77.1%
Final simplification80.1%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -2e-13) (+ (* (cos x) (cos eps)) -1.0) (expm1 (* (sin x) (- eps)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -2e-13) {
tmp = (cos(x) * cos(eps)) + -1.0;
} else {
tmp = expm1((sin(x) * -eps));
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -2e-13) {
tmp = (Math.cos(x) * Math.cos(eps)) + -1.0;
} else {
tmp = Math.expm1((Math.sin(x) * -eps));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -2e-13: tmp = (math.cos(x) * math.cos(eps)) + -1.0 else: tmp = math.expm1((math.sin(x) * -eps)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -2e-13) tmp = Float64(Float64(cos(x) * cos(eps)) + -1.0); else tmp = expm1(Float64(sin(x) * Float64(-eps))); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -2e-13], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(Exp[N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]] - 1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -2 \cdot 10^{-13}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\sin x \cdot \left(-\varepsilon\right)\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -2.0000000000000001e-13Initial program 84.7%
sub-neg84.7%
cos-sum97.9%
associate-+l-97.9%
fma-neg97.9%
Applied egg-rr97.9%
fma-neg97.9%
*-commutative97.9%
*-commutative97.9%
fma-neg97.9%
remove-double-neg97.9%
Simplified97.9%
Taylor expanded in x around 0 84.9%
if -2.0000000000000001e-13 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.2%
expm1-log1p-u22.2%
Applied egg-rr22.2%
Taylor expanded in eps around 0 65.0%
mul-1-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
Simplified65.0%
Final simplification71.2%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -2e-13) (+ (cos eps) -1.0) (expm1 (* (sin x) (- eps)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -2e-13) {
tmp = cos(eps) + -1.0;
} else {
tmp = expm1((sin(x) * -eps));
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((eps + x)) - Math.cos(x)) <= -2e-13) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = Math.expm1((Math.sin(x) * -eps));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -2e-13: tmp = math.cos(eps) + -1.0 else: tmp = math.expm1((math.sin(x) * -eps)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -2e-13) tmp = Float64(cos(eps) + -1.0); else tmp = expm1(Float64(sin(x) * Float64(-eps))); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -2e-13], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(Exp[N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]] - 1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -2 \cdot 10^{-13}:\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\sin x \cdot \left(-\varepsilon\right)\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -2.0000000000000001e-13Initial program 84.7%
Taylor expanded in x around 0 84.8%
if -2.0000000000000001e-13 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 22.2%
expm1-log1p-u22.2%
Applied egg-rr22.2%
Taylor expanded in eps around 0 65.0%
mul-1-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
Simplified65.0%
Final simplification71.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -0.27) (not (<= x 1.35e-69))) (* -2.0 (* (sin x) (sin (* 0.5 (+ eps (- x x)))))) (* (/ (sin eps) -1.0) (tan (/ eps 2.0)))))
double code(double x, double eps) {
double tmp;
if ((x <= -0.27) || !(x <= 1.35e-69)) {
tmp = -2.0 * (sin(x) * sin((0.5 * (eps + (x - x)))));
} else {
tmp = (sin(eps) / -1.0) * tan((eps / 2.0));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-0.27d0)) .or. (.not. (x <= 1.35d-69))) then
tmp = (-2.0d0) * (sin(x) * sin((0.5d0 * (eps + (x - x)))))
else
tmp = (sin(eps) / (-1.0d0)) * tan((eps / 2.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -0.27) || !(x <= 1.35e-69)) {
tmp = -2.0 * (Math.sin(x) * Math.sin((0.5 * (eps + (x - x)))));
} else {
tmp = (Math.sin(eps) / -1.0) * Math.tan((eps / 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -0.27) or not (x <= 1.35e-69): tmp = -2.0 * (math.sin(x) * math.sin((0.5 * (eps + (x - x))))) else: tmp = (math.sin(eps) / -1.0) * math.tan((eps / 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -0.27) || !(x <= 1.35e-69)) tmp = Float64(-2.0 * Float64(sin(x) * sin(Float64(0.5 * Float64(eps + Float64(x - x)))))); else tmp = Float64(Float64(sin(eps) / -1.0) * tan(Float64(eps / 2.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -0.27) || ~((x <= 1.35e-69))) tmp = -2.0 * (sin(x) * sin((0.5 * (eps + (x - x))))); else tmp = (sin(eps) / -1.0) * tan((eps / 2.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -0.27], N[Not[LessEqual[x, 1.35e-69]], $MachinePrecision]], N[(-2.0 * N[(N[Sin[x], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[eps], $MachinePrecision] / -1.0), $MachinePrecision] * N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.27 \lor \neg \left(x \leq 1.35 \cdot 10^{-69}\right):\\
\;\;\;\;-2 \cdot \left(\sin x \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin \varepsilon}{-1} \cdot \tan \left(\frac{\varepsilon}{2}\right)\\
\end{array}
\end{array}
if x < -0.27000000000000002 or 1.3499999999999999e-69 < x Initial program 11.3%
diff-cos11.2%
div-inv11.2%
metadata-eval11.2%
div-inv11.2%
+-commutative11.2%
metadata-eval11.2%
Applied egg-rr11.2%
*-commutative11.2%
+-commutative11.2%
associate--l+64.7%
*-commutative64.7%
associate-+r+64.7%
+-commutative64.7%
Simplified64.7%
Taylor expanded in eps around 0 60.3%
if -0.27000000000000002 < x < 1.3499999999999999e-69Initial program 75.6%
Taylor expanded in x around 0 75.6%
add-log-exp75.4%
sub-neg75.4%
metadata-eval75.4%
Applied egg-rr75.4%
add-log-exp75.6%
flip-+75.3%
frac-2neg75.3%
metadata-eval75.3%
sub-1-cos92.9%
pow292.9%
Applied egg-rr92.9%
remove-double-neg92.9%
unpow292.9%
neg-mul-192.9%
times-frac92.9%
sub-neg92.9%
metadata-eval92.9%
+-commutative92.9%
hang-0p-tan93.4%
Simplified93.4%
Final simplification76.0%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* 0.5 eps)) (sin (* 0.5 (- eps (* -2.0 x)))))))
double code(double x, double eps) {
return -2.0 * (sin((0.5 * eps)) * sin((0.5 * (eps - (-2.0 * x)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((0.5d0 * eps)) * sin((0.5d0 * (eps - ((-2.0d0) * x)))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((0.5 * eps)) * Math.sin((0.5 * (eps - (-2.0 * x)))));
}
def code(x, eps): return -2.0 * (math.sin((0.5 * eps)) * math.sin((0.5 * (eps - (-2.0 * x)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * sin(Float64(0.5 * Float64(eps - Float64(-2.0 * x)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((0.5 * eps)) * sin((0.5 * (eps - (-2.0 * x))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon - -2 \cdot x\right)\right)\right)
\end{array}
Initial program 41.7%
diff-cos50.1%
div-inv50.1%
metadata-eval50.1%
div-inv50.1%
+-commutative50.1%
metadata-eval50.1%
Applied egg-rr50.1%
*-commutative50.1%
+-commutative50.1%
associate--l+80.9%
*-commutative80.9%
associate-+r+80.9%
+-commutative80.9%
Simplified80.9%
Taylor expanded in x around -inf 80.9%
Final simplification80.9%
(FPCore (x eps) :precision binary64 (if (or (<= x -0.27) (not (<= x 5.5e-85))) (expm1 (* (sin x) (- eps))) (* (/ (sin eps) -1.0) (tan (/ eps 2.0)))))
double code(double x, double eps) {
double tmp;
if ((x <= -0.27) || !(x <= 5.5e-85)) {
tmp = expm1((sin(x) * -eps));
} else {
tmp = (sin(eps) / -1.0) * tan((eps / 2.0));
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if ((x <= -0.27) || !(x <= 5.5e-85)) {
tmp = Math.expm1((Math.sin(x) * -eps));
} else {
tmp = (Math.sin(eps) / -1.0) * Math.tan((eps / 2.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -0.27) or not (x <= 5.5e-85): tmp = math.expm1((math.sin(x) * -eps)) else: tmp = (math.sin(eps) / -1.0) * math.tan((eps / 2.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -0.27) || !(x <= 5.5e-85)) tmp = expm1(Float64(sin(x) * Float64(-eps))); else tmp = Float64(Float64(sin(eps) / -1.0) * tan(Float64(eps / 2.0))); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, -0.27], N[Not[LessEqual[x, 5.5e-85]], $MachinePrecision]], N[(Exp[N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]] - 1), $MachinePrecision], N[(N[(N[Sin[eps], $MachinePrecision] / -1.0), $MachinePrecision] * N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.27 \lor \neg \left(x \leq 5.5 \cdot 10^{-85}\right):\\
\;\;\;\;\mathsf{expm1}\left(\sin x \cdot \left(-\varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin \varepsilon}{-1} \cdot \tan \left(\frac{\varepsilon}{2}\right)\\
\end{array}
\end{array}
if x < -0.27000000000000002 or 5.4999999999999997e-85 < x Initial program 12.6%
expm1-log1p-u9.1%
Applied egg-rr9.1%
Taylor expanded in eps around 0 58.6%
mul-1-neg58.6%
*-commutative58.6%
distribute-rgt-neg-in58.6%
Simplified58.6%
if -0.27000000000000002 < x < 5.4999999999999997e-85Initial program 75.8%
Taylor expanded in x around 0 75.8%
add-log-exp75.6%
sub-neg75.6%
metadata-eval75.6%
Applied egg-rr75.6%
add-log-exp75.8%
flip-+75.5%
frac-2neg75.5%
metadata-eval75.5%
sub-1-cos93.5%
pow293.5%
Applied egg-rr93.5%
remove-double-neg93.5%
unpow293.5%
neg-mul-193.5%
times-frac93.5%
sub-neg93.5%
metadata-eval93.5%
+-commutative93.5%
hang-0p-tan94.0%
Simplified94.0%
Final simplification74.9%
(FPCore (x eps) :precision binary64 (if (or (<= x -0.27) (not (<= x 5.5e-85))) (expm1 (* (sin x) (- eps))) (* -2.0 (pow (sin (* 0.5 eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -0.27) || !(x <= 5.5e-85)) {
tmp = expm1((sin(x) * -eps));
} else {
tmp = -2.0 * pow(sin((0.5 * eps)), 2.0);
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if ((x <= -0.27) || !(x <= 5.5e-85)) {
tmp = Math.expm1((Math.sin(x) * -eps));
} else {
tmp = -2.0 * Math.pow(Math.sin((0.5 * eps)), 2.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -0.27) or not (x <= 5.5e-85): tmp = math.expm1((math.sin(x) * -eps)) else: tmp = -2.0 * math.pow(math.sin((0.5 * eps)), 2.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -0.27) || !(x <= 5.5e-85)) tmp = expm1(Float64(sin(x) * Float64(-eps))); else tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, -0.27], N[Not[LessEqual[x, 5.5e-85]], $MachinePrecision]], N[(Exp[N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]] - 1), $MachinePrecision], N[(-2.0 * N[Power[N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.27 \lor \neg \left(x \leq 5.5 \cdot 10^{-85}\right):\\
\;\;\;\;\mathsf{expm1}\left(\sin x \cdot \left(-\varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\end{array}
\end{array}
if x < -0.27000000000000002 or 5.4999999999999997e-85 < x Initial program 12.6%
expm1-log1p-u9.1%
Applied egg-rr9.1%
Taylor expanded in eps around 0 58.6%
mul-1-neg58.6%
*-commutative58.6%
distribute-rgt-neg-in58.6%
Simplified58.6%
if -0.27000000000000002 < x < 5.4999999999999997e-85Initial program 75.8%
diff-cos94.2%
div-inv94.2%
metadata-eval94.2%
div-inv94.2%
+-commutative94.2%
metadata-eval94.2%
Applied egg-rr94.2%
*-commutative94.2%
+-commutative94.2%
associate--l+99.0%
*-commutative99.0%
associate-+r+99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in x around 0 93.9%
Final simplification74.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.35e-6) (not (<= eps 1.65e-12))) (- (cos eps) (cos x)) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.35e-6) || !(eps <= 1.65e-12)) {
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.35d-6)) .or. (.not. (eps <= 1.65d-12))) 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.35e-6) || !(eps <= 1.65e-12)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.35e-6) or not (eps <= 1.65e-12): 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.35e-6) || !(eps <= 1.65e-12)) 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.35e-6) || ~((eps <= 1.65e-12))) tmp = cos(eps) - cos(x); else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.35e-6], N[Not[LessEqual[eps, 1.65e-12]], $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.35 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 1.65 \cdot 10^{-12}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -2.34999999999999995e-6 or 1.65e-12 < eps Initial program 57.6%
Taylor expanded in x around 0 59.4%
if -2.34999999999999995e-6 < eps < 1.65e-12Initial program 27.0%
Taylor expanded in eps around 0 83.9%
associate-*r*83.9%
mul-1-neg83.9%
Simplified83.9%
Final simplification72.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* eps (* eps -0.5))))
(if (<= eps -2.1e-7)
t_0
(if (<= eps -1.05e-193)
t_1
(if (<= eps 5.2e-155) (* eps (- x)) (if (<= eps 0.000165) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = eps * (eps * -0.5);
double tmp;
if (eps <= -2.1e-7) {
tmp = t_0;
} else if (eps <= -1.05e-193) {
tmp = t_1;
} else if (eps <= 5.2e-155) {
tmp = eps * -x;
} else if (eps <= 0.000165) {
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 = eps * (eps * (-0.5d0))
if (eps <= (-2.1d-7)) then
tmp = t_0
else if (eps <= (-1.05d-193)) then
tmp = t_1
else if (eps <= 5.2d-155) then
tmp = eps * -x
else if (eps <= 0.000165d0) 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 = eps * (eps * -0.5);
double tmp;
if (eps <= -2.1e-7) {
tmp = t_0;
} else if (eps <= -1.05e-193) {
tmp = t_1;
} else if (eps <= 5.2e-155) {
tmp = eps * -x;
} else if (eps <= 0.000165) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = eps * (eps * -0.5) tmp = 0 if eps <= -2.1e-7: tmp = t_0 elif eps <= -1.05e-193: tmp = t_1 elif eps <= 5.2e-155: tmp = eps * -x elif eps <= 0.000165: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(eps * Float64(eps * -0.5)) tmp = 0.0 if (eps <= -2.1e-7) tmp = t_0; elseif (eps <= -1.05e-193) tmp = t_1; elseif (eps <= 5.2e-155) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.000165) 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 = eps * (eps * -0.5); tmp = 0.0; if (eps <= -2.1e-7) tmp = t_0; elseif (eps <= -1.05e-193) tmp = t_1; elseif (eps <= 5.2e-155) tmp = eps * -x; elseif (eps <= 0.000165) 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[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -2.1e-7], t$95$0, If[LessEqual[eps, -1.05e-193], t$95$1, If[LessEqual[eps, 5.2e-155], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.000165], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{if}\;\varepsilon \leq -2.1 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -1.05 \cdot 10^{-193}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{-155}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.000165:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -2.1e-7 or 1.65e-4 < eps Initial program 57.8%
Taylor expanded in x around 0 58.1%
if -2.1e-7 < eps < -1.05e-193 or 5.20000000000000016e-155 < eps < 1.65e-4Initial program 8.0%
Taylor expanded in x around 0 8.0%
Taylor expanded in eps around 0 39.1%
*-commutative39.1%
unpow239.1%
associate-*l*39.1%
Simplified39.1%
if -1.05e-193 < eps < 5.20000000000000016e-155Initial program 47.9%
Taylor expanded in eps around 0 99.9%
associate-*r*99.9%
mul-1-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 61.9%
associate-*r*61.9%
mul-1-neg61.9%
Simplified61.9%
Final simplification53.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -7e-6) (not (<= eps 1.65e-12))) (+ (cos eps) -1.0) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((eps <= -7e-6) || !(eps <= 1.65e-12)) {
tmp = cos(eps) + -1.0;
} else {
tmp = sin(x) * -eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-7d-6)) .or. (.not. (eps <= 1.65d-12))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = sin(x) * -eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -7e-6) || !(eps <= 1.65e-12)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -7e-6) or not (eps <= 1.65e-12): tmp = math.cos(eps) + -1.0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -7e-6) || !(eps <= 1.65e-12)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(sin(x) * Float64(-eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -7e-6) || ~((eps <= 1.65e-12))) tmp = cos(eps) + -1.0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -7e-6], N[Not[LessEqual[eps, 1.65e-12]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7 \cdot 10^{-6} \lor \neg \left(\varepsilon \leq 1.65 \cdot 10^{-12}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if eps < -6.99999999999999989e-6 or 1.65e-12 < eps Initial program 57.6%
Taylor expanded in x around 0 57.9%
if -6.99999999999999989e-6 < eps < 1.65e-12Initial program 27.0%
Taylor expanded in eps around 0 83.9%
associate-*r*83.9%
mul-1-neg83.9%
Simplified83.9%
Final simplification71.4%
(FPCore (x eps) :precision binary64 (if (<= x 2.5e-124) (* eps (* eps -0.5)) (* eps (- x))))
double code(double x, double eps) {
double tmp;
if (x <= 2.5e-124) {
tmp = eps * (eps * -0.5);
} 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 <= 2.5d-124) then
tmp = eps * (eps * (-0.5d0))
else
tmp = eps * -x
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 2.5e-124) {
tmp = eps * (eps * -0.5);
} else {
tmp = eps * -x;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 2.5e-124: tmp = eps * (eps * -0.5) else: tmp = eps * -x return tmp
function code(x, eps) tmp = 0.0 if (x <= 2.5e-124) tmp = Float64(eps * Float64(eps * -0.5)); else tmp = Float64(eps * Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.5e-124) tmp = eps * (eps * -0.5); else tmp = eps * -x; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 2.5e-124], N[(eps * N[(eps * -0.5), $MachinePrecision]), $MachinePrecision], N[(eps * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5 \cdot 10^{-124}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\end{array}
\end{array}
if x < 2.5000000000000001e-124Initial program 52.9%
Taylor expanded in x around 0 53.0%
Taylor expanded in eps around 0 33.1%
*-commutative33.1%
unpow233.1%
associate-*l*33.1%
Simplified33.1%
if 2.5000000000000001e-124 < x Initial program 21.0%
Taylor expanded in eps around 0 56.1%
associate-*r*56.1%
mul-1-neg56.1%
Simplified56.1%
Taylor expanded in x around 0 19.9%
associate-*r*19.9%
mul-1-neg19.9%
Simplified19.9%
Final simplification28.5%
(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 41.7%
Taylor expanded in eps around 0 45.5%
associate-*r*45.5%
mul-1-neg45.5%
Simplified45.5%
Taylor expanded in x around 0 21.2%
associate-*r*21.2%
mul-1-neg21.2%
Simplified21.2%
Final simplification21.2%
(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 41.7%
add-cube-cbrt41.4%
pow341.4%
Applied egg-rr41.4%
Taylor expanded in eps around 0 15.5%
pow-base-115.5%
*-rgt-identity15.5%
+-inverses15.5%
Simplified15.5%
Final simplification15.5%
herbie shell --seed 2023182
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))