
(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 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (fma (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 * fma(sin(x), cos((0.5 * eps)), (t_0 * cos(x))));
}
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * fma(sin(x), cos(Float64(0.5 * eps)), Float64(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[Sin[x], $MachinePrecision] * N[Cos[N[(0.5 * eps), $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 \mathsf{fma}\left(\sin x, \cos \left(0.5 \cdot \varepsilon\right), t_0 \cdot \cos x\right)\right)
\end{array}
\end{array}
Initial program 38.4%
diff-cos46.6%
div-inv46.6%
metadata-eval46.6%
div-inv46.6%
+-commutative46.6%
metadata-eval46.6%
Applied egg-rr46.6%
*-commutative46.6%
+-commutative46.6%
associate--l+77.5%
+-inverses77.5%
distribute-lft-in77.5%
metadata-eval77.5%
*-commutative77.5%
associate-+r+77.5%
+-commutative77.5%
Simplified77.5%
distribute-rgt-in77.5%
*-commutative77.5%
sin-sum99.4%
Applied egg-rr99.4%
Taylor expanded in eps around inf 99.4%
+-commutative99.4%
*-commutative99.4%
fma-def99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (+ (* t_0 (cos x)) (* (sin x) (cos (* 0.5 eps))))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * ((t_0 * cos(x)) + (sin(x) * cos((0.5 * eps)))));
}
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 * ((t_0 * cos(x)) + (sin(x) * cos((0.5d0 * eps)))))
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((0.5 * eps));
return -2.0 * (t_0 * ((t_0 * Math.cos(x)) + (Math.sin(x) * Math.cos((0.5 * eps)))));
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) return -2.0 * (t_0 * ((t_0 * math.cos(x)) + (math.sin(x) * math.cos((0.5 * eps)))))
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * Float64(Float64(t_0 * cos(x)) + Float64(sin(x) * cos(Float64(0.5 * eps)))))) end
function tmp = code(x, eps) t_0 = sin((0.5 * eps)); tmp = -2.0 * (t_0 * ((t_0 * cos(x)) + (sin(x) * cos((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[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] + 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 \left(t_0 \cdot \cos x + \sin x \cdot \cos \left(0.5 \cdot \varepsilon\right)\right)\right)
\end{array}
\end{array}
Initial program 38.4%
diff-cos46.6%
div-inv46.6%
metadata-eval46.6%
div-inv46.6%
+-commutative46.6%
metadata-eval46.6%
Applied egg-rr46.6%
*-commutative46.6%
+-commutative46.6%
associate--l+77.5%
+-inverses77.5%
distribute-lft-in77.5%
metadata-eval77.5%
*-commutative77.5%
associate-+r+77.5%
+-commutative77.5%
Simplified77.5%
distribute-rgt-in77.5%
*-commutative77.5%
sin-sum99.4%
Applied egg-rr99.4%
Taylor expanded in eps around inf 99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.5e-5) (not (<= eps 0.00018))) (- (- (* (cos x) (cos eps)) (* (sin x) (sin eps))) (cos x)) (* -2.0 (* (sin (* 0.5 eps)) (sin (* 0.5 (- eps (* -2.0 x))))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -2.5e-5) || !(eps <= 0.00018)) {
tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x);
} else {
tmp = -2.0 * (sin((0.5 * eps)) * sin((0.5 * (eps - (-2.0 * 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.5d-5)) .or. (.not. (eps <= 0.00018d0))) then
tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x)
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * sin((0.5d0 * (eps - ((-2.0d0) * x)))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -2.5e-5) || !(eps <= 0.00018)) {
tmp = ((Math.cos(x) * Math.cos(eps)) - (Math.sin(x) * Math.sin(eps))) - Math.cos(x);
} else {
tmp = -2.0 * (Math.sin((0.5 * eps)) * Math.sin((0.5 * (eps - (-2.0 * x)))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -2.5e-5) or not (eps <= 0.00018): tmp = ((math.cos(x) * math.cos(eps)) - (math.sin(x) * math.sin(eps))) - math.cos(x) else: tmp = -2.0 * (math.sin((0.5 * eps)) * math.sin((0.5 * (eps - (-2.0 * x))))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -2.5e-5) || !(eps <= 0.00018)) tmp = Float64(Float64(Float64(cos(x) * cos(eps)) - Float64(sin(x) * sin(eps))) - cos(x)); else tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * sin(Float64(0.5 * Float64(eps - Float64(-2.0 * x)))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -2.5e-5) || ~((eps <= 0.00018))) tmp = ((cos(x) * cos(eps)) - (sin(x) * sin(eps))) - cos(x); else tmp = -2.0 * (sin((0.5 * eps)) * sin((0.5 * (eps - (-2.0 * x))))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -2.5e-5], N[Not[LessEqual[eps, 0.00018]], $MachinePrecision]], N[(N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.5 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 0.00018\right):\\
\;\;\;\;\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x\\
\mathbf{else}:\\
\;\;\;\;-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}
\end{array}
if eps < -2.50000000000000012e-5 or 1.80000000000000011e-4 < eps Initial program 54.3%
cos-sum98.6%
Applied egg-rr98.6%
if -2.50000000000000012e-5 < eps < 1.80000000000000011e-4Initial program 21.9%
diff-cos39.3%
div-inv39.3%
metadata-eval39.3%
div-inv39.3%
+-commutative39.3%
metadata-eval39.3%
Applied egg-rr39.3%
*-commutative39.3%
+-commutative39.3%
associate--l+99.7%
+-inverses99.7%
distribute-lft-in99.7%
metadata-eval99.7%
*-commutative99.7%
associate-+r+99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around -inf 99.8%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (+ t_0 (* (cos (* 0.5 eps)) (sin (* 0.5 (+ x x)))))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * (t_0 + (cos((0.5 * eps)) * sin((0.5 * (x + 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 * (t_0 + (cos((0.5d0 * eps)) * sin((0.5d0 * (x + x))))))
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((0.5 * eps));
return -2.0 * (t_0 * (t_0 + (Math.cos((0.5 * eps)) * Math.sin((0.5 * (x + x))))));
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) return -2.0 * (t_0 * (t_0 + (math.cos((0.5 * eps)) * math.sin((0.5 * (x + x))))))
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * Float64(t_0 + Float64(cos(Float64(0.5 * eps)) * sin(Float64(0.5 * Float64(x + x))))))) end
function tmp = code(x, eps) t_0 = sin((0.5 * eps)); tmp = -2.0 * (t_0 * (t_0 + (cos((0.5 * eps)) * sin((0.5 * (x + 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[(t$95$0 + N[(N[Cos[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * N[(x + x), $MachinePrecision]), $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 \left(t_0 + \cos \left(0.5 \cdot \varepsilon\right) \cdot \sin \left(0.5 \cdot \left(x + x\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 38.4%
diff-cos46.6%
div-inv46.6%
metadata-eval46.6%
div-inv46.6%
+-commutative46.6%
metadata-eval46.6%
Applied egg-rr46.6%
*-commutative46.6%
+-commutative46.6%
associate--l+77.5%
+-inverses77.5%
distribute-lft-in77.5%
metadata-eval77.5%
*-commutative77.5%
associate-+r+77.5%
+-commutative77.5%
Simplified77.5%
distribute-rgt-in77.5%
*-commutative77.5%
sin-sum99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 79.1%
Final simplification79.1%
(FPCore (x eps) :precision binary64 (let* ((t_0 (sin (* 0.5 eps)))) (* -2.0 (* t_0 (+ (sin x) (* t_0 (cos (* 0.5 (+ x x)))))))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
return -2.0 * (t_0 * (sin(x) + (t_0 * cos((0.5 * (x + 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) + (t_0 * cos((0.5d0 * (x + 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) + (t_0 * Math.cos((0.5 * (x + x))))));
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) return -2.0 * (t_0 * (math.sin(x) + (t_0 * math.cos((0.5 * (x + x))))))
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) return Float64(-2.0 * Float64(t_0 * Float64(sin(x) + Float64(t_0 * cos(Float64(0.5 * Float64(x + x))))))) end
function tmp = code(x, eps) t_0 = sin((0.5 * eps)); tmp = -2.0 * (t_0 * (sin(x) + (t_0 * cos((0.5 * (x + 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[Sin[x], $MachinePrecision] + N[(t$95$0 * N[Cos[N[(0.5 * N[(x + x), $MachinePrecision]), $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 \left(\sin x + t_0 \cdot \cos \left(0.5 \cdot \left(x + x\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 38.4%
diff-cos46.6%
div-inv46.6%
metadata-eval46.6%
div-inv46.6%
+-commutative46.6%
metadata-eval46.6%
Applied egg-rr46.6%
*-commutative46.6%
+-commutative46.6%
associate--l+77.5%
+-inverses77.5%
distribute-lft-in77.5%
metadata-eval77.5%
*-commutative77.5%
associate-+r+77.5%
+-commutative77.5%
Simplified77.5%
distribute-rgt-in77.5%
*-commutative77.5%
sin-sum99.4%
Applied egg-rr99.4%
Taylor expanded in eps around 0 78.9%
Final simplification78.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (+ (cos eps) -1.0) (* x (sin eps))))
(t_1 (sin (* 0.5 eps)))
(t_2 (* -2.0 (* t_1 (sin x)))))
(if (<= x -0.002)
t_2
(if (<= x -4.1e-95)
t_0
(if (<= x 3.2e-109)
(* -2.0 (pow t_1 2.0))
(if (<= x 2.4e-11) t_0 t_2))))))
double code(double x, double eps) {
double t_0 = (cos(eps) + -1.0) - (x * sin(eps));
double t_1 = sin((0.5 * eps));
double t_2 = -2.0 * (t_1 * sin(x));
double tmp;
if (x <= -0.002) {
tmp = t_2;
} else if (x <= -4.1e-95) {
tmp = t_0;
} else if (x <= 3.2e-109) {
tmp = -2.0 * pow(t_1, 2.0);
} else if (x <= 2.4e-11) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = (cos(eps) + (-1.0d0)) - (x * sin(eps))
t_1 = sin((0.5d0 * eps))
t_2 = (-2.0d0) * (t_1 * sin(x))
if (x <= (-0.002d0)) then
tmp = t_2
else if (x <= (-4.1d-95)) then
tmp = t_0
else if (x <= 3.2d-109) then
tmp = (-2.0d0) * (t_1 ** 2.0d0)
else if (x <= 2.4d-11) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (Math.cos(eps) + -1.0) - (x * Math.sin(eps));
double t_1 = Math.sin((0.5 * eps));
double t_2 = -2.0 * (t_1 * Math.sin(x));
double tmp;
if (x <= -0.002) {
tmp = t_2;
} else if (x <= -4.1e-95) {
tmp = t_0;
} else if (x <= 3.2e-109) {
tmp = -2.0 * Math.pow(t_1, 2.0);
} else if (x <= 2.4e-11) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, eps): t_0 = (math.cos(eps) + -1.0) - (x * math.sin(eps)) t_1 = math.sin((0.5 * eps)) t_2 = -2.0 * (t_1 * math.sin(x)) tmp = 0 if x <= -0.002: tmp = t_2 elif x <= -4.1e-95: tmp = t_0 elif x <= 3.2e-109: tmp = -2.0 * math.pow(t_1, 2.0) elif x <= 2.4e-11: tmp = t_0 else: tmp = t_2 return tmp
function code(x, eps) t_0 = Float64(Float64(cos(eps) + -1.0) - Float64(x * sin(eps))) t_1 = sin(Float64(0.5 * eps)) t_2 = Float64(-2.0 * Float64(t_1 * sin(x))) tmp = 0.0 if (x <= -0.002) tmp = t_2; elseif (x <= -4.1e-95) tmp = t_0; elseif (x <= 3.2e-109) tmp = Float64(-2.0 * (t_1 ^ 2.0)); elseif (x <= 2.4e-11) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x, eps) t_0 = (cos(eps) + -1.0) - (x * sin(eps)); t_1 = sin((0.5 * eps)); t_2 = -2.0 * (t_1 * sin(x)); tmp = 0.0; if (x <= -0.002) tmp = t_2; elseif (x <= -4.1e-95) tmp = t_0; elseif (x <= 3.2e-109) tmp = -2.0 * (t_1 ^ 2.0); elseif (x <= 2.4e-11) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision] - N[(x * N[Sin[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(-2.0 * N[(t$95$1 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.002], t$95$2, If[LessEqual[x, -4.1e-95], t$95$0, If[LessEqual[x, 3.2e-109], N[(-2.0 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4e-11], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \varepsilon + -1\right) - x \cdot \sin \varepsilon\\
t_1 := \sin \left(0.5 \cdot \varepsilon\right)\\
t_2 := -2 \cdot \left(t_1 \cdot \sin x\right)\\
\mathbf{if}\;x \leq -0.002:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -4.1 \cdot 10^{-95}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-109}:\\
\;\;\;\;-2 \cdot {t_1}^{2}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -2e-3 or 2.4000000000000001e-11 < x Initial program 7.5%
diff-cos6.7%
div-inv6.7%
metadata-eval6.7%
div-inv6.7%
+-commutative6.7%
metadata-eval6.7%
Applied egg-rr6.7%
*-commutative6.7%
+-commutative6.7%
associate--l+57.2%
+-inverses57.2%
distribute-lft-in57.2%
metadata-eval57.2%
*-commutative57.2%
associate-+r+57.2%
+-commutative57.2%
Simplified57.2%
distribute-rgt-in57.2%
*-commutative57.2%
sin-sum99.3%
Applied egg-rr99.3%
Taylor expanded in eps around inf 99.3%
+-commutative99.3%
*-commutative99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in eps around 0 57.6%
if -2e-3 < x < -4.0999999999999997e-95 or 3.2000000000000002e-109 < x < 2.4000000000000001e-11Initial program 63.5%
Taylor expanded in x around 0 65.3%
sub-neg65.3%
metadata-eval65.3%
+-commutative65.3%
associate-+r+91.1%
+-commutative91.1%
+-commutative91.1%
mul-1-neg91.1%
unsub-neg91.1%
unpow291.1%
associate-*l*91.1%
distribute-lft-out--91.1%
+-commutative91.1%
*-commutative91.1%
fma-def91.1%
Simplified91.1%
Taylor expanded in x around 0 90.6%
mul-1-neg90.6%
*-commutative90.6%
distribute-rgt-neg-in90.6%
Simplified90.6%
if -4.0999999999999997e-95 < x < 3.2000000000000002e-109Initial program 74.8%
diff-cos97.7%
div-inv97.7%
metadata-eval97.7%
div-inv97.7%
+-commutative97.7%
metadata-eval97.7%
Applied egg-rr97.7%
*-commutative97.7%
+-commutative97.7%
associate--l+99.4%
+-inverses99.4%
distribute-lft-in99.4%
metadata-eval99.4%
*-commutative99.4%
associate-+r+99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in x around 0 95.3%
Final simplification75.2%
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.007) (not (<= eps 0.0095))) (- (cos eps) (cos x)) (- (* (* eps eps) (* (cos x) -0.5)) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.007) || !(eps <= 0.0095)) {
tmp = cos(eps) - cos(x);
} else {
tmp = ((eps * eps) * (cos(x) * -0.5)) - (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 <= (-0.007d0)) .or. (.not. (eps <= 0.0095d0))) then
tmp = cos(eps) - cos(x)
else
tmp = ((eps * eps) * (cos(x) * (-0.5d0))) - (eps * sin(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.007) || !(eps <= 0.0095)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = ((eps * eps) * (Math.cos(x) * -0.5)) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.007) or not (eps <= 0.0095): tmp = math.cos(eps) - math.cos(x) else: tmp = ((eps * eps) * (math.cos(x) * -0.5)) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.007) || !(eps <= 0.0095)) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(Float64(Float64(eps * eps) * Float64(cos(x) * -0.5)) - Float64(eps * sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.007) || ~((eps <= 0.0095))) tmp = cos(eps) - cos(x); else tmp = ((eps * eps) * (cos(x) * -0.5)) - (eps * sin(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.007], N[Not[LessEqual[eps, 0.0095]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * eps), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - N[(eps * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.007 \lor \neg \left(\varepsilon \leq 0.0095\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\cos x \cdot -0.5\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if eps < -0.00700000000000000015 or 0.00949999999999999976 < eps Initial program 54.3%
Taylor expanded in x around 0 57.0%
if -0.00700000000000000015 < eps < 0.00949999999999999976Initial program 21.9%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
*-commutative99.7%
associate-*l*99.7%
unpow299.7%
Simplified99.7%
Final simplification78.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 38.4%
diff-cos46.6%
div-inv46.6%
metadata-eval46.6%
div-inv46.6%
+-commutative46.6%
metadata-eval46.6%
Applied egg-rr46.6%
*-commutative46.6%
+-commutative46.6%
associate--l+77.5%
+-inverses77.5%
distribute-lft-in77.5%
metadata-eval77.5%
*-commutative77.5%
associate-+r+77.5%
+-commutative77.5%
Simplified77.5%
Taylor expanded in x around -inf 77.5%
Final simplification77.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* 0.5 eps))))
(if (or (<= x -4.2e-30) (not (<= x 1.16e-11)))
(* -2.0 (* t_0 (sin x)))
(* -2.0 (pow t_0 2.0)))))
double code(double x, double eps) {
double t_0 = sin((0.5 * eps));
double tmp;
if ((x <= -4.2e-30) || !(x <= 1.16e-11)) {
tmp = -2.0 * (t_0 * sin(x));
} 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((0.5d0 * eps))
if ((x <= (-4.2d-30)) .or. (.not. (x <= 1.16d-11))) then
tmp = (-2.0d0) * (t_0 * sin(x))
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((0.5 * eps));
double tmp;
if ((x <= -4.2e-30) || !(x <= 1.16e-11)) {
tmp = -2.0 * (t_0 * Math.sin(x));
} else {
tmp = -2.0 * Math.pow(t_0, 2.0);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((0.5 * eps)) tmp = 0 if (x <= -4.2e-30) or not (x <= 1.16e-11): tmp = -2.0 * (t_0 * math.sin(x)) else: tmp = -2.0 * math.pow(t_0, 2.0) return tmp
function code(x, eps) t_0 = sin(Float64(0.5 * eps)) tmp = 0.0 if ((x <= -4.2e-30) || !(x <= 1.16e-11)) tmp = Float64(-2.0 * Float64(t_0 * sin(x))); else tmp = Float64(-2.0 * (t_0 ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((0.5 * eps)); tmp = 0.0; if ((x <= -4.2e-30) || ~((x <= 1.16e-11))) tmp = -2.0 * (t_0 * sin(x)); else tmp = -2.0 * (t_0 ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[x, -4.2e-30], N[Not[LessEqual[x, 1.16e-11]], $MachinePrecision]], N[(-2.0 * N[(t$95$0 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \varepsilon\right)\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{-30} \lor \neg \left(x \leq 1.16 \cdot 10^{-11}\right):\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -4.2000000000000004e-30 or 1.1600000000000001e-11 < x Initial program 7.7%
diff-cos6.9%
div-inv6.9%
metadata-eval6.9%
div-inv6.9%
+-commutative6.9%
metadata-eval6.9%
Applied egg-rr6.9%
*-commutative6.9%
+-commutative6.9%
associate--l+57.4%
+-inverses57.4%
distribute-lft-in57.4%
metadata-eval57.4%
*-commutative57.4%
associate-+r+57.4%
+-commutative57.4%
Simplified57.4%
distribute-rgt-in57.4%
*-commutative57.4%
sin-sum99.3%
Applied egg-rr99.3%
Taylor expanded in eps around inf 99.3%
+-commutative99.3%
*-commutative99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in eps around 0 57.5%
if -4.2000000000000004e-30 < x < 1.1600000000000001e-11Initial program 71.5%
diff-cos89.6%
div-inv89.6%
metadata-eval89.6%
div-inv89.6%
+-commutative89.6%
metadata-eval89.6%
Applied egg-rr89.6%
*-commutative89.6%
+-commutative89.6%
associate--l+99.2%
+-inverses99.2%
distribute-lft-in99.2%
metadata-eval99.2%
*-commutative99.2%
associate-+r+99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in x around 0 86.9%
Final simplification71.6%
(FPCore (x eps) :precision binary64 (if (or (<= eps -3.7e-41) (not (<= eps 1.78e-31))) (* -2.0 (pow (sin (* 0.5 eps)) 2.0)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -3.7e-41) || !(eps <= 1.78e-31)) {
tmp = -2.0 * pow(sin((0.5 * eps)), 2.0);
} else {
tmp = eps * -sin(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-3.7d-41)) .or. (.not. (eps <= 1.78d-31))) then
tmp = (-2.0d0) * (sin((0.5d0 * eps)) ** 2.0d0)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -3.7e-41) || !(eps <= 1.78e-31)) {
tmp = -2.0 * Math.pow(Math.sin((0.5 * eps)), 2.0);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -3.7e-41) or not (eps <= 1.78e-31): tmp = -2.0 * math.pow(math.sin((0.5 * eps)), 2.0) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -3.7e-41) || !(eps <= 1.78e-31)) tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -3.7e-41) || ~((eps <= 1.78e-31))) tmp = -2.0 * (sin((0.5 * eps)) ^ 2.0); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -3.7e-41], N[Not[LessEqual[eps, 1.78e-31]], $MachinePrecision]], N[(-2.0 * N[Power[N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -3.7 \cdot 10^{-41} \lor \neg \left(\varepsilon \leq 1.78 \cdot 10^{-31}\right):\\
\;\;\;\;-2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -3.7000000000000002e-41 or 1.77999999999999989e-31 < eps Initial program 51.4%
diff-cos55.8%
div-inv55.8%
metadata-eval55.8%
div-inv55.8%
+-commutative55.8%
metadata-eval55.8%
Applied egg-rr55.8%
*-commutative55.8%
+-commutative55.8%
associate--l+58.4%
+-inverses58.4%
distribute-lft-in58.4%
metadata-eval58.4%
*-commutative58.4%
associate-+r+58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in x around 0 57.0%
if -3.7000000000000002e-41 < eps < 1.77999999999999989e-31Initial program 23.1%
Taylor expanded in eps around 0 87.3%
mul-1-neg87.3%
*-commutative87.3%
distribute-rgt-neg-in87.3%
Simplified87.3%
Final simplification71.0%
(FPCore (x eps) :precision binary64 (if (or (<= eps -7.2e-37) (not (<= eps 4.8e-5))) (- (cos eps) (cos x)) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -7.2e-37) || !(eps <= 4.8e-5)) {
tmp = cos(eps) - cos(x);
} else {
tmp = eps * -sin(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-7.2d-37)) .or. (.not. (eps <= 4.8d-5))) then
tmp = cos(eps) - cos(x)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -7.2e-37) || !(eps <= 4.8e-5)) {
tmp = Math.cos(eps) - Math.cos(x);
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -7.2e-37) or not (eps <= 4.8e-5): tmp = math.cos(eps) - math.cos(x) else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -7.2e-37) || !(eps <= 4.8e-5)) tmp = Float64(cos(eps) - cos(x)); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -7.2e-37) || ~((eps <= 4.8e-5))) tmp = cos(eps) - cos(x); else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -7.2e-37], N[Not[LessEqual[eps, 4.8e-5]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7.2 \cdot 10^{-37} \lor \neg \left(\varepsilon \leq 4.8 \cdot 10^{-5}\right):\\
\;\;\;\;\cos \varepsilon - \cos x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -7.20000000000000014e-37 or 4.8000000000000001e-5 < eps Initial program 53.6%
Taylor expanded in x around 0 56.2%
if -7.20000000000000014e-37 < eps < 4.8000000000000001e-5Initial program 22.2%
Taylor expanded in eps around 0 84.1%
mul-1-neg84.1%
*-commutative84.1%
distribute-rgt-neg-in84.1%
Simplified84.1%
Final simplification69.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (cos eps) -1.0)) (t_1 (* (* eps eps) -0.5)))
(if (<= eps -0.00017)
t_0
(if (<= eps -9.5e-105)
t_1
(if (<= eps 3e-119) (* eps (- x)) (if (<= eps 0.00018) 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 <= -0.00017) {
tmp = t_0;
} else if (eps <= -9.5e-105) {
tmp = t_1;
} else if (eps <= 3e-119) {
tmp = eps * -x;
} else if (eps <= 0.00018) {
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 <= (-0.00017d0)) then
tmp = t_0
else if (eps <= (-9.5d-105)) then
tmp = t_1
else if (eps <= 3d-119) then
tmp = eps * -x
else if (eps <= 0.00018d0) 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 <= -0.00017) {
tmp = t_0;
} else if (eps <= -9.5e-105) {
tmp = t_1;
} else if (eps <= 3e-119) {
tmp = eps * -x;
} else if (eps <= 0.00018) {
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 <= -0.00017: tmp = t_0 elif eps <= -9.5e-105: tmp = t_1 elif eps <= 3e-119: tmp = eps * -x elif eps <= 0.00018: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(cos(eps) + -1.0) t_1 = Float64(Float64(eps * eps) * -0.5) tmp = 0.0 if (eps <= -0.00017) tmp = t_0; elseif (eps <= -9.5e-105) tmp = t_1; elseif (eps <= 3e-119) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.00018) 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 <= -0.00017) tmp = t_0; elseif (eps <= -9.5e-105) tmp = t_1; elseif (eps <= 3e-119) tmp = eps * -x; elseif (eps <= 0.00018) 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[(N[(eps * eps), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[eps, -0.00017], t$95$0, If[LessEqual[eps, -9.5e-105], t$95$1, If[LessEqual[eps, 3e-119], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00018], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \varepsilon + -1\\
t_1 := \left(\varepsilon \cdot \varepsilon\right) \cdot -0.5\\
\mathbf{if}\;\varepsilon \leq -0.00017:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq -9.5 \cdot 10^{-105}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{-119}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00018:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.7e-4 or 1.80000000000000011e-4 < eps Initial program 54.3%
Taylor expanded in x around 0 55.4%
if -1.7e-4 < eps < -9.5000000000000002e-105 or 3.0000000000000002e-119 < eps < 1.80000000000000011e-4Initial program 4.0%
Taylor expanded in x around 0 4.0%
Taylor expanded in eps around 0 47.0%
*-commutative47.0%
unpow247.0%
Simplified47.0%
if -9.5000000000000002e-105 < eps < 3.0000000000000002e-119Initial program 29.6%
Taylor expanded in eps around 0 94.9%
mul-1-neg94.9%
*-commutative94.9%
distribute-rgt-neg-in94.9%
Simplified94.9%
Taylor expanded in x around 0 43.2%
mul-1-neg43.2%
distribute-rgt-neg-in43.2%
Simplified43.2%
Final simplification49.9%
(FPCore (x eps) :precision binary64 (if (or (<= eps -7.2e-37) (not (<= eps 4.8e-6))) (+ (cos eps) -1.0) (* eps (- (sin x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -7.2e-37) || !(eps <= 4.8e-6)) {
tmp = cos(eps) + -1.0;
} else {
tmp = eps * -sin(x);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-7.2d-37)) .or. (.not. (eps <= 4.8d-6))) then
tmp = cos(eps) + (-1.0d0)
else
tmp = eps * -sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -7.2e-37) || !(eps <= 4.8e-6)) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = eps * -Math.sin(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -7.2e-37) or not (eps <= 4.8e-6): tmp = math.cos(eps) + -1.0 else: tmp = eps * -math.sin(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -7.2e-37) || !(eps <= 4.8e-6)) tmp = Float64(cos(eps) + -1.0); else tmp = Float64(eps * Float64(-sin(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -7.2e-37) || ~((eps <= 4.8e-6))) tmp = cos(eps) + -1.0; else tmp = eps * -sin(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -7.2e-37], N[Not[LessEqual[eps, 4.8e-6]], $MachinePrecision]], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(eps * (-N[Sin[x], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -7.2 \cdot 10^{-37} \lor \neg \left(\varepsilon \leq 4.8 \cdot 10^{-6}\right):\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-\sin x\right)\\
\end{array}
\end{array}
if eps < -7.20000000000000014e-37 or 4.7999999999999998e-6 < eps Initial program 53.6%
Taylor expanded in x around 0 54.6%
if -7.20000000000000014e-37 < eps < 4.7999999999999998e-6Initial program 22.2%
Taylor expanded in eps around 0 84.1%
mul-1-neg84.1%
*-commutative84.1%
distribute-rgt-neg-in84.1%
Simplified84.1%
Final simplification68.9%
(FPCore (x eps) :precision binary64 (if (<= x 9.5e-105) (* (* eps eps) -0.5) (* eps (- x))))
double code(double x, double eps) {
double tmp;
if (x <= 9.5e-105) {
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 <= 9.5d-105) 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 <= 9.5e-105) {
tmp = (eps * eps) * -0.5;
} else {
tmp = eps * -x;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 9.5e-105: tmp = (eps * eps) * -0.5 else: tmp = eps * -x return tmp
function code(x, eps) tmp = 0.0 if (x <= 9.5e-105) tmp = Float64(Float64(eps * eps) * -0.5); else tmp = Float64(eps * Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 9.5e-105) tmp = (eps * eps) * -0.5; else tmp = eps * -x; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 9.5e-105], N[(N[(eps * eps), $MachinePrecision] * -0.5), $MachinePrecision], N[(eps * (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{-105}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\end{array}
\end{array}
if x < 9.5000000000000002e-105Initial program 46.1%
Taylor expanded in x around 0 46.5%
Taylor expanded in eps around 0 24.5%
*-commutative24.5%
unpow224.5%
Simplified24.5%
if 9.5000000000000002e-105 < x Initial program 22.0%
Taylor expanded in eps around 0 50.9%
mul-1-neg50.9%
*-commutative50.9%
distribute-rgt-neg-in50.9%
Simplified50.9%
Taylor expanded in x around 0 16.8%
mul-1-neg16.8%
distribute-rgt-neg-in16.8%
Simplified16.8%
Final simplification22.0%
(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 38.4%
Taylor expanded in eps around 0 42.7%
mul-1-neg42.7%
*-commutative42.7%
distribute-rgt-neg-in42.7%
Simplified42.7%
Taylor expanded in x around 0 17.9%
mul-1-neg17.9%
distribute-rgt-neg-in17.9%
Simplified17.9%
Final simplification17.9%
herbie shell --seed 2023272
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))