
(FPCore (x eps) :precision binary64 (- (sin (+ x eps)) (sin x)))
double code(double x, double eps) {
return sin((x + eps)) - sin(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin((x + eps)) - sin(x)
end function
public static double code(double x, double eps) {
return Math.sin((x + eps)) - Math.sin(x);
}
def code(x, eps): return math.sin((x + eps)) - math.sin(x)
function code(x, eps) return Float64(sin(Float64(x + eps)) - sin(x)) end
function tmp = code(x, eps) tmp = sin((x + eps)) - sin(x); end
code[x_, eps_] := N[(N[Sin[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(x + \varepsilon\right) - \sin x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (sin (+ x eps)) (sin x)))
double code(double x, double eps) {
return sin((x + eps)) - sin(x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin((x + eps)) - sin(x)
end function
public static double code(double x, double eps) {
return Math.sin((x + eps)) - Math.sin(x);
}
def code(x, eps): return math.sin((x + eps)) - math.sin(x)
function code(x, eps) return Float64(sin(Float64(x + eps)) - sin(x)) end
function tmp = code(x, eps) tmp = sin((x + eps)) - sin(x); end
code[x_, eps_] := N[(N[Sin[N[(x + eps), $MachinePrecision]], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \left(x + \varepsilon\right) - \sin x
\end{array}
(FPCore (x eps) :precision binary64 (+ (* (sin eps) (cos x)) (* (sin x) (/ (pow (sin eps) 2.0) (- -1.0 (cos eps))))))
double code(double x, double eps) {
return (sin(eps) * cos(x)) + (sin(x) * (pow(sin(eps), 2.0) / (-1.0 - cos(eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(eps) * cos(x)) + (sin(x) * ((sin(eps) ** 2.0d0) / ((-1.0d0) - cos(eps))))
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) + (Math.sin(x) * (Math.pow(Math.sin(eps), 2.0) / (-1.0 - Math.cos(eps))));
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) + (math.sin(x) * (math.pow(math.sin(eps), 2.0) / (-1.0 - math.cos(eps))))
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) + Float64(sin(x) * Float64((sin(eps) ^ 2.0) / Float64(-1.0 - cos(eps))))) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) + (sin(x) * ((sin(eps) ^ 2.0) / (-1.0 - cos(eps)))); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Power[N[Sin[eps], $MachinePrecision], 2.0], $MachinePrecision] / N[(-1.0 - N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x + \sin x \cdot \frac{{\sin \varepsilon}^{2}}{-1 - \cos \varepsilon}
\end{array}
Initial program 37.7%
sin-sum63.5%
associate--l+63.5%
Applied egg-rr63.5%
+-commutative63.5%
sub-neg63.5%
associate-+l+99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-out99.4%
+-commutative99.4%
Simplified99.4%
flip-+99.3%
frac-2neg99.3%
metadata-eval99.3%
sub-1-cos99.5%
pow299.5%
sub-neg99.5%
metadata-eval99.5%
Applied egg-rr99.5%
remove-double-neg99.5%
+-commutative99.5%
distribute-neg-in99.5%
metadata-eval99.5%
sub-neg99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (fma (sin eps) (cos x) (* (sin x) (+ -1.0 (cos eps)))))
double code(double x, double eps) {
return fma(sin(eps), cos(x), (sin(x) * (-1.0 + cos(eps))));
}
function code(x, eps) return fma(sin(eps), cos(x), Float64(sin(x) * Float64(-1.0 + cos(eps)))) end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \varepsilon, \cos x, \sin x \cdot \left(-1 + \cos \varepsilon\right)\right)
\end{array}
Initial program 37.7%
sin-sum63.5%
associate--l+63.5%
Applied egg-rr63.5%
+-commutative63.5%
sub-neg63.5%
associate-+l+99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-out99.4%
+-commutative99.4%
Simplified99.4%
fma-def99.4%
*-commutative99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (fma (+ -1.0 (cos eps)) (sin x) (* (sin eps) (cos x))))
double code(double x, double eps) {
return fma((-1.0 + cos(eps)), sin(x), (sin(eps) * cos(x)));
}
function code(x, eps) return fma(Float64(-1.0 + cos(eps)), sin(x), Float64(sin(eps) * cos(x))) end
code[x_, eps_] := N[(N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision] * N[Sin[x], $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + \cos \varepsilon, \sin x, \sin \varepsilon \cdot \cos x\right)
\end{array}
Initial program 37.7%
sin-sum63.5%
associate--l+63.5%
Applied egg-rr63.5%
+-commutative63.5%
sub-neg63.5%
associate-+l+99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-out99.4%
+-commutative99.4%
Simplified99.4%
+-commutative99.4%
*-commutative99.4%
fma-def99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (+ (* (sin eps) (cos x)) (* (sin x) (+ -1.0 (cos eps)))))
double code(double x, double eps) {
return (sin(eps) * cos(x)) + (sin(x) * (-1.0 + cos(eps)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(eps) * cos(x)) + (sin(x) * ((-1.0d0) + cos(eps)))
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) + (Math.sin(x) * (-1.0 + Math.cos(eps)));
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) + (math.sin(x) * (-1.0 + math.cos(eps)))
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) + Float64(sin(x) * Float64(-1.0 + cos(eps)))) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) + (sin(x) * (-1.0 + cos(eps))); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(-1.0 + N[Cos[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x + \sin x \cdot \left(-1 + \cos \varepsilon\right)
\end{array}
Initial program 37.7%
sin-sum63.5%
associate--l+63.5%
Applied egg-rr63.5%
+-commutative63.5%
sub-neg63.5%
associate-+l+99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-out99.4%
+-commutative99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (+ (* (sin eps) (cos x)) (* (sin x) 0.0)))
double code(double x, double eps) {
return (sin(eps) * cos(x)) + (sin(x) * 0.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(eps) * cos(x)) + (sin(x) * 0.0d0)
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) + (Math.sin(x) * 0.0);
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) + (math.sin(x) * 0.0)
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) + Float64(sin(x) * 0.0)) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) + (sin(x) * 0.0); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x + \sin x \cdot 0
\end{array}
Initial program 37.7%
sin-sum63.5%
associate--l+63.5%
Applied egg-rr63.5%
+-commutative63.5%
sub-neg63.5%
associate-+l+99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-out99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in eps around 0 76.1%
Final simplification76.1%
(FPCore (x eps)
:precision binary64
(if (<= eps -0.043)
(sin eps)
(if (<= eps 2e-30)
(+ (* (* (sin x) (* eps eps)) -0.5) (* eps (cos x)))
(sin eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.043) {
tmp = sin(eps);
} else if (eps <= 2e-30) {
tmp = ((sin(x) * (eps * eps)) * -0.5) + (eps * cos(x));
} else {
tmp = sin(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.043d0)) then
tmp = sin(eps)
else if (eps <= 2d-30) then
tmp = ((sin(x) * (eps * eps)) * (-0.5d0)) + (eps * cos(x))
else
tmp = sin(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.043) {
tmp = Math.sin(eps);
} else if (eps <= 2e-30) {
tmp = ((Math.sin(x) * (eps * eps)) * -0.5) + (eps * Math.cos(x));
} else {
tmp = Math.sin(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.043: tmp = math.sin(eps) elif eps <= 2e-30: tmp = ((math.sin(x) * (eps * eps)) * -0.5) + (eps * math.cos(x)) else: tmp = math.sin(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.043) tmp = sin(eps); elseif (eps <= 2e-30) tmp = Float64(Float64(Float64(sin(x) * Float64(eps * eps)) * -0.5) + Float64(eps * cos(x))); else tmp = sin(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.043) tmp = sin(eps); elseif (eps <= 2e-30) tmp = ((sin(x) * (eps * eps)) * -0.5) + (eps * cos(x)); else tmp = sin(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.043], N[Sin[eps], $MachinePrecision], If[LessEqual[eps, 2e-30], N[(N[(N[(N[Sin[x], $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] + N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.043:\\
\;\;\;\;\sin \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 2 \cdot 10^{-30}:\\
\;\;\;\;\left(\sin x \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot -0.5 + \varepsilon \cdot \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin \varepsilon\\
\end{array}
\end{array}
if eps < -0.042999999999999997 or 2e-30 < eps Initial program 51.0%
Taylor expanded in x around 0 52.6%
if -0.042999999999999997 < eps < 2e-30Initial program 23.4%
Taylor expanded in eps around 0 99.3%
+-commutative99.3%
fma-def99.3%
unpow299.3%
associate-*l*99.3%
*-commutative99.3%
Simplified99.3%
fma-udef99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
Applied egg-rr99.3%
Final simplification75.1%
(FPCore (x eps) :precision binary64 (* 2.0 (* (sin (* eps 0.5)) (cos (* 0.5 (+ eps (+ x x)))))))
double code(double x, double eps) {
return 2.0 * (sin((eps * 0.5)) * cos((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((eps * 0.5d0)) * cos((0.5d0 * (eps + (x + x)))))
end function
public static double code(double x, double eps) {
return 2.0 * (Math.sin((eps * 0.5)) * Math.cos((0.5 * (eps + (x + x)))));
}
def code(x, eps): return 2.0 * (math.sin((eps * 0.5)) * math.cos((0.5 * (eps + (x + x)))))
function code(x, eps) return Float64(2.0 * Float64(sin(Float64(eps * 0.5)) * cos(Float64(0.5 * Float64(eps + Float64(x + x)))))) end
function tmp = code(x, eps) tmp = 2.0 * (sin((eps * 0.5)) * cos((0.5 * (eps + (x + x))))); end
code[x_, eps_] := N[(2.0 * N[(N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * N[(eps + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\sin \left(\varepsilon \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \left(\varepsilon + \left(x + x\right)\right)\right)\right)
\end{array}
Initial program 37.7%
diff-sin37.6%
div-inv37.6%
metadata-eval37.6%
div-inv37.6%
+-commutative37.6%
metadata-eval37.6%
Applied egg-rr37.6%
*-commutative37.6%
+-commutative37.6%
associate--l+74.5%
+-inverses74.5%
distribute-lft-in74.5%
metadata-eval74.5%
*-commutative74.5%
associate-+r+74.5%
+-commutative74.5%
Simplified74.5%
Final simplification74.5%
(FPCore (x eps) :precision binary64 (* (cos (/ (+ x (+ eps x)) 2.0)) (* 2.0 (sin (/ eps 2.0)))))
double code(double x, double eps) {
return cos(((x + (eps + x)) / 2.0)) * (2.0 * sin((eps / 2.0)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = cos(((x + (eps + x)) / 2.0d0)) * (2.0d0 * sin((eps / 2.0d0)))
end function
public static double code(double x, double eps) {
return Math.cos(((x + (eps + x)) / 2.0)) * (2.0 * Math.sin((eps / 2.0)));
}
def code(x, eps): return math.cos(((x + (eps + x)) / 2.0)) * (2.0 * math.sin((eps / 2.0)))
function code(x, eps) return Float64(cos(Float64(Float64(x + Float64(eps + x)) / 2.0)) * Float64(2.0 * sin(Float64(eps / 2.0)))) end
function tmp = code(x, eps) tmp = cos(((x + (eps + x)) / 2.0)) * (2.0 * sin((eps / 2.0))); end
code[x_, eps_] := N[(N[Cos[N[(N[(x + N[(eps + x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(2.0 * N[Sin[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{x + \left(\varepsilon + x\right)}{2}\right) \cdot \left(2 \cdot \sin \left(\frac{\varepsilon}{2}\right)\right)
\end{array}
Initial program 37.7%
sin-sum63.5%
associate--l+63.5%
Applied egg-rr63.5%
+-commutative63.5%
sub-neg63.5%
associate-+l+99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-out99.4%
+-commutative99.4%
Simplified99.4%
+-commutative99.4%
*-commutative99.4%
fma-def99.4%
Applied egg-rr99.4%
fma-udef99.4%
*-commutative99.4%
+-commutative99.4%
distribute-rgt-in99.4%
neg-mul-199.4%
associate-+r+63.5%
sin-sum37.7%
+-commutative37.7%
add-cube-cbrt36.7%
fma-def36.7%
fma-neg36.7%
add-cube-cbrt37.7%
diff-sin37.6%
Applied egg-rr37.6%
associate-*r*37.6%
*-commutative37.6%
+-commutative37.6%
+-commutative37.6%
associate--l+74.5%
+-inverses74.5%
Simplified74.5%
Final simplification74.5%
(FPCore (x eps) :precision binary64 (if (<= eps -0.043) (sin eps) (if (<= eps 2e-30) (* eps (cos x)) (sin eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -0.043) {
tmp = sin(eps);
} else if (eps <= 2e-30) {
tmp = eps * cos(x);
} else {
tmp = sin(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.043d0)) then
tmp = sin(eps)
else if (eps <= 2d-30) then
tmp = eps * cos(x)
else
tmp = sin(eps)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= -0.043) {
tmp = Math.sin(eps);
} else if (eps <= 2e-30) {
tmp = eps * Math.cos(x);
} else {
tmp = Math.sin(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -0.043: tmp = math.sin(eps) elif eps <= 2e-30: tmp = eps * math.cos(x) else: tmp = math.sin(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -0.043) tmp = sin(eps); elseif (eps <= 2e-30) tmp = Float64(eps * cos(x)); else tmp = sin(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -0.043) tmp = sin(eps); elseif (eps <= 2e-30) tmp = eps * cos(x); else tmp = sin(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -0.043], N[Sin[eps], $MachinePrecision], If[LessEqual[eps, 2e-30], N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision], N[Sin[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.043:\\
\;\;\;\;\sin \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 2 \cdot 10^{-30}:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin \varepsilon\\
\end{array}
\end{array}
if eps < -0.042999999999999997 or 2e-30 < eps Initial program 51.0%
Taylor expanded in x around 0 52.6%
if -0.042999999999999997 < eps < 2e-30Initial program 23.4%
Taylor expanded in eps around 0 99.0%
Final simplification74.9%
(FPCore (x eps) :precision binary64 (sin eps))
double code(double x, double eps) {
return sin(eps);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = sin(eps)
end function
public static double code(double x, double eps) {
return Math.sin(eps);
}
def code(x, eps): return math.sin(eps)
function code(x, eps) return sin(eps) end
function tmp = code(x, eps) tmp = sin(eps); end
code[x_, eps_] := N[Sin[eps], $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon
\end{array}
Initial program 37.7%
Taylor expanded in x around 0 51.5%
Final simplification51.5%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 37.7%
add-cube-cbrt36.7%
pow336.6%
Applied egg-rr36.6%
Taylor expanded in eps around 0 4.2%
pow-base-14.2%
*-lft-identity4.2%
+-inverses4.2%
Simplified4.2%
Final simplification4.2%
(FPCore (x eps) :precision binary64 eps)
double code(double x, double eps) {
return eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps
end function
public static double code(double x, double eps) {
return eps;
}
def code(x, eps): return eps
function code(x, eps) return eps end
function tmp = code(x, eps) tmp = eps; end
code[x_, eps_] := eps
\begin{array}{l}
\\
\varepsilon
\end{array}
Initial program 37.7%
Taylor expanded in eps around 0 50.8%
Taylor expanded in x around 0 27.3%
Final simplification27.3%
(FPCore (x eps) :precision binary64 (* 2.0 (* (cos (+ x (/ eps 2.0))) (sin (/ eps 2.0)))))
double code(double x, double eps) {
return 2.0 * (cos((x + (eps / 2.0))) * sin((eps / 2.0)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 2.0d0 * (cos((x + (eps / 2.0d0))) * sin((eps / 2.0d0)))
end function
public static double code(double x, double eps) {
return 2.0 * (Math.cos((x + (eps / 2.0))) * Math.sin((eps / 2.0)));
}
def code(x, eps): return 2.0 * (math.cos((x + (eps / 2.0))) * math.sin((eps / 2.0)))
function code(x, eps) return Float64(2.0 * Float64(cos(Float64(x + Float64(eps / 2.0))) * sin(Float64(eps / 2.0)))) end
function tmp = code(x, eps) tmp = 2.0 * (cos((x + (eps / 2.0))) * sin((eps / 2.0))); end
code[x_, eps_] := N[(2.0 * N[(N[Cos[N[(x + N[(eps / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\cos \left(x + \frac{\varepsilon}{2}\right) \cdot \sin \left(\frac{\varepsilon}{2}\right)\right)
\end{array}
herbie shell --seed 2023178
(FPCore (x eps)
:name "2sin (example 3.3)"
:precision binary64
:herbie-target
(* 2.0 (* (cos (+ x (/ eps 2.0))) (sin (/ eps 2.0))))
(- (sin (+ x eps)) (sin x)))