
(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 9 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
(let* ((t_0 (- (* (cos x) (sin eps)) (sin x))))
(if (<= eps -0.00018)
(+ (* (sin x) (cos eps)) t_0)
(if (<= eps 0.00018)
(+
(* -0.5 (* (sin x) (pow eps 2.0)))
(* (cos x) (+ eps (* -0.16666666666666666 (pow eps 3.0)))))
(fma (sin x) (cos eps) t_0)))))
double code(double x, double eps) {
double t_0 = (cos(x) * sin(eps)) - sin(x);
double tmp;
if (eps <= -0.00018) {
tmp = (sin(x) * cos(eps)) + t_0;
} else if (eps <= 0.00018) {
tmp = (-0.5 * (sin(x) * pow(eps, 2.0))) + (cos(x) * (eps + (-0.16666666666666666 * pow(eps, 3.0))));
} else {
tmp = fma(sin(x), cos(eps), t_0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(cos(x) * sin(eps)) - sin(x)) tmp = 0.0 if (eps <= -0.00018) tmp = Float64(Float64(sin(x) * cos(eps)) + t_0); elseif (eps <= 0.00018) tmp = Float64(Float64(-0.5 * Float64(sin(x) * (eps ^ 2.0))) + Float64(cos(x) * Float64(eps + Float64(-0.16666666666666666 * (eps ^ 3.0))))); else tmp = fma(sin(x), cos(eps), t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Cos[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.00018], N[(N[(N[Sin[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[eps, 0.00018], N[(N[(-0.5 * N[(N[Sin[x], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps + N[(-0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \sin \varepsilon - \sin x\\
\mathbf{if}\;\varepsilon \leq -0.00018:\\
\;\;\;\;\sin x \cdot \cos \varepsilon + t_0\\
\mathbf{elif}\;\varepsilon \leq 0.00018:\\
\;\;\;\;-0.5 \cdot \left(\sin x \cdot {\varepsilon}^{2}\right) + \cos x \cdot \left(\varepsilon + -0.16666666666666666 \cdot {\varepsilon}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin x, \cos \varepsilon, t_0\right)\\
\end{array}
\end{array}
if eps < -1.80000000000000011e-4Initial program 53.5%
sin-sum99.6%
associate--l+99.7%
Applied egg-rr99.7%
if -1.80000000000000011e-4 < eps < 1.80000000000000011e-4Initial program 25.7%
Taylor expanded in eps around 0 99.9%
fma-def99.9%
+-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
Simplified99.9%
Taylor expanded in x around inf 99.9%
if 1.80000000000000011e-4 < eps Initial program 47.3%
sin-sum99.1%
associate--l+99.1%
fma-def99.3%
Applied egg-rr99.3%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (sin (+ eps x)) (sin x))))
(if (or (<= t_0 -1e-5) (not (<= t_0 2e-61)))
t_0
(* 2.0 (* (cos x) (sin (* eps 0.5)))))))
double code(double x, double eps) {
double t_0 = sin((eps + x)) - sin(x);
double tmp;
if ((t_0 <= -1e-5) || !(t_0 <= 2e-61)) {
tmp = t_0;
} else {
tmp = 2.0 * (cos(x) * sin((eps * 0.5)));
}
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 <= (-1d-5)) .or. (.not. (t_0 <= 2d-61))) then
tmp = t_0
else
tmp = 2.0d0 * (cos(x) * sin((eps * 0.5d0)))
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 <= -1e-5) || !(t_0 <= 2e-61)) {
tmp = t_0;
} else {
tmp = 2.0 * (Math.cos(x) * Math.sin((eps * 0.5)));
}
return tmp;
}
def code(x, eps): t_0 = math.sin((eps + x)) - math.sin(x) tmp = 0 if (t_0 <= -1e-5) or not (t_0 <= 2e-61): tmp = t_0 else: tmp = 2.0 * (math.cos(x) * math.sin((eps * 0.5))) return tmp
function code(x, eps) t_0 = Float64(sin(Float64(eps + x)) - sin(x)) tmp = 0.0 if ((t_0 <= -1e-5) || !(t_0 <= 2e-61)) tmp = t_0; else tmp = Float64(2.0 * Float64(cos(x) * sin(Float64(eps * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = sin((eps + x)) - sin(x); tmp = 0.0; if ((t_0 <= -1e-5) || ~((t_0 <= 2e-61))) tmp = t_0; else tmp = 2.0 * (cos(x) * sin((eps * 0.5))); 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, -1e-5], N[Not[LessEqual[t$95$0, 2e-61]], $MachinePrecision]], t$95$0, N[(2.0 * N[(N[Cos[x], $MachinePrecision] * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\varepsilon + x\right) - \sin x\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-5} \lor \neg \left(t_0 \leq 2 \cdot 10^{-61}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\cos x \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x)) < -1.00000000000000008e-5 or 2.0000000000000001e-61 < (-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x)) Initial program 68.6%
if -1.00000000000000008e-5 < (-.f64 (sin.f64 (+.f64 x eps)) (sin.f64 x)) < 2.0000000000000001e-61Initial program 20.2%
add-cube-cbrt19.5%
pow319.4%
Applied egg-rr19.4%
rem-cube-cbrt20.2%
diff-sin20.2%
Applied egg-rr20.2%
+-commutative20.2%
associate--l+83.3%
+-commutative83.3%
associate-+l+83.3%
Simplified83.3%
Taylor expanded in x around -inf 83.3%
Taylor expanded in eps around 0 83.3%
Final simplification78.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (cos x) (sin eps))))
(if (<= eps -0.000175)
(+ (* (sin x) (cos eps)) (- t_0 (sin x)))
(if (<= eps 0.000155)
(+
(* -0.5 (* (sin x) (pow eps 2.0)))
(* (cos x) (+ eps (* -0.16666666666666666 (pow eps 3.0)))))
(- (fma (sin x) (cos eps) t_0) (sin x))))))
double code(double x, double eps) {
double t_0 = cos(x) * sin(eps);
double tmp;
if (eps <= -0.000175) {
tmp = (sin(x) * cos(eps)) + (t_0 - sin(x));
} else if (eps <= 0.000155) {
tmp = (-0.5 * (sin(x) * pow(eps, 2.0))) + (cos(x) * (eps + (-0.16666666666666666 * pow(eps, 3.0))));
} else {
tmp = fma(sin(x), cos(eps), t_0) - sin(x);
}
return tmp;
}
function code(x, eps) t_0 = Float64(cos(x) * sin(eps)) tmp = 0.0 if (eps <= -0.000175) tmp = Float64(Float64(sin(x) * cos(eps)) + Float64(t_0 - sin(x))); elseif (eps <= 0.000155) tmp = Float64(Float64(-0.5 * Float64(sin(x) * (eps ^ 2.0))) + Float64(cos(x) * Float64(eps + Float64(-0.16666666666666666 * (eps ^ 3.0))))); else tmp = Float64(fma(sin(x), cos(eps), t_0) - sin(x)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, -0.000175], N[(N[(N[Sin[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 - N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 0.000155], N[(N[(-0.5 * N[(N[Sin[x], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps + N[(-0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision] + t$95$0), $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos x \cdot \sin \varepsilon\\
\mathbf{if}\;\varepsilon \leq -0.000175:\\
\;\;\;\;\sin x \cdot \cos \varepsilon + \left(t_0 - \sin x\right)\\
\mathbf{elif}\;\varepsilon \leq 0.000155:\\
\;\;\;\;-0.5 \cdot \left(\sin x \cdot {\varepsilon}^{2}\right) + \cos x \cdot \left(\varepsilon + -0.16666666666666666 \cdot {\varepsilon}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin x, \cos \varepsilon, t_0\right) - \sin x\\
\end{array}
\end{array}
if eps < -1.74999999999999998e-4Initial program 53.5%
sin-sum99.6%
associate--l+99.7%
Applied egg-rr99.7%
if -1.74999999999999998e-4 < eps < 1.55e-4Initial program 25.7%
Taylor expanded in eps around 0 99.9%
fma-def99.9%
+-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
Simplified99.9%
Taylor expanded in x around inf 99.9%
if 1.55e-4 < eps Initial program 47.3%
sin-sum99.1%
fma-def99.2%
Applied egg-rr99.2%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(if (or (<= eps -0.000165) (not (<= eps 0.000175)))
(+ (* (sin x) (cos eps)) (- (* (cos x) (sin eps)) (sin x)))
(+
(* -0.5 (* (sin x) (pow eps 2.0)))
(* (cos x) (+ eps (* -0.16666666666666666 (pow eps 3.0)))))))
double code(double x, double eps) {
double tmp;
if ((eps <= -0.000165) || !(eps <= 0.000175)) {
tmp = (sin(x) * cos(eps)) + ((cos(x) * sin(eps)) - sin(x));
} else {
tmp = (-0.5 * (sin(x) * pow(eps, 2.0))) + (cos(x) * (eps + (-0.16666666666666666 * pow(eps, 3.0))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((eps <= (-0.000165d0)) .or. (.not. (eps <= 0.000175d0))) then
tmp = (sin(x) * cos(eps)) + ((cos(x) * sin(eps)) - sin(x))
else
tmp = ((-0.5d0) * (sin(x) * (eps ** 2.0d0))) + (cos(x) * (eps + ((-0.16666666666666666d0) * (eps ** 3.0d0))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((eps <= -0.000165) || !(eps <= 0.000175)) {
tmp = (Math.sin(x) * Math.cos(eps)) + ((Math.cos(x) * Math.sin(eps)) - Math.sin(x));
} else {
tmp = (-0.5 * (Math.sin(x) * Math.pow(eps, 2.0))) + (Math.cos(x) * (eps + (-0.16666666666666666 * Math.pow(eps, 3.0))));
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -0.000165) or not (eps <= 0.000175): tmp = (math.sin(x) * math.cos(eps)) + ((math.cos(x) * math.sin(eps)) - math.sin(x)) else: tmp = (-0.5 * (math.sin(x) * math.pow(eps, 2.0))) + (math.cos(x) * (eps + (-0.16666666666666666 * math.pow(eps, 3.0)))) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -0.000165) || !(eps <= 0.000175)) tmp = Float64(Float64(sin(x) * cos(eps)) + Float64(Float64(cos(x) * sin(eps)) - sin(x))); else tmp = Float64(Float64(-0.5 * Float64(sin(x) * (eps ^ 2.0))) + Float64(cos(x) * Float64(eps + Float64(-0.16666666666666666 * (eps ^ 3.0))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -0.000165) || ~((eps <= 0.000175))) tmp = (sin(x) * cos(eps)) + ((cos(x) * sin(eps)) - sin(x)); else tmp = (-0.5 * (sin(x) * (eps ^ 2.0))) + (cos(x) * (eps + (-0.16666666666666666 * (eps ^ 3.0)))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -0.000165], N[Not[LessEqual[eps, 0.000175]], $MachinePrecision]], N[(N[(N[Sin[x], $MachinePrecision] * N[Cos[eps], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision]), $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(N[Sin[x], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[x], $MachinePrecision] * N[(eps + N[(-0.16666666666666666 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -0.000165 \lor \neg \left(\varepsilon \leq 0.000175\right):\\
\;\;\;\;\sin x \cdot \cos \varepsilon + \left(\cos x \cdot \sin \varepsilon - \sin x\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\sin x \cdot {\varepsilon}^{2}\right) + \cos x \cdot \left(\varepsilon + -0.16666666666666666 \cdot {\varepsilon}^{3}\right)\\
\end{array}
\end{array}
if eps < -1.65e-4 or 1.74999999999999998e-4 < eps Initial program 50.5%
sin-sum99.4%
associate--l+99.4%
Applied egg-rr99.4%
if -1.65e-4 < eps < 1.74999999999999998e-4Initial program 25.7%
Taylor expanded in eps around 0 99.9%
fma-def99.9%
+-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
Simplified99.9%
Taylor expanded in x around inf 99.9%
Final simplification99.7%
(FPCore (x eps) :precision binary64 (* 2.0 (* (cos (* 0.5 (- eps (* x -2.0)))) (sin (* eps 0.5)))))
double code(double x, double eps) {
return 2.0 * (cos((0.5 * (eps - (x * -2.0)))) * sin((eps * 0.5)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 2.0d0 * (cos((0.5d0 * (eps - (x * (-2.0d0))))) * sin((eps * 0.5d0)))
end function
public static double code(double x, double eps) {
return 2.0 * (Math.cos((0.5 * (eps - (x * -2.0)))) * Math.sin((eps * 0.5)));
}
def code(x, eps): return 2.0 * (math.cos((0.5 * (eps - (x * -2.0)))) * math.sin((eps * 0.5)))
function code(x, eps) return Float64(2.0 * Float64(cos(Float64(0.5 * Float64(eps - Float64(x * -2.0)))) * sin(Float64(eps * 0.5)))) end
function tmp = code(x, eps) tmp = 2.0 * (cos((0.5 * (eps - (x * -2.0)))) * sin((eps * 0.5))); end
code[x_, eps_] := N[(2.0 * N[(N[Cos[N[(0.5 * N[(eps - N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(eps * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\cos \left(0.5 \cdot \left(\varepsilon - x \cdot -2\right)\right) \cdot \sin \left(\varepsilon \cdot 0.5\right)\right)
\end{array}
Initial program 37.0%
add-cube-cbrt36.1%
pow336.0%
Applied egg-rr36.0%
rem-cube-cbrt37.0%
diff-sin36.7%
Applied egg-rr36.7%
+-commutative36.7%
associate--l+78.1%
+-commutative78.1%
associate-+l+78.1%
Simplified78.1%
Taylor expanded in x around -inf 78.1%
Final simplification78.1%
(FPCore (x eps) :precision binary64 (if (or (<= eps -1.25e-5) (not (<= eps 0.00044))) (sin eps) (* eps (cos x))))
double code(double x, double eps) {
double tmp;
if ((eps <= -1.25e-5) || !(eps <= 0.00044)) {
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 <= (-1.25d-5)) .or. (.not. (eps <= 0.00044d0))) 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 <= -1.25e-5) || !(eps <= 0.00044)) {
tmp = Math.sin(eps);
} else {
tmp = eps * Math.cos(x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (eps <= -1.25e-5) or not (eps <= 0.00044): tmp = math.sin(eps) else: tmp = eps * math.cos(x) return tmp
function code(x, eps) tmp = 0.0 if ((eps <= -1.25e-5) || !(eps <= 0.00044)) tmp = sin(eps); else tmp = Float64(eps * cos(x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= -1.25e-5) || ~((eps <= 0.00044))) tmp = sin(eps); else tmp = eps * cos(x); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[eps, -1.25e-5], N[Not[LessEqual[eps, 0.00044]], $MachinePrecision]], N[Sin[eps], $MachinePrecision], N[(eps * N[Cos[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.25 \cdot 10^{-5} \lor \neg \left(\varepsilon \leq 0.00044\right):\\
\;\;\;\;\sin \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \cos x\\
\end{array}
\end{array}
if eps < -1.25000000000000006e-5 or 4.40000000000000016e-4 < eps Initial program 50.5%
Taylor expanded in x around 0 52.1%
if -1.25000000000000006e-5 < eps < 4.40000000000000016e-4Initial program 25.4%
Taylor expanded in eps around 0 99.5%
Final simplification77.5%
(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.0%
Taylor expanded in x around 0 55.4%
Final simplification55.4%
(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.0%
add-cube-cbrt36.1%
pow336.0%
Applied egg-rr36.0%
Taylor expanded in eps around 0 4.3%
pow-base-14.3%
*-lft-identity4.3%
+-inverses4.3%
Simplified4.3%
Final simplification4.3%
(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.0%
Taylor expanded in eps around 0 15.6%
Taylor expanded in x around 0 32.9%
Final simplification32.9%
(FPCore (x eps) :precision binary64 (fma (cos x) (sin eps) (* (sin x) (- (cos eps) 1.0))))
double code(double x, double eps) {
return fma(cos(x), sin(eps), (sin(x) * (cos(eps) - 1.0)));
}
function code(x, eps) return fma(cos(x), sin(eps), Float64(sin(x) * Float64(cos(eps) - 1.0))) end
code[x_, eps_] := N[(N[Cos[x], $MachinePrecision] * N[Sin[eps], $MachinePrecision] + N[(N[Sin[x], $MachinePrecision] * N[(N[Cos[eps], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos x, \sin \varepsilon, \sin x \cdot \left(\cos \varepsilon - 1\right)\right)
\end{array}
herbie shell --seed 2023330
(FPCore (x eps)
:name "2sin (example 3.3)"
:precision binary64
:herbie-target
(fma (cos x) (sin eps) (* (sin x) (- (cos eps) 1.0)))
(- (sin (+ x eps)) (sin x)))