
(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 14 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 (fma (sin eps) (cos x) (* (sin x) (* (tan (* eps 0.5)) (- (sin eps))))))
double code(double x, double eps) {
return fma(sin(eps), cos(x), (sin(x) * (tan((eps * 0.5)) * -sin(eps))));
}
function code(x, eps) return fma(sin(eps), cos(x), Float64(sin(x) * Float64(tan(Float64(eps * 0.5)) * Float64(-sin(eps))))) end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Tan[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision] * (-N[Sin[eps], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \varepsilon, \cos x, \sin x \cdot \left(\tan \left(\varepsilon \cdot 0.5\right) \cdot \left(-\sin \varepsilon\right)\right)\right)
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (sin (+ eps x))) (t_1 (- t_0 (sin x))))
(if (<= t_1 -0.1)
t_1
(if (<= t_1 5e-135)
(* (cos x) (* 2.0 (sin (* eps 0.5))))
(- (fabs t_0) (sin x))))))
double code(double x, double eps) {
double t_0 = sin((eps + x));
double t_1 = t_0 - sin(x);
double tmp;
if (t_1 <= -0.1) {
tmp = t_1;
} else if (t_1 <= 5e-135) {
tmp = cos(x) * (2.0 * sin((eps * 0.5)));
} else {
tmp = fabs(t_0) - sin(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 = sin((eps + x))
t_1 = t_0 - sin(x)
if (t_1 <= (-0.1d0)) then
tmp = t_1
else if (t_1 <= 5d-135) then
tmp = cos(x) * (2.0d0 * sin((eps * 0.5d0)))
else
tmp = abs(t_0) - sin(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin((eps + x));
double t_1 = t_0 - Math.sin(x);
double tmp;
if (t_1 <= -0.1) {
tmp = t_1;
} else if (t_1 <= 5e-135) {
tmp = Math.cos(x) * (2.0 * Math.sin((eps * 0.5)));
} else {
tmp = Math.abs(t_0) - Math.sin(x);
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps + x)) t_1 = t_0 - math.sin(x) tmp = 0 if t_1 <= -0.1: tmp = t_1 elif t_1 <= 5e-135: tmp = math.cos(x) * (2.0 * math.sin((eps * 0.5))) else: tmp = math.fabs(t_0) - math.sin(x) return tmp
function code(x, eps) t_0 = sin(Float64(eps + x)) t_1 = Float64(t_0 - sin(x)) tmp = 0.0 if (t_1 <= -0.1) tmp = t_1; elseif (t_1 <= 5e-135) tmp = Float64(cos(x) * Float64(2.0 * sin(Float64(eps * 0.5)))); else tmp = Float64(abs(t_0) - sin(x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps + x)); t_1 = t_0 - sin(x); tmp = 0.0; if (t_1 <= -0.1) tmp = t_1; elseif (t_1 <= 5e-135) tmp = cos(x) * (2.0 * sin((eps * 0.5))); else tmp = abs(t_0) - sin(x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Sin[N[(eps + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.1], t$95$1, If[LessEqual[t$95$1, 5e-135], N[(N[Cos[x], $MachinePrecision] * N[(2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[t$95$0], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon + x\right)\\
t_1 := t_0 - \sin x\\
\mathbf{if}\;t_1 \leq -0.1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-135}:\\
\;\;\;\;\cos x \cdot \left(2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|t_0\right| - \sin x\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin (+ eps x)) (sin x))))
(if (<= t_0 -0.1)
t_0
(if (<= t_0 0.0)
(* (cos x) (* 2.0 (sin (* eps 0.5))))
(fabs (sin eps))))))
double code(double x, double eps) {
double t_0 = sin((eps + x)) - sin(x);
double tmp;
if (t_0 <= -0.1) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = cos(x) * (2.0 * sin((eps * 0.5)));
} else {
tmp = fabs(sin(eps));
}
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.1d0)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = cos(x) * (2.0d0 * sin((eps * 0.5d0)))
else
tmp = abs(sin(eps))
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.1) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = Math.cos(x) * (2.0 * Math.sin((eps * 0.5)));
} else {
tmp = Math.abs(Math.sin(eps));
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps + x)) - math.sin(x) tmp = 0 if t_0 <= -0.1: tmp = t_0 elif t_0 <= 0.0: tmp = math.cos(x) * (2.0 * math.sin((eps * 0.5))) else: tmp = math.fabs(math.sin(eps)) return tmp
function code(x, eps) t_0 = Float64(sin(Float64(eps + x)) - sin(x)) tmp = 0.0 if (t_0 <= -0.1) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(cos(x) * Float64(2.0 * sin(Float64(eps * 0.5)))); else tmp = abs(sin(eps)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps + x)) - sin(x); tmp = 0.0; if (t_0 <= -0.1) tmp = t_0; elseif (t_0 <= 0.0) tmp = cos(x) * (2.0 * sin((eps * 0.5))); else tmp = abs(sin(eps)); 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[LessEqual[t$95$0, -0.1], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[Cos[x], $MachinePrecision] * N[(2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[eps], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon + x\right) - \sin x\\
\mathbf{if}\;t_0 \leq -0.1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\cos x \cdot \left(2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \varepsilon\right|\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (let* ((t_0 (- (sin (+ eps x)) (sin x)))) (if (<= t_0 -0.02) t_0 (if (<= t_0 0.0) (* eps (cos x)) (fabs (sin eps))))))
double code(double x, double eps) {
double t_0 = sin((eps + x)) - sin(x);
double tmp;
if (t_0 <= -0.02) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = eps * cos(x);
} else {
tmp = fabs(sin(eps));
}
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.02d0)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = eps * cos(x)
else
tmp = abs(sin(eps))
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.02) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = eps * Math.cos(x);
} else {
tmp = Math.abs(Math.sin(eps));
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps + x)) - math.sin(x) tmp = 0 if t_0 <= -0.02: tmp = t_0 elif t_0 <= 0.0: tmp = eps * math.cos(x) else: tmp = math.fabs(math.sin(eps)) return tmp
function code(x, eps) t_0 = Float64(sin(Float64(eps + x)) - sin(x)) tmp = 0.0 if (t_0 <= -0.02) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(eps * cos(x)); else tmp = abs(sin(eps)); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps + x)) - sin(x); tmp = 0.0; if (t_0 <= -0.02) tmp = t_0; elseif (t_0 <= 0.0) tmp = eps * cos(x); else tmp = abs(sin(eps)); 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[LessEqual[t$95$0, -0.02], t$95$0, If[LessEqual[t$95$0, 0.0], N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision], N[Abs[N[Sin[eps], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon + x\right) - \sin x\\
\mathbf{if}\;t_0 \leq -0.02:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \varepsilon\right|\\
\end{array}
\end{array}
(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}
(FPCore (x eps) :precision binary64 (* (sin eps) (- (cos x) (* (sin x) (tan (* eps 0.5))))))
double code(double x, double eps) {
return sin(eps) * (cos(x) - (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(x) * tan((eps * 0.5d0))))
end function
public static double code(double x, double eps) {
return Math.sin(eps) * (Math.cos(x) - (Math.sin(x) * Math.tan((eps * 0.5))));
}
def code(x, eps): return math.sin(eps) * (math.cos(x) - (math.sin(x) * math.tan((eps * 0.5))))
function code(x, eps) return Float64(sin(eps) * Float64(cos(x) - Float64(sin(x) * tan(Float64(eps * 0.5))))) end
function tmp = code(x, eps) tmp = sin(eps) * (cos(x) - (sin(x) * tan((eps * 0.5)))); end
code[x_, eps_] := N[(N[Sin[eps], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] * N[Tan[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin \varepsilon \cdot \left(\cos x - \sin x \cdot \tan \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00195) (not (<= eps 1.75e-7))) (+ (sin eps) (* (sin x) (+ (cos eps) -1.0))) (+ (* -0.5 (* (sin x) (pow eps 2.0))) (* eps (cos x)))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00195) || !(eps <= 1.75e-7)) {
tmp = sin(eps) + (sin(x) * (cos(eps) + -1.0));
} else {
tmp = (-0.5 * (sin(x) * pow(eps, 2.0))) + (eps * cos(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.00195d0)) .or. (.not. (eps <= 1.75d-7))) then
tmp = sin(eps) + (sin(x) * (cos(eps) + (-1.0d0)))
else
tmp = ((-0.5d0) * (sin(x) * (eps ** 2.0d0))) + (eps * cos(x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00195) || !(eps <= 1.75e-7)) {
tmp = Math.sin(eps) + (Math.sin(x) * (Math.cos(eps) + -1.0));
} else {
tmp = (-0.5 * (Math.sin(x) * Math.pow(eps, 2.0))) + (eps * Math.cos(x));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00195) or not (eps <= 1.75e-7): tmp = math.sin(eps) + (math.sin(x) * (math.cos(eps) + -1.0)) else: tmp = (-0.5 * (math.sin(x) * math.pow(eps, 2.0))) + (eps * math.cos(x)) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00195) || !(eps <= 1.75e-7)) tmp = Float64(sin(eps) + Float64(sin(x) * Float64(cos(eps) + -1.0))); else tmp = Float64(Float64(-0.5 * Float64(sin(x) * (eps ^ 2.0))) + Float64(eps * cos(x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00195) || ~((eps <= 1.75e-7))) tmp = sin(eps) + (sin(x) * (cos(eps) + -1.0)); else tmp = (-0.5 * (sin(x) * (eps ^ 2.0))) + (eps * cos(x)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00195], N[Not[LessEqual[eps, 1.75e-7]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(N[Sin[x], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00195 \lor \neg \left(\varepsilon \leq 1.75 \cdot 10^{-7}\right):\\
\;\;\;\;\sin \varepsilon + \sin x \cdot \left(\cos \varepsilon + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\sin x \cdot {\varepsilon}^{2}\right) + \varepsilon \cdot \cos x\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (sin x) (+ (cos eps) -1.0))))
(if (or (<= eps -0.0008) (not (<= eps 1.75e-7)))
(+ (sin eps) t_0)
(+ (* eps (cos x)) t_0))))
double code(double x, double eps) {
double t_0 = sin(x) * (cos(eps) + -1.0);
double tmp;
if ((eps <= -0.0008) || !(eps <= 1.75e-7)) {
tmp = sin(eps) + t_0;
} else {
tmp = (eps * cos(x)) + t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = sin(x) * (cos(eps) + (-1.0d0))
if ((eps <= (-0.0008d0)) .or. (.not. (eps <= 1.75d-7))) then
tmp = sin(eps) + t_0
else
tmp = (eps * cos(x)) + t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.sin(x) * (Math.cos(eps) + -1.0);
double tmp;
if ((eps <= -0.0008) || !(eps <= 1.75e-7)) {
tmp = Math.sin(eps) + t_0;
} else {
tmp = (eps * Math.cos(x)) + t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.sin(x) * (math.cos(eps) + -1.0) tmp = 0 if (eps <= -0.0008) or not (eps <= 1.75e-7): tmp = math.sin(eps) + t_0 else: tmp = (eps * math.cos(x)) + t_0 return tmp
function code(x, eps) t_0 = Float64(sin(x) * Float64(cos(eps) + -1.0)) tmp = 0.0 if ((eps <= -0.0008) || !(eps <= 1.75e-7)) tmp = Float64(sin(eps) + t_0); else tmp = Float64(Float64(eps * cos(x)) + t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin(x) * (cos(eps) + -1.0); tmp = 0.0; if ((eps <= -0.0008) || ~((eps <= 1.75e-7))) tmp = sin(eps) + t_0; else tmp = (eps * cos(x)) + t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eps, -0.0008], N[Not[LessEqual[eps, 1.75e-7]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin x \cdot \left(\cos \varepsilon + -1\right)\\
\mathbf{if}\;\varepsilon \leq -0.0008 \lor \neg \left(\varepsilon \leq 1.75 \cdot 10^{-7}\right):\\
\;\;\;\;\sin \varepsilon + t_0\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \cos x + t_0\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00047) (not (<= eps 1.75e-7))) (+ (sin eps) (* (sin x) (+ (cos eps) -1.0))) (* eps (cos x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00047) || !(eps <= 1.75e-7)) {
tmp = sin(eps) + (sin(x) * (cos(eps) + -1.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) :: tmp
if ((eps <= (-0.00047d0)) .or. (.not. (eps <= 1.75d-7))) then
tmp = sin(eps) + (sin(x) * (cos(eps) + (-1.0d0)))
else
tmp = eps * cos(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00047) || !(eps <= 1.75e-7)) {
tmp = Math.sin(eps) + (Math.sin(x) * (Math.cos(eps) + -1.0));
} else {
tmp = eps * Math.cos(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00047) or not (eps <= 1.75e-7): tmp = math.sin(eps) + (math.sin(x) * (math.cos(eps) + -1.0)) else: tmp = eps * math.cos(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00047) || !(eps <= 1.75e-7)) tmp = Float64(sin(eps) + Float64(sin(x) * Float64(cos(eps) + -1.0))); else tmp = Float64(eps * cos(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00047) || ~((eps <= 1.75e-7))) tmp = sin(eps) + (sin(x) * (cos(eps) + -1.0)); else tmp = eps * cos(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00047], N[Not[LessEqual[eps, 1.75e-7]], $MachinePrecision]], N[(N[Sin[eps], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00047 \lor \neg \left(\varepsilon \leq 1.75 \cdot 10^{-7}\right):\\
\;\;\;\;\sin \varepsilon + \sin x \cdot \left(\cos \varepsilon + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (* (cos (* 0.5 (fma 2.0 x eps))) (* 2.0 (sin (* eps 0.5)))))
double code(double x, double eps) {
return cos((0.5 * fma(2.0, x, eps))) * (2.0 * sin((eps * 0.5)));
}
function code(x, eps) return Float64(cos(Float64(0.5 * fma(2.0, x, eps))) * Float64(2.0 * sin(Float64(eps * 0.5)))) end
code[x_, eps_] := N[(N[Cos[N[(0.5 * N[(2.0 * x + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(2.0 * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(0.5 \cdot \mathsf{fma}\left(2, x, \varepsilon\right)\right) \cdot \left(2 \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= eps -0.00045) (not (<= eps 1.75e-7))) (sin eps) (* eps (cos x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.00045) || !(eps <= 1.75e-7)) {
tmp = sin(eps);
} 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) :: tmp
if ((eps <= (-0.00045d0)) .or. (.not. (eps <= 1.75d-7))) then
tmp = sin(eps)
else
tmp = eps * cos(x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.00045) || !(eps <= 1.75e-7)) {
tmp = Math.sin(eps);
} else {
tmp = eps * Math.cos(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.00045) or not (eps <= 1.75e-7): tmp = math.sin(eps) else: tmp = eps * math.cos(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.00045) || !(eps <= 1.75e-7)) tmp = sin(eps); else tmp = Float64(eps * cos(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.00045) || ~((eps <= 1.75e-7))) tmp = sin(eps); else tmp = eps * cos(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.00045], N[Not[LessEqual[eps, 1.75e-7]], $MachinePrecision]], N[Sin[eps], $MachinePrecision], N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.00045 \lor \neg \left(\varepsilon \leq 1.75 \cdot 10^{-7}\right):\\
\;\;\;\;\sin \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\end{array}
\end{array}
(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}
(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}
(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}
(FPCore (x eps) :precision binary64 (fma (sin x) (- (cos eps) 1.0) (* (sin eps) (cos x))))
double code(double x, double eps) {
return fma(sin(x), (cos(eps) - 1.0), (sin(eps) * cos(x)));
}
function code(x, eps) return fma(sin(x), Float64(cos(eps) - 1.0), Float64(sin(eps) * cos(x))) end
code[x_, eps_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] - 1.0), $MachinePrecision] + N[(N[Sin[eps], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin x, \cos \varepsilon - 1, \sin \varepsilon \cdot \cos x\right)
\end{array}
herbie shell --seed 2023343
(FPCore (x eps)
:name "2sin (example 3.3)"
:precision binary64
:herbie-target
(fma (sin x) (- (cos eps) 1.0) (* (sin eps) (cos x)))
(- (sin (+ x eps)) (sin x)))