
(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 (cos x) (* (tan (/ eps 2.0)) (- (sin eps))) (* (sin eps) (- (sin x)))))
double code(double x, double eps) {
return fma(cos(x), (tan((eps / 2.0)) * -sin(eps)), (sin(eps) * -sin(x)));
}
function code(x, eps) return fma(cos(x), Float64(tan(Float64(eps / 2.0)) * Float64(-sin(eps))), Float64(sin(eps) * Float64(-sin(x)))) end
code[x_, eps_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos x, \tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right), \sin \varepsilon \cdot \left(-\sin x\right)\right)
\end{array}
Initial program 37.2%
cos-sum64.3%
associate--l-64.4%
fma-neg64.4%
fma-def64.4%
Applied egg-rr64.4%
Taylor expanded in x around inf 64.4%
associate--r+89.8%
*-commutative89.8%
*-rgt-identity89.8%
distribute-lft-out--89.8%
sub-neg89.8%
metadata-eval89.8%
*-commutative89.8%
fma-neg89.8%
+-commutative89.8%
distribute-rgt-neg-in89.8%
Simplified89.8%
flip-+89.5%
frac-2neg89.5%
metadata-eval89.5%
1-sub-cos99.2%
add-sqr-sqrt46.1%
sqrt-unprod67.7%
sqr-neg67.7%
sqrt-unprod21.5%
add-sqr-sqrt40.5%
distribute-rgt-neg-out40.5%
sqr-neg40.5%
pow240.5%
flip--3.9%
Applied egg-rr99.2%
neg-sub099.2%
+-commutative99.2%
associate--r+99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in eps around inf 99.2%
mul-1-neg99.2%
+-commutative99.2%
unpow299.2%
associate-*r/99.1%
distribute-rgt-neg-in99.1%
+-commutative99.1%
hang-0p-tan99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -2.95e-8) (not (<= x 2.15e-40)))
(fma (cos x) (+ (cos eps) -1.0) (* (sin eps) (- (sin x))))
(* (+ t_0 (* x (cos (* eps 0.5)))) (* t_0 -2.0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((x <= -2.95e-8) || !(x <= 2.15e-40)) {
tmp = fma(cos(x), (cos(eps) + -1.0), (sin(eps) * -sin(x)));
} else {
tmp = (t_0 + (x * cos((eps * 0.5)))) * (t_0 * -2.0);
}
return tmp;
}
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if ((x <= -2.95e-8) || !(x <= 2.15e-40)) tmp = fma(cos(x), Float64(cos(eps) + -1.0), Float64(sin(eps) * Float64(-sin(x)))); else tmp = Float64(Float64(t_0 + Float64(x * cos(Float64(eps * 0.5)))) * Float64(t_0 * -2.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x, -2.95e-8], N[Not[LessEqual[x, 2.15e-40]], $MachinePrecision]], N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(x * N[Cos[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(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 -2.95 \cdot 10^{-8} \lor \neg \left(x \leq 2.15 \cdot 10^{-40}\right):\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon + -1, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 + x \cdot \cos \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(t_0 \cdot -2\right)\\
\end{array}
\end{array}
if x < -2.9499999999999999e-8 or 2.1500000000000001e-40 < x Initial program 9.8%
cos-sum59.2%
associate--l-59.3%
fma-neg59.3%
fma-def59.3%
Applied egg-rr59.3%
Taylor expanded in x around inf 59.3%
associate--r+99.2%
*-commutative99.2%
*-rgt-identity99.2%
distribute-lft-out--99.1%
sub-neg99.1%
metadata-eval99.1%
*-commutative99.1%
fma-neg99.1%
+-commutative99.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
if -2.9499999999999999e-8 < x < 2.1500000000000001e-40Initial program 69.8%
diff-cos90.9%
div-inv90.9%
associate--l+90.9%
metadata-eval90.9%
div-inv90.9%
+-commutative90.9%
associate-+l+90.9%
metadata-eval90.9%
Applied egg-rr90.9%
associate-*r*90.9%
*-commutative90.9%
*-commutative90.9%
+-commutative90.9%
count-290.9%
fma-def90.9%
sub-neg90.9%
mul-1-neg90.9%
+-commutative90.9%
associate-+r+98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
remove-double-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
neg-sub098.9%
mul-1-neg98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in x around 0 99.6%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (<= x -2.75e-8)
(- (- (* (cos x) (cos eps)) (cos x)) (* (sin eps) (sin x)))
(if (<= x 4.4e-41)
(* (+ t_0 (* x (cos (* eps 0.5)))) (* t_0 -2.0))
(fma (cos x) (+ (cos eps) -1.0) (* (sin eps) (- (sin x))))))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if (x <= -2.75e-8) {
tmp = ((cos(x) * cos(eps)) - cos(x)) - (sin(eps) * sin(x));
} else if (x <= 4.4e-41) {
tmp = (t_0 + (x * cos((eps * 0.5)))) * (t_0 * -2.0);
} else {
tmp = fma(cos(x), (cos(eps) + -1.0), (sin(eps) * -sin(x)));
}
return tmp;
}
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if (x <= -2.75e-8) tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - cos(x)) - Float64(sin(eps) * sin(x))); elseif (x <= 4.4e-41) tmp = Float64(Float64(t_0 + Float64(x * cos(Float64(eps * 0.5)))) * Float64(t_0 * -2.0)); else tmp = fma(cos(x), Float64(cos(eps) + -1.0), Float64(sin(eps) * Float64(-sin(x)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.75e-8], 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[x, 4.4e-41], N[(N[(t$95$0 + N[(x * N[Cos[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon \cdot 0.5\right)\\
\mathbf{if}\;x \leq -2.75 \cdot 10^{-8}:\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \cos x\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-41}:\\
\;\;\;\;\left(t_0 + x \cdot \cos \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(t_0 \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos x, \cos \varepsilon + -1, \sin \varepsilon \cdot \left(-\sin x\right)\right)\\
\end{array}
\end{array}
if x < -2.7500000000000001e-8Initial program 6.7%
cos-sum56.6%
associate--l-56.6%
fma-neg56.7%
fma-def56.6%
Applied egg-rr56.6%
Taylor expanded in x around inf 56.6%
associate--r+99.2%
*-commutative99.2%
*-rgt-identity99.2%
distribute-lft-out--99.1%
sub-neg99.1%
metadata-eval99.1%
*-commutative99.1%
fma-neg99.1%
+-commutative99.1%
distribute-rgt-neg-in99.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%
distribute-lft-neg-in99.1%
cancel-sign-sub-inv99.1%
+-commutative99.1%
Simplified99.1%
distribute-rgt-in99.2%
mul-1-neg99.2%
Applied egg-rr99.2%
if -2.7500000000000001e-8 < x < 4.4e-41Initial program 69.8%
diff-cos90.9%
div-inv90.9%
associate--l+90.9%
metadata-eval90.9%
div-inv90.9%
+-commutative90.9%
associate-+l+90.9%
metadata-eval90.9%
Applied egg-rr90.9%
associate-*r*90.9%
*-commutative90.9%
*-commutative90.9%
+-commutative90.9%
count-290.9%
fma-def90.9%
sub-neg90.9%
mul-1-neg90.9%
+-commutative90.9%
associate-+r+98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
remove-double-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
neg-sub098.9%
mul-1-neg98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in x around 0 99.6%
if 4.4e-41 < x Initial program 12.8%
cos-sum61.6%
associate--l-61.8%
fma-neg61.9%
fma-def61.9%
Applied egg-rr61.9%
Taylor expanded in x around inf 61.8%
associate--r+99.1%
*-commutative99.1%
*-rgt-identity99.1%
distribute-lft-out--99.1%
sub-neg99.1%
metadata-eval99.1%
*-commutative99.1%
fma-neg99.1%
+-commutative99.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* eps 0.5))))
(if (or (<= x -3.5e-8) (not (<= x 2.3e-40)))
(- (* (cos x) (+ (cos eps) -1.0)) (* (sin eps) (sin x)))
(* (+ t_0 (* x (cos (* eps 0.5)))) (* t_0 -2.0)))))
double code(double x, double eps) {
double t_0 = sin((eps * 0.5));
double tmp;
if ((x <= -3.5e-8) || !(x <= 2.3e-40)) {
tmp = (cos(x) * (cos(eps) + -1.0)) - (sin(eps) * sin(x));
} else {
tmp = (t_0 + (x * cos((eps * 0.5)))) * (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 <= (-3.5d-8)) .or. (.not. (x <= 2.3d-40))) then
tmp = (cos(x) * (cos(eps) + (-1.0d0))) - (sin(eps) * sin(x))
else
tmp = (t_0 + (x * cos((eps * 0.5d0)))) * (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 <= -3.5e-8) || !(x <= 2.3e-40)) {
tmp = (Math.cos(x) * (Math.cos(eps) + -1.0)) - (Math.sin(eps) * Math.sin(x));
} else {
tmp = (t_0 + (x * Math.cos((eps * 0.5)))) * (t_0 * -2.0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps * 0.5)) tmp = 0 if (x <= -3.5e-8) or not (x <= 2.3e-40): tmp = (math.cos(x) * (math.cos(eps) + -1.0)) - (math.sin(eps) * math.sin(x)) else: tmp = (t_0 + (x * math.cos((eps * 0.5)))) * (t_0 * -2.0) return tmp
function code(x, eps) t_0 = sin(Float64(eps * 0.5)) tmp = 0.0 if ((x <= -3.5e-8) || !(x <= 2.3e-40)) tmp = Float64(Float64(cos(x) * Float64(cos(eps) + -1.0)) - Float64(sin(eps) * sin(x))); else tmp = Float64(Float64(t_0 + Float64(x * cos(Float64(eps * 0.5)))) * Float64(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 <= -3.5e-8) || ~((x <= 2.3e-40))) tmp = (cos(x) * (cos(eps) + -1.0)) - (sin(eps) * sin(x)); else tmp = (t_0 + (x * cos((eps * 0.5)))) * (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, -3.5e-8], N[Not[LessEqual[x, 2.3e-40]], $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[(t$95$0 + N[(x * N[Cos[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(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 -3.5 \cdot 10^{-8} \lor \neg \left(x \leq 2.3 \cdot 10^{-40}\right):\\
\;\;\;\;\cos x \cdot \left(\cos \varepsilon + -1\right) - \sin \varepsilon \cdot \sin x\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 + x \cdot \cos \left(\varepsilon \cdot 0.5\right)\right) \cdot \left(t_0 \cdot -2\right)\\
\end{array}
\end{array}
if x < -3.50000000000000024e-8 or 2.3e-40 < x Initial program 9.8%
cos-sum59.2%
associate--l-59.3%
fma-neg59.3%
fma-def59.3%
Applied egg-rr59.3%
Taylor expanded in x around inf 59.3%
associate--r+99.2%
*-commutative99.2%
*-rgt-identity99.2%
distribute-lft-out--99.1%
sub-neg99.1%
metadata-eval99.1%
+-commutative99.1%
*-commutative99.1%
Simplified99.1%
if -3.50000000000000024e-8 < x < 2.3e-40Initial program 69.8%
diff-cos90.9%
div-inv90.9%
associate--l+90.9%
metadata-eval90.9%
div-inv90.9%
+-commutative90.9%
associate-+l+90.9%
metadata-eval90.9%
Applied egg-rr90.9%
associate-*r*90.9%
*-commutative90.9%
*-commutative90.9%
+-commutative90.9%
count-290.9%
fma-def90.9%
sub-neg90.9%
mul-1-neg90.9%
+-commutative90.9%
associate-+r+98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
remove-double-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
neg-sub098.9%
mul-1-neg98.9%
remove-double-neg98.9%
Simplified98.9%
Taylor expanded in x around 0 99.6%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ x eps)) (cos x)) -1e-16) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((x + eps)) - cos(x)) <= -1e-16) {
tmp = cos(eps) - cos(x);
} else {
tmp = eps * -sin(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((cos((x + eps)) - cos(x)) <= (-1d-16)) then
tmp = cos(eps) - cos(x)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((Math.cos((x + eps)) - Math.cos(x)) <= -1e-16) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((x + eps)) - math.cos(x)) <= -1e-16: tmp = math.cos(eps) - math.cos(x) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(x + eps)) - cos(x)) <= -1e-16) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((cos((x + eps)) - cos(x)) <= -1e-16) tmp = cos(eps) - cos(x); else tmp = 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], -1e-16], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(x + \varepsilon\right) - \cos x \leq -1 \cdot 10^{-16}:\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -9.9999999999999998e-17Initial program 75.9%
Taylor expanded in x around 0 76.2%
if -9.9999999999999998e-17 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 18.4%
Taylor expanded in eps around 0 56.4%
mul-1-neg56.4%
*-commutative56.4%
distribute-rgt-neg-in56.4%
Simplified56.4%
Final simplification62.9%
(FPCore (x eps) :precision binary64 (* (* (sin (* eps 0.5)) -2.0) (sin (* 0.5 (fma 2.0 x eps)))))
double code(double x, double eps) {
return (sin((eps * 0.5)) * -2.0) * sin((0.5 * fma(2.0, x, eps)));
}
function code(x, eps) return Float64(Float64(sin(Float64(eps * 0.5)) * -2.0) * sin(Float64(0.5 * fma(2.0, x, eps)))) end
code[x_, eps_] := N[(N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision] * N[Sin[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin \left(\varepsilon \cdot 0.5\right) \cdot -2\right) \cdot \sin \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right)
\end{array}
Initial program 37.2%
diff-cos47.2%
div-inv47.2%
associate--l+47.2%
metadata-eval47.2%
div-inv47.2%
+-commutative47.2%
associate-+l+47.3%
metadata-eval47.3%
Applied egg-rr47.3%
associate-*r*47.4%
*-commutative47.4%
*-commutative47.4%
+-commutative47.4%
count-247.4%
fma-def47.4%
sub-neg47.4%
mul-1-neg47.4%
+-commutative47.4%
associate-+r+74.0%
mul-1-neg74.0%
sub-neg74.0%
+-inverses74.0%
remove-double-neg74.0%
mul-1-neg74.0%
sub-neg74.0%
neg-sub074.0%
mul-1-neg74.0%
remove-double-neg74.0%
Simplified74.0%
Final simplification74.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (* (sin (* eps 0.5)) -2.0))))
(if (<= x -7.6e-9)
t_0
(if (<= x -7.2e-63)
(+ -1.0 (- (cos eps) (* x (sin eps))))
(if (<= x -8.2e-91)
(+
(* -0.5 (pow eps 2.0))
(* x (- (* 0.16666666666666666 (pow eps 3.0)) eps)))
(if (<= x 1.8e-9) (* (tan (/ eps 2.0)) (- (sin eps))) t_0))))))
double code(double x, double eps) {
double t_0 = sin(x) * (sin((eps * 0.5)) * -2.0);
double tmp;
if (x <= -7.6e-9) {
tmp = t_0;
} else if (x <= -7.2e-63) {
tmp = -1.0 + (cos(eps) - (x * sin(eps)));
} else if (x <= -8.2e-91) {
tmp = (-0.5 * pow(eps, 2.0)) + (x * ((0.16666666666666666 * pow(eps, 3.0)) - eps));
} else if (x <= 1.8e-9) {
tmp = tan((eps / 2.0)) * -sin(eps);
} 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 = sin(x) * (sin((eps * 0.5d0)) * (-2.0d0))
if (x <= (-7.6d-9)) then
tmp = t_0
else if (x <= (-7.2d-63)) then
tmp = (-1.0d0) + (cos(eps) - (x * sin(eps)))
else if (x <= (-8.2d-91)) then
tmp = ((-0.5d0) * (eps ** 2.0d0)) + (x * ((0.16666666666666666d0 * (eps ** 3.0d0)) - eps))
else if (x <= 1.8d-9) then
tmp = tan((eps / 2.0d0)) * -sin(eps)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) * (Math.sin((eps * 0.5)) * -2.0);
double tmp;
if (x <= -7.6e-9) {
tmp = t_0;
} else if (x <= -7.2e-63) {
tmp = -1.0 + (Math.cos(eps) - (x * Math.sin(eps)));
} else if (x <= -8.2e-91) {
tmp = (-0.5 * Math.pow(eps, 2.0)) + (x * ((0.16666666666666666 * Math.pow(eps, 3.0)) - eps));
} else if (x <= 1.8e-9) {
tmp = Math.tan((eps / 2.0)) * -Math.sin(eps);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) * (math.sin((eps * 0.5)) * -2.0) tmp = 0 if x <= -7.6e-9: tmp = t_0 elif x <= -7.2e-63: tmp = -1.0 + (math.cos(eps) - (x * math.sin(eps))) elif x <= -8.2e-91: tmp = (-0.5 * math.pow(eps, 2.0)) + (x * ((0.16666666666666666 * math.pow(eps, 3.0)) - eps)) elif x <= 1.8e-9: tmp = math.tan((eps / 2.0)) * -math.sin(eps) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(sin(x) * Float64(sin(Float64(eps * 0.5)) * -2.0)) tmp = 0.0 if (x <= -7.6e-9) tmp = t_0; elseif (x <= -7.2e-63) tmp = Float64(-1.0 + Float64(cos(eps) - Float64(x * sin(eps)))); elseif (x <= -8.2e-91) tmp = Float64(Float64(-0.5 * (eps ^ 2.0)) + Float64(x * Float64(Float64(0.16666666666666666 * (eps ^ 3.0)) - eps))); elseif (x <= 1.8e-9) tmp = Float64(tan(Float64(eps / 2.0)) * Float64(-sin(eps))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) * (sin((eps * 0.5)) * -2.0); tmp = 0.0; if (x <= -7.6e-9) tmp = t_0; elseif (x <= -7.2e-63) tmp = -1.0 + (cos(eps) - (x * sin(eps))); elseif (x <= -8.2e-91) tmp = (-0.5 * (eps ^ 2.0)) + (x * ((0.16666666666666666 * (eps ^ 3.0)) - eps)); elseif (x <= 1.8e-9) tmp = tan((eps / 2.0)) * -sin(eps); else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.6e-9], t$95$0, If[LessEqual[x, -7.2e-63], N[(-1.0 + N[(N[Cos[eps], $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -8.2e-91], N[(N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e-9], N[(N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot -2\right)\\
\mathbf{if}\;x \leq -7.6 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{-63}:\\
\;\;\;\;-1 + \left(\cos \varepsilon - x \cdot \sin \varepsilon\right)\\
\mathbf{elif}\;x \leq -8.2 \cdot 10^{-91}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2} + x \cdot \left(0.16666666666666666 \cdot {\varepsilon}^{3} - \varepsilon\right)\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-9}:\\
\;\;\;\;\tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.60000000000000023e-9 or 1.8e-9 < x Initial program 6.6%
diff-cos7.3%
div-inv7.3%
associate--l+7.3%
metadata-eval7.3%
div-inv7.3%
+-commutative7.3%
associate-+l+7.6%
metadata-eval7.6%
Applied egg-rr7.6%
associate-*r*7.6%
*-commutative7.6%
*-commutative7.6%
+-commutative7.6%
count-27.6%
fma-def7.6%
sub-neg7.6%
mul-1-neg7.6%
+-commutative7.6%
associate-+r+51.0%
mul-1-neg51.0%
sub-neg51.0%
+-inverses51.0%
remove-double-neg51.0%
mul-1-neg51.0%
sub-neg51.0%
neg-sub051.0%
mul-1-neg51.0%
remove-double-neg51.0%
Simplified51.0%
Taylor expanded in eps around 0 50.8%
if -7.60000000000000023e-9 < x < -7.20000000000000016e-63Initial program 82.3%
log1p-expm1-u82.0%
Applied egg-rr82.0%
Taylor expanded in x around 0 87.7%
sub-neg87.7%
metadata-eval87.7%
+-commutative87.7%
mul-1-neg87.7%
unsub-neg87.7%
Simplified87.7%
if -7.20000000000000016e-63 < x < -8.20000000000000048e-91Initial program 29.3%
Taylor expanded in eps around 0 99.8%
associate-+r+99.8%
+-commutative99.8%
associate-+l+99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
mul-1-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
if -8.20000000000000048e-91 < x < 1.8e-9Initial program 72.1%
Taylor expanded in x around 0 72.1%
flip--71.8%
frac-2neg71.8%
metadata-eval71.8%
sub-1-cos92.6%
pow292.6%
Applied egg-rr92.6%
remove-double-neg92.6%
neg-sub092.6%
+-commutative92.6%
associate--r+92.6%
metadata-eval92.6%
Simplified92.6%
Taylor expanded in eps around inf 92.6%
mul-1-neg99.4%
+-commutative99.4%
unpow299.4%
associate-*r/99.3%
distribute-rgt-neg-in99.3%
+-commutative99.3%
hang-0p-tan99.8%
Simplified93.0%
Final simplification71.0%
(FPCore (x eps) :precision binary64 (* -2.0 (* (sin (* 0.5 (+ eps (- x x)))) (sin (* 0.5 (+ eps (+ x x)))))))
double code(double x, double eps) {
return -2.0 * (sin((0.5 * (eps + (x - x)))) * sin((0.5 * (eps + (x + x)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (-2.0d0) * (sin((0.5d0 * (eps + (x - x)))) * sin((0.5d0 * (eps + (x + x)))))
end function
public static double code(double x, double eps) {
return -2.0 * (Math.sin((0.5 * (eps + (x - x)))) * Math.sin((0.5 * (eps + (x + x)))));
}
def code(x, eps): return -2.0 * (math.sin((0.5 * (eps + (x - x)))) * math.sin((0.5 * (eps + (x + x)))))
function code(x, eps) return Float64(-2.0 * Float64(sin(Float64(0.5 * Float64(eps + Float64(x - x)))) * sin(Float64(0.5 * Float64(eps + Float64(x + x)))))) end
function tmp = code(x, eps) tmp = -2.0 * (sin((0.5 * (eps + (x - x)))) * sin((0.5 * (eps + (x + x))))); end
code[x_, eps_] := N[(-2.0 * N[(N[Sin[N[(0.5 * N[(eps + N[(x - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(\sin \left(0.5 \cdot \left(\varepsilon + \left(x - x\right)\right)\right) \cdot \sin \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)
\end{array}
Initial program 37.2%
log1p-expm1-u37.1%
Applied egg-rr37.1%
diff-cos47.1%
log1p-expm1-u47.2%
div-inv47.2%
metadata-eval47.2%
div-inv47.2%
metadata-eval47.2%
Applied egg-rr47.2%
*-commutative47.2%
+-commutative47.2%
associate--l+73.9%
*-commutative73.9%
+-commutative73.9%
associate-+l+74.0%
Simplified74.0%
Final simplification74.0%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.8e-9) (not (<= x 1.3e-9))) (* (sin x) (* (sin (* eps 0.5)) -2.0)) (* (tan (/ eps 2.0)) (- (sin eps)))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.8e-9) || !(x <= 1.3e-9)) {
tmp = sin(x) * (sin((eps * 0.5)) * -2.0);
} else {
tmp = tan((eps / 2.0)) * -sin(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-2.8d-9)) .or. (.not. (x <= 1.3d-9))) then
tmp = sin(x) * (sin((eps * 0.5d0)) * (-2.0d0))
else
tmp = tan((eps / 2.0d0)) * -sin(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -2.8e-9) || !(x <= 1.3e-9)) {
tmp = Math.sin(x) * (Math.sin((eps * 0.5)) * -2.0);
} else {
tmp = Math.tan((eps / 2.0)) * -Math.sin(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2.8e-9) or not (x <= 1.3e-9): tmp = math.sin(x) * (math.sin((eps * 0.5)) * -2.0) else: tmp = math.tan((eps / 2.0)) * -math.sin(eps) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2.8e-9) || !(x <= 1.3e-9)) tmp = Float64(sin(x) * Float64(sin(Float64(eps * 0.5)) * -2.0)); else tmp = Float64(tan(Float64(eps / 2.0)) * Float64(-sin(eps))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -2.8e-9) || ~((x <= 1.3e-9))) tmp = sin(x) * (sin((eps * 0.5)) * -2.0); else tmp = tan((eps / 2.0)) * -sin(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.8e-9], N[Not[LessEqual[x, 1.3e-9]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-9} \lor \neg \left(x \leq 1.3 \cdot 10^{-9}\right):\\
\;\;\;\;\sin x \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right)\\
\end{array}
\end{array}
if x < -2.79999999999999984e-9 or 1.3000000000000001e-9 < x Initial program 6.6%
diff-cos7.3%
div-inv7.3%
associate--l+7.3%
metadata-eval7.3%
div-inv7.3%
+-commutative7.3%
associate-+l+7.6%
metadata-eval7.6%
Applied egg-rr7.6%
associate-*r*7.6%
*-commutative7.6%
*-commutative7.6%
+-commutative7.6%
count-27.6%
fma-def7.6%
sub-neg7.6%
mul-1-neg7.6%
+-commutative7.6%
associate-+r+51.0%
mul-1-neg51.0%
sub-neg51.0%
+-inverses51.0%
remove-double-neg51.0%
mul-1-neg51.0%
sub-neg51.0%
neg-sub051.0%
mul-1-neg51.0%
remove-double-neg51.0%
Simplified51.0%
Taylor expanded in eps around 0 50.8%
if -2.79999999999999984e-9 < x < 1.3000000000000001e-9Initial program 70.4%
Taylor expanded in x around 0 70.4%
flip--70.1%
frac-2neg70.1%
metadata-eval70.1%
sub-1-cos88.7%
pow288.7%
Applied egg-rr88.7%
remove-double-neg88.7%
neg-sub088.7%
+-commutative88.7%
associate--r+88.7%
metadata-eval88.7%
Simplified88.7%
Taylor expanded in eps around inf 88.7%
mul-1-neg99.3%
+-commutative99.3%
unpow299.3%
associate-*r/99.3%
distribute-rgt-neg-in99.3%
+-commutative99.3%
hang-0p-tan99.8%
Simplified89.2%
Final simplification69.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.75e-9) (not (<= x 3.9e-12))) (* eps (- (sin x))) (* -2.0 (pow (sin (* eps 0.5)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.75e-9) || !(x <= 3.9e-12)) {
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 <= (-2.75d-9)) .or. (.not. (x <= 3.9d-12))) 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 <= -2.75e-9) || !(x <= 3.9e-12)) {
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 <= -2.75e-9) or not (x <= 3.9e-12): 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 <= -2.75e-9) || !(x <= 3.9e-12)) 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 <= -2.75e-9) || ~((x <= 3.9e-12))) 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, -2.75e-9], N[Not[LessEqual[x, 3.9e-12]], $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 -2.75 \cdot 10^{-9} \lor \neg \left(x \leq 3.9 \cdot 10^{-12}\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 < -2.7499999999999998e-9 or 3.89999999999999994e-12 < x Initial program 6.6%
Taylor expanded in eps around 0 45.9%
mul-1-neg45.9%
*-commutative45.9%
distribute-rgt-neg-in45.9%
Simplified45.9%
if -2.7499999999999998e-9 < x < 3.89999999999999994e-12Initial program 70.4%
diff-cos90.4%
div-inv90.4%
associate--l+90.4%
metadata-eval90.4%
div-inv90.4%
+-commutative90.4%
associate-+l+90.4%
metadata-eval90.4%
Applied egg-rr90.4%
associate-*r*90.4%
*-commutative90.4%
*-commutative90.4%
+-commutative90.4%
count-290.4%
fma-def90.4%
sub-neg90.4%
mul-1-neg90.4%
+-commutative90.4%
associate-+r+98.8%
mul-1-neg98.8%
sub-neg98.8%
+-inverses98.8%
remove-double-neg98.8%
mul-1-neg98.8%
sub-neg98.8%
neg-sub098.8%
mul-1-neg98.8%
remove-double-neg98.8%
Simplified98.8%
Taylor expanded in x around 0 89.0%
Final simplification66.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.7e-9) (not (<= x 1.9e-12))) (* eps (- (sin x))) (* (tan (/ eps 2.0)) (- (sin eps)))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.7e-9) || !(x <= 1.9e-12)) {
tmp = eps * -sin(x);
} else {
tmp = tan((eps / 2.0)) * -sin(eps);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-2.7d-9)) .or. (.not. (x <= 1.9d-12))) then
tmp = eps * -sin(x)
else
tmp = tan((eps / 2.0d0)) * -sin(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -2.7e-9) || !(x <= 1.9e-12)) {
tmp = eps * -Math.sin(x);
} else {
tmp = Math.tan((eps / 2.0)) * -Math.sin(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2.7e-9) or not (x <= 1.9e-12): tmp = eps * -math.sin(x) else: tmp = math.tan((eps / 2.0)) * -math.sin(eps) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2.7e-9) || !(x <= 1.9e-12)) tmp = Float64(eps * Float64(-sin(x))); else tmp = Float64(tan(Float64(eps / 2.0)) * Float64(-sin(eps))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -2.7e-9) || ~((x <= 1.9e-12))) tmp = eps * -sin(x); else tmp = tan((eps / 2.0)) * -sin(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.7e-9], N[Not[LessEqual[x, 1.9e-12]], $MachinePrecision]], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision], N[(N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-9} \lor \neg \left(x \leq 1.9 \cdot 10^{-12}\right):\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(\frac{\varepsilon}{2}\right) \cdot \left(-\sin \varepsilon\right)\\
\end{array}
\end{array}
if x < -2.7000000000000002e-9 or 1.89999999999999998e-12 < x Initial program 6.6%
Taylor expanded in eps around 0 45.9%
mul-1-neg45.9%
*-commutative45.9%
distribute-rgt-neg-in45.9%
Simplified45.9%
if -2.7000000000000002e-9 < x < 1.89999999999999998e-12Initial program 70.4%
Taylor expanded in x around 0 70.4%
flip--70.1%
frac-2neg70.1%
metadata-eval70.1%
sub-1-cos88.7%
pow288.7%
Applied egg-rr88.7%
remove-double-neg88.7%
neg-sub088.7%
+-commutative88.7%
associate--r+88.7%
metadata-eval88.7%
Simplified88.7%
Taylor expanded in eps around inf 88.7%
mul-1-neg99.3%
+-commutative99.3%
unpow299.3%
associate-*r/99.3%
distribute-rgt-neg-in99.3%
+-commutative99.3%
hang-0p-tan99.8%
Simplified89.2%
Final simplification66.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* -0.5 (pow eps 2.0))))
(if (<= eps -0.000156)
t_0
(if (<= eps -2.45e-147)
t_1
(if (<= eps 3.2e-144) (* eps (- x)) (if (<= eps 0.00016) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = -0.5 * pow(eps, 2.0);
double tmp;
if (eps <= -0.000156) {
tmp = t_0;
} else if (eps <= -2.45e-147) {
tmp = t_1;
} else if (eps <= 3.2e-144) {
tmp = eps * -x;
} else if (eps <= 0.00016) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(eps) + (-1.0d0)
t_1 = (-0.5d0) * (eps ** 2.0d0)
if (eps <= (-0.000156d0)) then
tmp = t_0
else if (eps <= (-2.45d-147)) then
tmp = t_1
else if (eps <= 3.2d-144) then
tmp = eps * -x
else if (eps <= 0.00016d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.cos(eps) + -1.0;
double t_1 = -0.5 * Math.pow(eps, 2.0);
double tmp;
if (eps <= -0.000156) {
tmp = t_0;
} else if (eps <= -2.45e-147) {
tmp = t_1;
} else if (eps <= 3.2e-144) {
tmp = eps * -x;
} else if (eps <= 0.00016) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = -0.5 * math.pow(eps, 2.0) tmp = 0 if eps <= -0.000156: tmp = t_0 elif eps <= -2.45e-147: tmp = t_1 elif eps <= 3.2e-144: tmp = eps * -x elif eps <= 0.00016: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(-0.5 * (eps ^ 2.0)) tmp = 0.0 if (eps <= -0.000156) tmp = t_0; elseif (eps <= -2.45e-147) tmp = t_1; elseif (eps <= 3.2e-144) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.00016) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = cos(eps) + -1.0; t_1 = -0.5 * (eps ^ 2.0); tmp = 0.0; if (eps <= -0.000156) tmp = t_0; elseif (eps <= -2.45e-147) tmp = t_1; elseif (eps <= 3.2e-144) tmp = eps * -x; elseif (eps <= 0.00016) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.000156], t$95$0, If[LessEqual[eps, -2.45e-147], t$95$1, If[LessEqual[eps, 3.2e-144], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00016], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := -0.5 \cdot {\varepsilon}^{2}\\
\mathbf{if}\;\varepsilon \leq -0.000156:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -2.45 \cdot 10^{-147}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{-144}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00016:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.56e-4 or 1.60000000000000013e-4 < eps Initial program 48.4%
Taylor expanded in x around 0 51.2%
if -1.56e-4 < eps < -2.45000000000000002e-147 or 3.19999999999999973e-144 < eps < 1.60000000000000013e-4Initial program 6.0%
Taylor expanded in x around 0 6.0%
Taylor expanded in eps around 0 48.2%
if -2.45000000000000002e-147 < eps < 3.19999999999999973e-144Initial program 39.3%
Taylor expanded in eps around 0 98.9%
mul-1-neg98.9%
*-commutative98.9%
distribute-rgt-neg-in98.9%
Simplified98.9%
Taylor expanded in x around 0 51.4%
mul-1-neg51.4%
distribute-rgt-neg-in51.4%
Simplified51.4%
Final simplification50.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* eps (- (sin x)))))
(if (<= eps -0.0044)
t_0
(if (<= eps 3e-101)
t_1
(if (<= eps 7.5e-6)
(* -0.5 (pow eps 2.0))
(if (<= eps 1.9e-5) t_1 t_0))))))
double code(double x, double eps) {
double t_0 = cos(eps) + -1.0;
double t_1 = eps * -sin(x);
double tmp;
if (eps <= -0.0044) {
tmp = t_0;
} else if (eps <= 3e-101) {
tmp = t_1;
} else if (eps <= 7.5e-6) {
tmp = -0.5 * pow(eps, 2.0);
} else if (eps <= 1.9e-5) {
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 * -sin(x)
if (eps <= (-0.0044d0)) then
tmp = t_0
else if (eps <= 3d-101) then
tmp = t_1
else if (eps <= 7.5d-6) then
tmp = (-0.5d0) * (eps ** 2.0d0)
else if (eps <= 1.9d-5) 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 * -Math.sin(x);
double tmp;
if (eps <= -0.0044) {
tmp = t_0;
} else if (eps <= 3e-101) {
tmp = t_1;
} else if (eps <= 7.5e-6) {
tmp = -0.5 * Math.pow(eps, 2.0);
} else if (eps <= 1.9e-5) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.cos(eps) + -1.0 t_1 = eps * -math.sin(x) tmp = 0 if eps <= -0.0044: tmp = t_0 elif eps <= 3e-101: tmp = t_1 elif eps <= 7.5e-6: tmp = -0.5 * math.pow(eps, 2.0) elif eps <= 1.9e-5: 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(-sin(x))) tmp = 0.0 if (eps <= -0.0044) tmp = t_0; elseif (eps <= 3e-101) tmp = t_1; elseif (eps <= 7.5e-6) tmp = Float64(-0.5 * (eps ^ 2.0)); elseif (eps <= 1.9e-5) 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 * -sin(x); tmp = 0.0; if (eps <= -0.0044) tmp = t_0; elseif (eps <= 3e-101) tmp = t_1; elseif (eps <= 7.5e-6) tmp = -0.5 * (eps ^ 2.0); elseif (eps <= 1.9e-5) 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[Sin[x], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[eps, -0.0044], t$95$0, If[LessEqual[eps, 3e-101], t$95$1, If[LessEqual[eps, 7.5e-6], N[(-0.5 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.9e-5], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \varepsilon \cdot \left(-\sin x\right)\\
\mathbf{if}\;\varepsilon \leq -0.0044:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-101}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;-0.5 \cdot {\varepsilon}^{2}\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -0.00440000000000000027 or 1.9000000000000001e-5 < eps Initial program 48.8%
Taylor expanded in x around 0 51.6%
if -0.00440000000000000027 < eps < 3.0000000000000003e-101 or 7.50000000000000019e-6 < eps < 1.9000000000000001e-5Initial program 26.8%
Taylor expanded in eps around 0 84.8%
mul-1-neg84.8%
*-commutative84.8%
distribute-rgt-neg-in84.8%
Simplified84.8%
if 3.0000000000000003e-101 < eps < 7.50000000000000019e-6Initial program 4.2%
Taylor expanded in x around 0 4.2%
Taylor expanded in eps around 0 65.8%
Final simplification66.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.1e-46) (not (<= eps 2.05e-71))) (+ (cos eps) -1.0) (* eps (- x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-46) || !(eps <= 2.05e-71)) {
tmp = cos(eps) + -1.0;
} else {
tmp = eps * -x;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-1.1d-46)) .or. (.not. (eps <= 2.05d-71))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = eps * -x
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -1.1e-46) || !(eps <= 2.05e-71)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -x;
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.1e-46) or not (eps <= 2.05e-71): tmp = math.cos(eps) + -1.0 else: tmp = eps * -x return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.1e-46) || !(eps <= 2.05e-71)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(eps * Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.1e-46) || ~((eps <= 2.05e-71))) tmp = cos(eps) + -1.0; else tmp = eps * -x; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.1e-46], N[Not[LessEqual[eps, 2.05e-71]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-46} \lor \neg \left(\varepsilon \leq 2.05 \cdot 10^{-71}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\end{array}
\end{array}
if eps < -1.1e-46 or 2.04999999999999997e-71 < eps Initial program 43.9%
Taylor expanded in x around 0 46.4%
if -1.1e-46 < eps < 2.04999999999999997e-71Initial program 27.4%
Taylor expanded in eps around 0 83.4%
mul-1-neg83.4%
*-commutative83.4%
distribute-rgt-neg-in83.4%
Simplified83.4%
Taylor expanded in x around 0 38.6%
mul-1-neg38.6%
distribute-rgt-neg-in38.6%
Simplified38.6%
Final simplification43.2%
(FPCore (x eps) :precision binary64 (* eps (- x)))
double code(double x, double eps) {
return eps * -x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * -x
end function
public static double code(double x, double eps) {
return eps * -x;
}
def code(x, eps): return eps * -x
function code(x, eps) return Float64(eps * Float64(-x)) end
function tmp = code(x, eps) tmp = eps * -x; end
code[x_, eps_] := N[(eps * (-x)), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(-x\right)
\end{array}
Initial program 37.2%
Taylor expanded in eps around 0 39.1%
mul-1-neg39.1%
*-commutative39.1%
distribute-rgt-neg-in39.1%
Simplified39.1%
Taylor expanded in x around 0 17.5%
mul-1-neg17.5%
distribute-rgt-neg-in17.5%
Simplified17.5%
Final simplification17.5%
herbie shell --seed 2023322
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))