
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (let* ((t_0 (* c (* s_m (sqrt x_m))))) (/ (cos (* 2.0 x_m)) (* t_0 (* x_m t_0)))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double t_0 = c * (s_m * sqrt(x_m));
return cos((2.0 * x_m)) / (t_0 * (x_m * t_0));
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (s_m * sqrt(x_m))
code = cos((2.0d0 * x_m)) / (t_0 * (x_m * t_0))
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double t_0 = c * (s_m * Math.sqrt(x_m));
return Math.cos((2.0 * x_m)) / (t_0 * (x_m * t_0));
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): t_0 = c * (s_m * math.sqrt(x_m)) return math.cos((2.0 * x_m)) / (t_0 * (x_m * t_0))
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) t_0 = Float64(c * Float64(s_m * sqrt(x_m))) return Float64(cos(Float64(2.0 * x_m)) / Float64(t_0 * Float64(x_m * t_0))) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
t_0 = c * (s_m * sqrt(x_m));
tmp = cos((2.0 * x_m)) / (t_0 * (x_m * t_0));
end
x_m = N[Abs[x], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(s$95$m * N[Sqrt[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * N[(x$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s_m \cdot \sqrt{x_m}\right)\\
\frac{\cos \left(2 \cdot x_m\right)}{t_0 \cdot \left(x_m \cdot t_0\right)}
\end{array}
\end{array}
Initial program 74.1%
Taylor expanded in c around 0 66.4%
unpow266.4%
rem-square-sqrt66.4%
swap-sqr72.1%
unpow272.1%
unpow272.1%
unpow272.1%
unswap-sqr90.2%
rem-sqrt-square98.3%
Simplified98.3%
pow-prod-down81.6%
*-commutative81.6%
unpow281.6%
add-sqr-sqrt46.8%
fabs-sqr46.8%
add-sqr-sqrt57.1%
*-commutative57.1%
associate-*l*55.6%
add-sqr-sqrt37.4%
fabs-sqr37.4%
add-sqr-sqrt79.3%
associate-*l*74.1%
unpow274.1%
associate-*r*75.2%
*-commutative75.2%
add-sqr-sqrt38.9%
associate-*r*39.0%
Applied egg-rr49.4%
Final simplification49.4%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (if (<= x_m 2.1e-16) (pow (* c (* x_m s_m)) -2.0) (/ (cos (* 2.0 x_m)) (* x_m (* (* c s_m) (* s_m (* x_m c)))))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 2.1e-16) {
tmp = pow((c * (x_m * s_m)), -2.0);
} else {
tmp = cos((2.0 * x_m)) / (x_m * ((c * s_m) * (s_m * (x_m * c))));
}
return tmp;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: tmp
if (x_m <= 2.1d-16) then
tmp = (c * (x_m * s_m)) ** (-2.0d0)
else
tmp = cos((2.0d0 * x_m)) / (x_m * ((c * s_m) * (s_m * (x_m * c))))
end if
code = tmp
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double tmp;
if (x_m <= 2.1e-16) {
tmp = Math.pow((c * (x_m * s_m)), -2.0);
} else {
tmp = Math.cos((2.0 * x_m)) / (x_m * ((c * s_m) * (s_m * (x_m * c))));
}
return tmp;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): tmp = 0 if x_m <= 2.1e-16: tmp = math.pow((c * (x_m * s_m)), -2.0) else: tmp = math.cos((2.0 * x_m)) / (x_m * ((c * s_m) * (s_m * (x_m * c)))) return tmp
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) tmp = 0.0 if (x_m <= 2.1e-16) tmp = Float64(c * Float64(x_m * s_m)) ^ -2.0; else tmp = Float64(cos(Float64(2.0 * x_m)) / Float64(x_m * Float64(Float64(c * s_m) * Float64(s_m * Float64(x_m * c))))); end return tmp end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp_2 = code(x_m, c, s_m)
tmp = 0.0;
if (x_m <= 2.1e-16)
tmp = (c * (x_m * s_m)) ^ -2.0;
else
tmp = cos((2.0 * x_m)) / (x_m * ((c * s_m) * (s_m * (x_m * c))));
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := If[LessEqual[x$95$m, 2.1e-16], N[Power[N[(c * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / N[(x$95$m * N[(N[(c * s$95$m), $MachinePrecision] * N[(s$95$m * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x_m \leq 2.1 \cdot 10^{-16}:\\
\;\;\;\;{\left(c \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x_m\right)}{x_m \cdot \left(\left(c \cdot s_m\right) \cdot \left(s_m \cdot \left(x_m \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 2.1000000000000001e-16Initial program 71.9%
Taylor expanded in x around 0 60.7%
unpow260.7%
rem-square-sqrt60.7%
swap-sqr66.4%
unpow266.4%
unpow266.4%
unpow266.4%
unswap-sqr81.0%
rem-sqrt-square84.5%
Simplified84.5%
expm1-log1p-u83.8%
expm1-udef77.2%
pow-flip77.2%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt77.2%
metadata-eval77.2%
Applied egg-rr77.2%
expm1-def84.0%
expm1-log1p84.7%
Simplified84.7%
if 2.1000000000000001e-16 < x Initial program 79.5%
Taylor expanded in c around 0 75.4%
unpow275.4%
rem-square-sqrt75.4%
swap-sqr80.9%
unpow280.9%
unpow280.9%
unpow280.9%
unswap-sqr88.3%
rem-sqrt-square98.5%
Simplified98.5%
/-rgt-identity98.5%
unpow298.5%
associate-/l*98.5%
add-sqr-sqrt45.8%
fabs-sqr45.8%
add-sqr-sqrt73.6%
add-sqr-sqrt45.8%
fabs-sqr45.8%
add-sqr-sqrt98.5%
Applied egg-rr98.5%
associate-/l*98.5%
associate-*l*96.0%
/-rgt-identity96.0%
associate-*l*98.5%
associate-*r*98.5%
*-commutative98.5%
associate-*l*96.9%
associate-*r*98.1%
*-commutative98.1%
associate-*l*96.9%
Applied egg-rr96.9%
Final simplification88.2%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (let* ((t_0 (* c (* x_m s_m)))) (/ (/ (cos (* 2.0 x_m)) t_0) t_0)))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double t_0 = c * (x_m * s_m);
return (cos((2.0 * x_m)) / t_0) / t_0;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (x_m * s_m)
code = (cos((2.0d0 * x_m)) / t_0) / t_0
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double t_0 = c * (x_m * s_m);
return (Math.cos((2.0 * x_m)) / t_0) / t_0;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): t_0 = c * (x_m * s_m) return (math.cos((2.0 * x_m)) / t_0) / t_0
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) t_0 = Float64(c * Float64(x_m * s_m)) return Float64(Float64(cos(Float64(2.0 * x_m)) / t_0) / t_0) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
t_0 = c * (x_m * s_m);
tmp = (cos((2.0 * x_m)) / t_0) / t_0;
end
x_m = N[Abs[x], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x_m \cdot s_m\right)\\
\frac{\frac{\cos \left(2 \cdot x_m\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 74.1%
cos-274.1%
div-sub42.1%
pow242.1%
*-commutative42.1%
associate-*l*36.4%
pow236.4%
pow236.4%
*-commutative36.4%
associate-*l*36.0%
pow236.0%
Applied egg-rr36.0%
unpow236.0%
rem-square-sqrt36.0%
swap-sqr36.8%
unpow236.8%
unpow236.8%
unpow236.8%
unswap-sqr37.2%
rem-sqrt-square37.4%
unpow237.4%
rem-square-sqrt37.4%
swap-sqr41.0%
unpow241.0%
Simplified62.2%
Applied egg-rr98.6%
Final simplification98.6%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (pow (* c (* x_m s_m)) -2.0))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
return pow((c * (x_m * s_m)), -2.0);
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = (c * (x_m * s_m)) ** (-2.0d0)
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
return Math.pow((c * (x_m * s_m)), -2.0);
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): return math.pow((c * (x_m * s_m)), -2.0)
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) return Float64(c * Float64(x_m * s_m)) ^ -2.0 end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
tmp = (c * (x_m * s_m)) ^ -2.0;
end
x_m = N[Abs[x], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c_, s$95$m_] := N[Power[N[(c * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
{\left(c \cdot \left(x_m \cdot s_m\right)\right)}^{-2}
\end{array}
Initial program 74.1%
Taylor expanded in x around 0 61.2%
unpow261.2%
rem-square-sqrt61.2%
swap-sqr65.8%
unpow265.8%
unpow265.8%
unpow265.8%
unswap-sqr76.5%
rem-sqrt-square79.4%
Simplified79.4%
expm1-log1p-u78.9%
expm1-udef73.7%
pow-flip73.7%
add-sqr-sqrt44.8%
fabs-sqr44.8%
add-sqr-sqrt73.7%
metadata-eval73.7%
Applied egg-rr73.7%
expm1-def79.0%
expm1-log1p79.5%
Simplified79.5%
Final simplification79.5%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (let* ((t_0 (* c (* x_m s_m)))) (/ 1.0 (* t_0 t_0))))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double t_0 = c * (x_m * s_m);
return 1.0 / (t_0 * t_0);
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (x_m * s_m)
code = 1.0d0 / (t_0 * t_0)
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double t_0 = c * (x_m * s_m);
return 1.0 / (t_0 * t_0);
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): t_0 = c * (x_m * s_m) return 1.0 / (t_0 * t_0)
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) t_0 = Float64(c * Float64(x_m * s_m)) return Float64(1.0 / Float64(t_0 * t_0)) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
t_0 = c * (x_m * s_m);
tmp = 1.0 / (t_0 * t_0);
end
x_m = N[Abs[x], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x_m \cdot s_m\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 74.1%
Taylor expanded in x around 0 61.2%
unpow261.2%
rem-square-sqrt61.2%
swap-sqr65.8%
unpow265.8%
unpow265.8%
unpow265.8%
unswap-sqr76.5%
rem-sqrt-square79.4%
Simplified79.4%
unpow279.4%
add-sqr-sqrt46.8%
fabs-sqr46.8%
add-sqr-sqrt59.6%
add-sqr-sqrt37.5%
fabs-sqr37.5%
add-sqr-sqrt79.4%
Applied egg-rr79.4%
Final simplification79.4%
x_m = (fabs.f64 x) s_m = (fabs.f64 s) NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c s_m) :precision binary64 (let* ((t_0 (* c (* x_m s_m)))) (/ (/ 1.0 t_0) t_0)))
x_m = fabs(x);
s_m = fabs(s);
assert(x_m < c && c < s_m);
double code(double x_m, double c, double s_m) {
double t_0 = c * (x_m * s_m);
return (1.0 / t_0) / t_0;
}
x_m = abs(x)
s_m = abs(s)
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c * (x_m * s_m)
code = (1.0d0 / t_0) / t_0
end function
x_m = Math.abs(x);
s_m = Math.abs(s);
assert x_m < c && c < s_m;
public static double code(double x_m, double c, double s_m) {
double t_0 = c * (x_m * s_m);
return (1.0 / t_0) / t_0;
}
x_m = math.fabs(x) s_m = math.fabs(s) [x_m, c, s_m] = sort([x_m, c, s_m]) def code(x_m, c, s_m): t_0 = c * (x_m * s_m) return (1.0 / t_0) / t_0
x_m = abs(x) s_m = abs(s) x_m, c, s_m = sort([x_m, c, s_m]) function code(x_m, c, s_m) t_0 = Float64(c * Float64(x_m * s_m)) return Float64(Float64(1.0 / t_0) / t_0) end
x_m = abs(x);
s_m = abs(s);
x_m, c, s_m = num2cell(sort([x_m, c, s_m])){:}
function tmp = code(x_m, c, s_m)
t_0 = c * (x_m * s_m);
tmp = (1.0 / t_0) / t_0;
end
x_m = N[Abs[x], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c_, s$95$m_] := Block[{t$95$0 = N[(c * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
s_m = \left|s\right|
\\
[x_m, c, s_m] = \mathsf{sort}([x_m, c, s_m])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x_m \cdot s_m\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 74.1%
cos-274.1%
div-sub42.1%
pow242.1%
*-commutative42.1%
associate-*l*36.4%
pow236.4%
pow236.4%
*-commutative36.4%
associate-*l*36.0%
pow236.0%
Applied egg-rr36.0%
unpow236.0%
rem-square-sqrt36.0%
swap-sqr36.8%
unpow236.8%
unpow236.8%
unpow236.8%
unswap-sqr37.2%
rem-sqrt-square37.4%
unpow237.4%
rem-square-sqrt37.4%
swap-sqr41.0%
unpow241.0%
Simplified62.2%
Applied egg-rr98.6%
Taylor expanded in x around 0 79.5%
Final simplification79.5%
herbie shell --seed 2024014
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))