
(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 11 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 eps) (sin x)) (tan (* eps 0.5)))))
double code(double x, double eps) {
return (sin(eps) * cos(x)) - ((sin(eps) * sin(x)) * tan((eps * 0.5)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(eps) * cos(x)) - ((sin(eps) * sin(x)) * tan((eps * 0.5d0)))
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) - ((Math.sin(eps) * Math.sin(x)) * Math.tan((eps * 0.5)));
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) - ((math.sin(eps) * math.sin(x)) * math.tan((eps * 0.5)))
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) - Float64(Float64(sin(eps) * sin(x)) * tan(Float64(eps * 0.5)))) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) - ((sin(eps) * sin(x)) * tan((eps * 0.5))); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[eps], $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] * N[Tan[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x - \left(\sin \varepsilon \cdot \sin x\right) \cdot \tan \left(\varepsilon \cdot 0.5\right)
\end{array}
Initial program 41.1%
sin-sum65.2%
associate--l+65.2%
Applied egg-rr65.2%
+-commutative65.2%
sub-neg65.2%
associate-+l+99.3%
*-commutative99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out99.3%
+-commutative99.3%
Simplified99.3%
flip-+99.0%
metadata-eval99.0%
fma-neg99.3%
metadata-eval99.3%
Applied egg-rr99.3%
fma-udef99.0%
-1-add-cos99.3%
unpow299.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in eps around inf 99.3%
mul-1-neg99.3%
unpow299.3%
+-commutative99.3%
associate-*r/99.2%
distribute-rgt-neg-in99.2%
+-commutative99.2%
hang-0p-tan99.6%
Simplified99.6%
distribute-rgt-neg-out99.6%
distribute-rgt-neg-out99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
associate-*r*99.6%
distribute-rgt-neg-in99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (sin (+ eps x)) (sin x)))) (if (or (<= t_0 -0.05) (not (<= t_0 5e-97))) t_0 (* eps (cos x)))))
double code(double x, double eps) {
double t_0 = sin((eps + x)) - sin(x);
double tmp;
if ((t_0 <= -0.05) || !(t_0 <= 5e-97)) {
tmp = t_0;
} else {
tmp = eps * 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) :: tmp
t_0 = sin((eps + x)) - sin(x)
if ((t_0 <= (-0.05d0)) .or. (.not. (t_0 <= 5d-97))) then
tmp = t_0
else
tmp = eps * cos(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps + x)) - Math.sin(x);
double tmp;
if ((t_0 <= -0.05) || !(t_0 <= 5e-97)) {
tmp = t_0;
} else {
tmp = eps * Math.cos(x);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps + x)) - math.sin(x) tmp = 0 if (t_0 <= -0.05) or not (t_0 <= 5e-97): tmp = t_0 else: tmp = eps * math.cos(x) return tmp
function code(x, eps) t_0 = Float64(sin(Float64(eps + x)) - sin(x)) tmp = 0.0 if ((t_0 <= -0.05) || !(t_0 <= 5e-97)) tmp = t_0; else tmp = Float64(eps * cos(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps + x)) - sin(x); tmp = 0.0; if ((t_0 <= -0.05) || ~((t_0 <= 5e-97))) tmp = t_0; else tmp = eps * cos(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[N[(eps + x), $MachinePrecision]], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.05], N[Not[LessEqual[t$95$0, 5e-97]], $MachinePrecision]], t$95$0, N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon + x\right) - \sin x\\
\mathbf{if}\;t_0 \leq -0.05 \lor \neg \left(t_0 \leq 5 \cdot 10^{-97}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\end{array}
\end{array}
if (-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x)) < -0.050000000000000003 or 4.9999999999999995e-97 < (-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x)) Initial program 71.9%
if -0.050000000000000003 < (-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x)) < 4.9999999999999995e-97Initial program 19.7%
Taylor expanded in eps around 0 78.5%
Final simplification75.8%
(FPCore (x eps) :precision binary64 (- (* (sin eps) (cos x)) (* (sin eps) (* (sin x) (tan (* eps 0.5))))))
double code(double x, double eps) {
return (sin(eps) * cos(x)) - (sin(eps) * (sin(x) * tan((eps * 0.5))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(eps) * cos(x)) - (sin(eps) * (sin(x) * tan((eps * 0.5d0))))
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) - (Math.sin(eps) * (Math.sin(x) * Math.tan((eps * 0.5))));
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) - (math.sin(eps) * (math.sin(x) * math.tan((eps * 0.5))))
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) - Float64(sin(eps) * Float64(sin(x) * tan(Float64(eps * 0.5))))) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) - (sin(eps) * (sin(x) * tan((eps * 0.5)))); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[eps], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * N[Tan[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x - \sin \varepsilon \cdot \left(\sin x \cdot \tan \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 41.1%
sin-sum65.2%
associate--l+65.2%
Applied egg-rr65.2%
+-commutative65.2%
sub-neg65.2%
associate-+l+99.3%
*-commutative99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out99.3%
+-commutative99.3%
Simplified99.3%
flip-+99.0%
metadata-eval99.0%
fma-neg99.3%
metadata-eval99.3%
Applied egg-rr99.3%
fma-udef99.0%
-1-add-cos99.3%
unpow299.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in eps around inf 99.3%
mul-1-neg99.3%
unpow299.3%
+-commutative99.3%
associate-*r/99.2%
distribute-rgt-neg-in99.2%
+-commutative99.2%
hang-0p-tan99.6%
Simplified99.6%
*-commutative99.6%
add-sqr-sqrt51.7%
sqrt-unprod87.4%
sqr-neg87.4%
sqrt-unprod35.6%
add-sqr-sqrt75.1%
cancel-sign-sub75.1%
distribute-rgt-neg-out75.1%
*-commutative75.1%
Applied egg-rr99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (- (* (sin eps) (cos x)) (* (sin x) (* (sin eps) (tan (/ eps 2.0))))))
double code(double x, double eps) {
return (sin(eps) * cos(x)) - (sin(x) * (sin(eps) * tan((eps / 2.0))));
}
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) * tan((eps / 2.0d0))))
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) - (Math.sin(x) * (Math.sin(eps) * Math.tan((eps / 2.0))));
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) - (math.sin(x) * (math.sin(eps) * math.tan((eps / 2.0))))
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) - Float64(sin(x) * Float64(sin(eps) * tan(Float64(eps / 2.0))))) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) - (sin(x) * (sin(eps) * tan((eps / 2.0)))); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[(N[Sin[eps], $MachinePrecision] * N[Tan[N[(eps / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x - \sin x \cdot \left(\sin \varepsilon \cdot \tan \left(\frac{\varepsilon}{2}\right)\right)
\end{array}
Initial program 41.1%
sin-sum65.2%
associate--l+65.2%
Applied egg-rr65.2%
+-commutative65.2%
sub-neg65.2%
associate-+l+99.3%
*-commutative99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out99.3%
+-commutative99.3%
Simplified99.3%
flip-+99.0%
metadata-eval99.0%
fma-neg99.3%
metadata-eval99.3%
Applied egg-rr99.3%
fma-udef99.0%
-1-add-cos99.3%
unpow299.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in eps around inf 99.3%
mul-1-neg99.3%
unpow299.3%
+-commutative99.3%
associate-*r/99.2%
distribute-rgt-neg-in99.2%
+-commutative99.2%
hang-0p-tan99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (fma (sin eps) (cos x) (* (sin x) (+ (cos eps) -1.0))))
double code(double x, double eps) {
return fma(sin(eps), cos(x), (sin(x) * (cos(eps) + -1.0)));
}
function code(x, eps) return fma(sin(eps), cos(x), Float64(sin(x) * Float64(cos(eps) + -1.0))) end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \varepsilon, \cos x, \sin x \cdot \left(\cos \varepsilon + -1\right)\right)
\end{array}
Initial program 41.1%
sin-sum65.2%
associate--l+65.2%
Applied egg-rr65.2%
+-commutative65.2%
sub-neg65.2%
associate-+l+99.3%
*-commutative99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out99.3%
+-commutative99.3%
Simplified99.3%
fma-def99.3%
*-commutative99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (+ (* (sin eps) (cos x)) (* (sin x) (+ (cos eps) -1.0))))
double code(double x, double eps) {
return (sin(eps) * cos(x)) + (sin(x) * (cos(eps) + -1.0));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (sin(eps) * cos(x)) + (sin(x) * (cos(eps) + (-1.0d0)))
end function
public static double code(double x, double eps) {
return (Math.sin(eps) * Math.cos(x)) + (Math.sin(x) * (Math.cos(eps) + -1.0));
}
def code(x, eps): return (math.sin(eps) * math.cos(x)) + (math.sin(x) * (math.cos(eps) + -1.0))
function code(x, eps) return Float64(Float64(sin(eps) * cos(x)) + Float64(sin(x) * Float64(cos(eps) + -1.0))) end
function tmp = code(x, eps) tmp = (sin(eps) * cos(x)) + (sin(x) * (cos(eps) + -1.0)); end
code[x_, eps_] := N[(N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \cos x + \sin x \cdot \left(\cos \varepsilon + -1\right)
\end{array}
Initial program 41.1%
sin-sum65.2%
associate--l+65.2%
Applied egg-rr65.2%
+-commutative65.2%
sub-neg65.2%
associate-+l+99.3%
*-commutative99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out99.3%
+-commutative99.3%
Simplified99.3%
Final simplification99.3%
(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 41.1%
diff-sin40.2%
div-inv40.2%
metadata-eval40.2%
div-inv40.2%
+-commutative40.2%
metadata-eval40.2%
Applied egg-rr40.2%
*-commutative40.2%
+-commutative40.2%
associate--l+75.8%
+-inverses75.8%
distribute-lft-in75.8%
metadata-eval75.8%
*-commutative75.8%
associate-+r+75.8%
+-commutative75.8%
Simplified75.8%
Final simplification75.8%
(FPCore (x eps) :precision binary64 (if (<= eps -1.1e-5) (sin eps) (if (<= eps 0.000125) (* eps (cos x)) (sin eps))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.1e-5) {
tmp = sin(eps);
} else if (eps <= 0.000125) {
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 <= (-1.1d-5)) then
tmp = sin(eps)
else if (eps <= 0.000125d0) 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 <= -1.1e-5) {
tmp = Math.sin(eps);
} else if (eps <= 0.000125) {
tmp = eps * Math.cos(x);
} else {
tmp = Math.sin(eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= -1.1e-5: tmp = math.sin(eps) elif eps <= 0.000125: tmp = eps * math.cos(x) else: tmp = math.sin(eps) return tmp
function code(x, eps) tmp = 0.0 if (eps <= -1.1e-5) tmp = sin(eps); elseif (eps <= 0.000125) tmp = Float64(eps * cos(x)); else tmp = sin(eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= -1.1e-5) tmp = sin(eps); elseif (eps <= 0.000125) tmp = eps * cos(x); else tmp = sin(eps); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, -1.1e-5], N[Sin[eps], $MachinePrecision], If[LessEqual[eps, 0.000125], N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision], N[Sin[eps], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.1 \cdot 10^{-5}:\\
\;\;\;\;\sin \varepsilon\\
\mathbf{elif}\;\varepsilon \leq 0.000125:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\mathbf{else}:\\
\;\;\;\;\sin \varepsilon\\
\end{array}
\end{array}
if eps < -1.1e-5 or 1.25e-4 < eps Initial program 54.2%
Taylor expanded in x around 0 54.2%
if -1.1e-5 < eps < 1.25e-4Initial program 27.2%
Taylor expanded in eps around 0 98.6%
Final simplification75.7%
(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 41.1%
Taylor expanded in x around 0 54.6%
Final simplification54.6%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 41.1%
add-cube-cbrt40.3%
pow340.3%
Applied egg-rr40.3%
Taylor expanded in eps around 0 4.4%
pow-base-14.4%
*-lft-identity4.4%
+-inverses4.4%
Simplified4.4%
Final simplification4.4%
(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 41.1%
Taylor expanded in eps around 0 49.4%
Taylor expanded in x around 0 28.3%
Final simplification28.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 2023242
(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)))