
(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 13 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 34.8%
diff-cos44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
+-commutative44.4%
metadata-eval44.4%
Applied egg-rr44.4%
*-commutative44.4%
+-commutative44.4%
associate--l+75.6%
+-inverses75.6%
distribute-lft-in75.6%
metadata-eval75.6%
*-commutative75.6%
associate-+r+75.7%
+-commutative75.7%
Simplified75.7%
distribute-lft-in75.7%
sin-sum99.5%
Applied egg-rr99.5%
*-commutative99.5%
count-299.5%
*-commutative99.5%
count-299.5%
count-299.5%
*-commutative99.5%
count-299.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in eps around inf 99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(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 34.8%
diff-cos44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
+-commutative44.4%
metadata-eval44.4%
Applied egg-rr44.4%
*-commutative44.4%
+-commutative44.4%
associate--l+75.6%
+-inverses75.6%
distribute-lft-in75.6%
metadata-eval75.6%
*-commutative75.6%
associate-+r+75.7%
+-commutative75.7%
Simplified75.7%
distribute-lft-in75.7%
sin-sum99.5%
Applied egg-rr99.5%
*-commutative99.5%
count-299.5%
*-commutative99.5%
count-299.5%
count-299.5%
*-commutative99.5%
count-299.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in eps around inf 99.5%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.0033) (not (<= eps 0.0036)))
(- (* (cos x) (cos eps)) (+ (cos x) (* (sin x) (sin eps))))
(*
-2.0
(*
(sin (* 0.5 eps))
(+
(* (cos x) (+ (* 0.5 eps) (* -0.020833333333333332 (pow eps 3.0))))
(* (sin x) (+ 1.0 (* -0.125 (* eps eps)))))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.0033) || !(eps <= 0.0036)) {
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)));
} else {
tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + (-0.020833333333333332 * pow(eps, 3.0)))) + (sin(x) * (1.0 + (-0.125 * (eps * eps))))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.0033d0)) .or. (.not. (eps <= 0.0036d0))) then
tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps)))
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * ((cos(x) * ((0.5d0 * eps) + ((-0.020833333333333332d0) * (eps ** 3.0d0)))) + (sin(x) * (1.0d0 + ((-0.125d0) * (eps * eps))))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.0033) || !(eps <= 0.0036)) {
tmp = (Math.cos(x) * Math.cos(eps)) - (Math.cos(x) + (Math.sin(x) * Math.sin(eps)));
} else {
tmp = -2.0 * (Math.sin((0.5 * eps)) * ((Math.cos(x) * ((0.5 * eps) + (-0.020833333333333332 * Math.pow(eps, 3.0)))) + (Math.sin(x) * (1.0 + (-0.125 * (eps * eps))))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.0033) or not (eps <= 0.0036): tmp = (math.cos(x) * math.cos(eps)) - (math.cos(x) + (math.sin(x) * math.sin(eps))) else: tmp = -2.0 * (math.sin((0.5 * eps)) * ((math.cos(x) * ((0.5 * eps) + (-0.020833333333333332 * math.pow(eps, 3.0)))) + (math.sin(x) * (1.0 + (-0.125 * (eps * eps)))))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.0033) || !(eps <= 0.0036)) tmp = Float64(Float64(cos(x) * cos(eps)) - Float64(cos(x) + Float64(sin(x) * sin(eps)))); else tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * Float64(Float64(cos(x) * Float64(Float64(0.5 * eps) + Float64(-0.020833333333333332 * (eps ^ 3.0)))) + Float64(sin(x) * Float64(1.0 + Float64(-0.125 * Float64(eps * eps))))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.0033) || ~((eps <= 0.0036))) tmp = (cos(x) * cos(eps)) - (cos(x) + (sin(x) * sin(eps))); else tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + (-0.020833333333333332 * (eps ^ 3.0)))) + (sin(x) * (1.0 + (-0.125 * (eps * eps)))))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.0033], N[Not[LessEqual[eps, 0.0036]], $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[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(0.5 * eps), $MachinePrecision] + N[(-0.020833333333333332 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.0033 \lor \neg \left(\varepsilon \leq 0.0036\right):\\
\;\;\;\;\cos x \cdot \cos \varepsilon - \left(\cos x + \sin x \cdot \sin \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \left(\cos x \cdot \left(0.5 \cdot \varepsilon + -0.020833333333333332 \cdot {\varepsilon}^{3}\right) + \sin x \cdot \left(1 + -0.125 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)\\
\end{array}
\end{array}
if eps < -0.0033 or 0.0035999999999999999 < eps Initial program 50.1%
sub-neg50.1%
cos-sum98.9%
associate-+l-99.0%
fma-neg98.9%
Applied egg-rr98.9%
fma-neg99.0%
*-commutative99.0%
*-commutative99.0%
fma-neg98.9%
remove-double-neg98.9%
Simplified98.9%
fma-udef99.0%
Applied egg-rr99.0%
if -0.0033 < eps < 0.0035999999999999999Initial program 20.5%
diff-cos40.0%
div-inv40.0%
metadata-eval40.0%
div-inv40.0%
+-commutative40.0%
metadata-eval40.0%
Applied egg-rr40.0%
*-commutative40.0%
+-commutative40.0%
associate--l+98.6%
+-inverses98.6%
distribute-lft-in98.6%
metadata-eval98.6%
*-commutative98.6%
associate-+r+98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in eps around 0 99.8%
associate-+r+99.8%
+-commutative99.8%
+-commutative99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-lft-identity99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (cos eps))) (t_1 (* (sin x) (sin eps))))
(if (<= eps -0.004)
(- t_0 (+ (cos x) t_1))
(if (<= eps 0.0035)
(*
-2.0
(*
(sin (* 0.5 eps))
(+
(* (cos x) (+ (* 0.5 eps) (* -0.020833333333333332 (pow eps 3.0))))
(* (sin x) (+ 1.0 (* -0.125 (* eps eps)))))))
(- (- t_0 t_1) (cos x))))))
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.004) {
tmp = t_0 - (cos(x) + t_1);
} else if (eps <= 0.0035) {
tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + (-0.020833333333333332 * pow(eps, 3.0)))) + (sin(x) * (1.0 + (-0.125 * (eps * eps))))));
} else {
tmp = (t_0 - t_1) - cos(x);
}
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.004d0)) then
tmp = t_0 - (cos(x) + t_1)
else if (eps <= 0.0035d0) then
tmp = (-2.0d0) * (sin((0.5d0 * eps)) * ((cos(x) * ((0.5d0 * eps) + ((-0.020833333333333332d0) * (eps ** 3.0d0)))) + (sin(x) * (1.0d0 + ((-0.125d0) * (eps * eps))))))
else
tmp = (t_0 - t_1) - cos(x)
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.004) {
tmp = t_0 - (Math.cos(x) + t_1);
} else if (eps <= 0.0035) {
tmp = -2.0 * (Math.sin((0.5 * eps)) * ((Math.cos(x) * ((0.5 * eps) + (-0.020833333333333332 * Math.pow(eps, 3.0)))) + (Math.sin(x) * (1.0 + (-0.125 * (eps * eps))))));
} else {
tmp = (t_0 - t_1) - Math.cos(x);
}
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.004: tmp = t_0 - (math.cos(x) + t_1) elif eps <= 0.0035: tmp = -2.0 * (math.sin((0.5 * eps)) * ((math.cos(x) * ((0.5 * eps) + (-0.020833333333333332 * math.pow(eps, 3.0)))) + (math.sin(x) * (1.0 + (-0.125 * (eps * eps)))))) else: tmp = (t_0 - t_1) - math.cos(x) 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.004) tmp = Float64(t_0 - Float64(cos(x) + t_1)); elseif (eps <= 0.0035) tmp = Float64(-2.0 * Float64(sin(Float64(0.5 * eps)) * Float64(Float64(cos(x) * Float64(Float64(0.5 * eps) + Float64(-0.020833333333333332 * (eps ^ 3.0)))) + Float64(sin(x) * Float64(1.0 + Float64(-0.125 * Float64(eps * eps))))))); else tmp = Float64(Float64(t_0 - t_1) - cos(x)); 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.004) tmp = t_0 - (cos(x) + t_1); elseif (eps <= 0.0035) tmp = -2.0 * (sin((0.5 * eps)) * ((cos(x) * ((0.5 * eps) + (-0.020833333333333332 * (eps ^ 3.0)))) + (sin(x) * (1.0 + (-0.125 * (eps * eps)))))); else tmp = (t_0 - t_1) - cos(x); 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.004], N[(t$95$0 - N[(N[Cos[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.0035], N[(-2.0 * N[(N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] * N[(N[(0.5 * eps), $MachinePrecision] + N[(-0.020833333333333332 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - t$95$1), $MachinePrecision] - N[Cos[x], $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.004:\\
\;\;\;\;t_0 - \left(\cos x + t_1\right)\\
\mathbf{elif}\;\varepsilon \leq 0.0035:\\
\;\;\;\;-2 \cdot \left(\sin \left(0.5 \cdot \varepsilon\right) \cdot \left(\cos x \cdot \left(0.5 \cdot \varepsilon + -0.020833333333333332 \cdot {\varepsilon}^{3}\right) + \sin x \cdot \left(1 + -0.125 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 - t_1\right) - \cos x\\
\end{array}
\end{array}
if eps < -0.0040000000000000001Initial program 51.8%
sub-neg51.8%
cos-sum98.9%
associate-+l-99.0%
fma-neg99.0%
Applied egg-rr99.0%
fma-neg99.0%
*-commutative99.0%
*-commutative99.0%
fma-neg99.0%
remove-double-neg99.0%
Simplified99.0%
fma-udef99.0%
Applied egg-rr99.0%
if -0.0040000000000000001 < eps < 0.00350000000000000007Initial program 20.5%
diff-cos40.0%
div-inv40.0%
metadata-eval40.0%
div-inv40.0%
+-commutative40.0%
metadata-eval40.0%
Applied egg-rr40.0%
*-commutative40.0%
+-commutative40.0%
associate--l+98.6%
+-inverses98.6%
distribute-lft-in98.6%
metadata-eval98.6%
*-commutative98.6%
associate-+r+98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in eps around 0 99.8%
associate-+r+99.8%
+-commutative99.8%
+-commutative99.8%
associate-*r*99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
*-lft-identity99.8%
associate-*r*99.8%
distribute-rgt-out99.8%
unpow299.8%
Simplified99.8%
if 0.00350000000000000007 < eps Initial program 47.8%
cos-sum98.9%
Applied egg-rr98.9%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-12) (* -2.0 (pow (sin (* 0.5 eps)) 2.0)) (- (* (* eps eps) (* (cos x) -0.5)) (* eps (sin x)))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-12) {
tmp = -2.0 * pow(sin((0.5 * eps)), 2.0);
} 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 ((cos((eps + x)) - cos(x)) <= (-5d-12)) then
tmp = (-2.0d0) * (sin((0.5d0 * eps)) ** 2.0d0)
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 ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-12) {
tmp = -2.0 * Math.pow(Math.sin((0.5 * eps)), 2.0);
} else {
tmp = ((eps * eps) * (Math.cos(x) * -0.5)) - (eps * Math.sin(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-12: tmp = -2.0 * math.pow(math.sin((0.5 * eps)), 2.0) else: tmp = ((eps * eps) * (math.cos(x) * -0.5)) - (eps * math.sin(x)) return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-12) tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); 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 ((cos((eps + x)) - cos(x)) <= -5e-12) tmp = -2.0 * (sin((0.5 * eps)) ^ 2.0); else tmp = ((eps * eps) * (cos(x) * -0.5)) - (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], -5e-12], N[(-2.0 * N[Power[N[Sin[N[(0.5 * eps), $MachinePrecision]], $MachinePrecision], 2.0], $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}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;-2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\cos x \cdot -0.5\right) - \varepsilon \cdot \sin x\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 73.2%
diff-cos74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
+-commutative74.4%
metadata-eval74.4%
Applied egg-rr74.4%
*-commutative74.4%
+-commutative74.4%
associate--l+74.4%
+-inverses74.4%
distribute-lft-in74.4%
metadata-eval74.4%
*-commutative74.4%
associate-+r+74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in x around 0 74.2%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.0%
Taylor expanded in eps around 0 75.4%
+-commutative75.4%
mul-1-neg75.4%
unsub-neg75.4%
*-commutative75.4%
associate-*l*75.4%
unpow275.4%
Simplified75.4%
Final simplification75.0%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-12) (+ (* (cos x) (cos eps)) -1.0) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-12) {
tmp = (cos(x) * 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 ((cos((eps + x)) - cos(x)) <= (-5d-12)) then
tmp = (cos(x) * 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 ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-12) {
tmp = (Math.cos(x) * Math.cos(eps)) + -1.0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-12: tmp = (math.cos(x) * math.cos(eps)) + -1.0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-12) tmp = Float64(Float64(cos(x) * 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 ((cos((eps + x)) - cos(x)) <= -5e-12) tmp = (cos(x) * cos(eps)) + -1.0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;\cos x \cdot \cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 73.2%
sub-neg73.2%
cos-sum98.4%
associate-+l-98.4%
fma-neg98.4%
Applied egg-rr98.4%
fma-neg98.4%
*-commutative98.4%
*-commutative98.4%
fma-neg98.4%
remove-double-neg98.4%
Simplified98.4%
Taylor expanded in x around 0 73.5%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.0%
Taylor expanded in eps around 0 60.4%
mul-1-neg60.4%
*-commutative60.4%
distribute-rgt-neg-in60.4%
Simplified60.4%
Final simplification64.5%
(FPCore (x eps) :precision binary64 (if (<= (- (cos (+ eps x)) (cos x)) -5e-12) (+ (cos eps) -1.0) (* (sin x) (- eps))))
double code(double x, double eps) {
double tmp;
if ((cos((eps + x)) - cos(x)) <= -5e-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 ((cos((eps + x)) - cos(x)) <= (-5d-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 ((Math.cos((eps + x)) - Math.cos(x)) <= -5e-12) {
tmp = Math.cos(eps) + -1.0;
} else {
tmp = Math.sin(x) * -eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (math.cos((eps + x)) - math.cos(x)) <= -5e-12: tmp = math.cos(eps) + -1.0 else: tmp = math.sin(x) * -eps return tmp
function code(x, eps) tmp = 0.0 if (Float64(cos(Float64(eps + x)) - cos(x)) <= -5e-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 ((cos((eps + x)) - cos(x)) <= -5e-12) tmp = cos(eps) + -1.0; else tmp = sin(x) * -eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[Cos[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Cos[x], $MachinePrecision]), $MachinePrecision], -5e-12], N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * (-eps)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\varepsilon + x\right) - \cos x \leq -5 \cdot 10^{-12}:\\
\;\;\;\;\cos \varepsilon + -1\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\end{array}
\end{array}
if (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) < -4.9999999999999997e-12Initial program 73.2%
Taylor expanded in x around 0 73.3%
if -4.9999999999999997e-12 < (-.f64 (cos.f64 (+.f64 x eps)) (cos.f64 x)) Initial program 17.0%
Taylor expanded in eps around 0 60.4%
mul-1-neg60.4%
*-commutative60.4%
distribute-rgt-neg-in60.4%
Simplified60.4%
Final simplification64.5%
(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 34.8%
diff-cos44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
+-commutative44.4%
metadata-eval44.4%
Applied egg-rr44.4%
*-commutative44.4%
+-commutative44.4%
associate--l+75.6%
+-inverses75.6%
distribute-lft-in75.6%
metadata-eval75.6%
*-commutative75.6%
associate-+r+75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in x around -inf 75.7%
Final simplification75.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (* 0.5 eps))))
(if (or (<= x -7.9e-87) (not (<= x 6000.0)))
(* -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 <= -7.9e-87) || !(x <= 6000.0)) {
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 <= (-7.9d-87)) .or. (.not. (x <= 6000.0d0))) 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 <= -7.9e-87) || !(x <= 6000.0)) {
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 <= -7.9e-87) or not (x <= 6000.0): 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 <= -7.9e-87) || !(x <= 6000.0)) 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 <= -7.9e-87) || ~((x <= 6000.0))) 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, -7.9e-87], N[Not[LessEqual[x, 6000.0]], $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 -7.9 \cdot 10^{-87} \lor \neg \left(x \leq 6000\right):\\
\;\;\;\;-2 \cdot \left(t_0 \cdot \sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {t_0}^{2}\\
\end{array}
\end{array}
if x < -7.90000000000000033e-87 or 6e3 < x Initial program 11.1%
diff-cos10.7%
div-inv10.7%
metadata-eval10.7%
div-inv10.7%
+-commutative10.7%
metadata-eval10.7%
Applied egg-rr10.7%
*-commutative10.7%
+-commutative10.7%
associate--l+59.5%
+-inverses59.5%
distribute-lft-in59.5%
metadata-eval59.5%
*-commutative59.5%
associate-+r+59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in eps around 0 54.8%
if -7.90000000000000033e-87 < x < 6e3Initial program 68.8%
diff-cos92.9%
div-inv92.9%
metadata-eval92.9%
div-inv92.9%
+-commutative92.9%
metadata-eval92.9%
Applied egg-rr92.9%
*-commutative92.9%
+-commutative92.9%
associate--l+98.7%
+-inverses98.7%
distribute-lft-in98.7%
metadata-eval98.7%
*-commutative98.7%
associate-+r+98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 92.7%
Final simplification70.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.66e-85) (not (<= x 82000000000000.0))) (* (sin x) (- eps)) (* -2.0 (pow (sin (* 0.5 eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -1.66e-85) || !(x <= 82000000000000.0)) {
tmp = sin(x) * -eps;
} else {
tmp = -2.0 * pow(sin((0.5 * 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 <= (-1.66d-85)) .or. (.not. (x <= 82000000000000.0d0))) then
tmp = sin(x) * -eps
else
tmp = (-2.0d0) * (sin((0.5d0 * eps)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -1.66e-85) || !(x <= 82000000000000.0)) {
tmp = 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 <= -1.66e-85) or not (x <= 82000000000000.0): tmp = 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 <= -1.66e-85) || !(x <= 82000000000000.0)) tmp = Float64(sin(x) * Float64(-eps)); else tmp = Float64(-2.0 * (sin(Float64(0.5 * eps)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.66e-85) || ~((x <= 82000000000000.0))) tmp = sin(x) * -eps; else tmp = -2.0 * (sin((0.5 * eps)) ^ 2.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.66e-85], N[Not[LessEqual[x, 82000000000000.0]], $MachinePrecision]], N[(N[Sin[x], $MachinePrecision] * (-eps)), $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 -1.66 \cdot 10^{-85} \lor \neg \left(x \leq 82000000000000\right):\\
\;\;\;\;\sin x \cdot \left(-\varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot {\sin \left(0.5 \cdot \varepsilon\right)}^{2}\\
\end{array}
\end{array}
if x < -1.66e-85 or 8.2e13 < x Initial program 11.1%
Taylor expanded in eps around 0 52.7%
mul-1-neg52.7%
*-commutative52.7%
distribute-rgt-neg-in52.7%
Simplified52.7%
if -1.66e-85 < x < 8.2e13Initial program 68.3%
diff-cos92.0%
div-inv92.0%
metadata-eval92.0%
div-inv92.0%
+-commutative92.0%
metadata-eval92.0%
Applied egg-rr92.0%
*-commutative92.0%
+-commutative92.0%
associate--l+97.8%
+-inverses97.8%
distribute-lft-in97.8%
metadata-eval97.8%
*-commutative97.8%
associate-+r+97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 91.9%
Final simplification68.9%
(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 -4.4e-153)
t_1
(if (<= eps 2.8e-109) (* eps (- x)) (if (<= eps 0.00105) 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 <= -4.4e-153) {
tmp = t_1;
} else if (eps <= 2.8e-109) {
tmp = eps * -x;
} else if (eps <= 0.00105) {
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 <= (-4.4d-153)) then
tmp = t_1
else if (eps <= 2.8d-109) then
tmp = eps * -x
else if (eps <= 0.00105d0) 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 <= -4.4e-153) {
tmp = t_1;
} else if (eps <= 2.8e-109) {
tmp = eps * -x;
} else if (eps <= 0.00105) {
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 <= -4.4e-153: tmp = t_1 elif eps <= 2.8e-109: tmp = eps * -x elif eps <= 0.00105: 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 <= -4.4e-153) tmp = t_1; elseif (eps <= 2.8e-109) tmp = Float64(eps * Float64(-x)); elseif (eps <= 0.00105) 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 <= -4.4e-153) tmp = t_1; elseif (eps <= 2.8e-109) tmp = eps * -x; elseif (eps <= 0.00105) 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, -4.4e-153], t$95$1, If[LessEqual[eps, 2.8e-109], N[(eps * (-x)), $MachinePrecision], If[LessEqual[eps, 0.00105], 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 -4.4 \cdot 10^{-153}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 2.8 \cdot 10^{-109}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.00105:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if eps < -1.7e-4 or 0.00104999999999999994 < eps Initial program 50.1%
Taylor expanded in x around 0 50.1%
if -1.7e-4 < eps < -4.40000000000000001e-153 or 2.79999999999999979e-109 < eps < 0.00104999999999999994Initial program 5.9%
Taylor expanded in x around 0 5.5%
Taylor expanded in eps around 0 41.4%
*-commutative41.4%
unpow241.4%
Simplified41.4%
if -4.40000000000000001e-153 < eps < 2.79999999999999979e-109Initial program 34.6%
Taylor expanded in eps around 0 96.9%
mul-1-neg96.9%
*-commutative96.9%
distribute-rgt-neg-in96.9%
Simplified96.9%
Taylor expanded in x around 0 46.5%
associate-*r*46.5%
neg-mul-146.5%
Simplified46.5%
Final simplification47.0%
(FPCore (x eps) :precision binary64 (if (<= x -3.8e-114) (* eps (- x)) (* (* eps eps) -0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -3.8e-114) {
tmp = eps * -x;
} else {
tmp = (eps * eps) * -0.5;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-3.8d-114)) then
tmp = eps * -x
else
tmp = (eps * eps) * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.8e-114) {
tmp = eps * -x;
} else {
tmp = (eps * eps) * -0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.8e-114: tmp = eps * -x else: tmp = (eps * eps) * -0.5 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.8e-114) tmp = Float64(eps * Float64(-x)); else tmp = Float64(Float64(eps * eps) * -0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.8e-114) tmp = eps * -x; else tmp = (eps * eps) * -0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.8e-114], N[(eps * (-x)), $MachinePrecision], N[(N[(eps * eps), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-114}:\\
\;\;\;\;\varepsilon \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot -0.5\\
\end{array}
\end{array}
if x < -3.7999999999999998e-114Initial program 19.3%
Taylor expanded in eps around 0 50.2%
mul-1-neg50.2%
*-commutative50.2%
distribute-rgt-neg-in50.2%
Simplified50.2%
Taylor expanded in x around 0 15.6%
associate-*r*15.6%
neg-mul-115.6%
Simplified15.6%
if -3.7999999999999998e-114 < x Initial program 42.9%
Taylor expanded in x around 0 42.4%
Taylor expanded in eps around 0 29.9%
*-commutative29.9%
unpow229.9%
Simplified29.9%
Final simplification25.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 34.8%
Taylor expanded in eps around 0 42.3%
mul-1-neg42.3%
*-commutative42.3%
distribute-rgt-neg-in42.3%
Simplified42.3%
Taylor expanded in x around 0 16.8%
associate-*r*16.8%
neg-mul-116.8%
Simplified16.8%
Final simplification16.8%
herbie shell --seed 2023279
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))