
(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 7 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}
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* x (* s_m c_m))))
(if (<= (pow c_m 2.0) 1e-42)
(/ (/ (cos (* 2.0 x)) t_0) t_0)
(/ 1.0 (* (* (* x s_m) c_m) (* s_m (* x c_m)))))))c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = x * (s_m * c_m);
double tmp;
if (pow(c_m, 2.0) <= 1e-42) {
tmp = (cos((2.0 * x)) / t_0) / t_0;
} else {
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = x * (s_m * c_m)
if ((c_m ** 2.0d0) <= 1d-42) then
tmp = (cos((2.0d0 * x)) / t_0) / t_0
else
tmp = 1.0d0 / (((x * s_m) * c_m) * (s_m * (x * c_m)))
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = x * (s_m * c_m);
double tmp;
if (Math.pow(c_m, 2.0) <= 1e-42) {
tmp = (Math.cos((2.0 * x)) / t_0) / t_0;
} else {
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = x * (s_m * c_m) tmp = 0 if math.pow(c_m, 2.0) <= 1e-42: tmp = (math.cos((2.0 * x)) / t_0) / t_0 else: tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m))) return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(x * Float64(s_m * c_m)) tmp = 0.0 if ((c_m ^ 2.0) <= 1e-42) tmp = Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0); else tmp = Float64(1.0 / Float64(Float64(Float64(x * s_m) * c_m) * Float64(s_m * Float64(x * c_m)))); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = x * (s_m * c_m);
tmp = 0.0;
if ((c_m ^ 2.0) <= 1e-42)
tmp = (cos((2.0 * x)) / t_0) / t_0;
else
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[c$95$m, 2.0], $MachinePrecision], 1e-42], N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(1.0 / N[(N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision] * N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(s_m \cdot c_m\right)\\
\mathbf{if}\;{c_m}^{2} \leq 10^{-42}:\\
\;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot s_m\right) \cdot c_m\right) \cdot \left(s_m \cdot \left(x \cdot c_m\right)\right)}\\
\end{array}
\end{array}
if (pow.f64 c 2) < 1.00000000000000004e-42Initial program 65.4%
add-sqr-sqrt54.0%
add-sqr-sqrt54.0%
times-frac54.0%
sqrt-prod54.0%
unpow254.0%
sqrt-prod31.0%
add-sqr-sqrt33.4%
*-commutative33.4%
associate-*l*31.7%
pow231.7%
sqrt-prod31.7%
Applied egg-rr53.1%
unpow253.1%
unpow253.1%
unpow253.1%
unswap-sqr71.9%
rem-sqrt-square77.7%
Simplified77.7%
Applied egg-rr98.4%
if 1.00000000000000004e-42 < (pow.f64 c 2) Initial program 65.7%
Taylor expanded in x around 0 56.7%
unpow256.7%
rem-square-sqrt56.7%
swap-sqr63.1%
unpow263.1%
unpow263.1%
unpow263.1%
unswap-sqr80.6%
rem-sqrt-square88.4%
Simplified88.4%
pow188.4%
metadata-eval88.4%
sqrt-pow188.4%
pow288.4%
add-sqr-sqrt88.4%
unpow288.4%
add-sqr-sqrt42.1%
fabs-sqr42.1%
add-sqr-sqrt68.6%
associate-*r*68.0%
add-sqr-sqrt35.7%
fabs-sqr35.7%
add-sqr-sqrt84.1%
associate-*r*88.3%
Applied egg-rr88.3%
pow288.3%
associate-*r*88.4%
*-commutative88.4%
associate-*l*92.8%
Applied egg-rr92.8%
unpow292.8%
associate-*r*88.6%
*-commutative88.6%
associate-*l*87.9%
associate-*r*87.7%
*-commutative87.7%
*-commutative87.7%
Applied egg-rr87.7%
*-commutative87.7%
*-commutative87.7%
associate-*l*88.4%
associate-*r*88.6%
*-commutative88.6%
*-commutative88.6%
*-commutative88.6%
Simplified88.6%
Final simplification93.6%
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* x (* s_m c_m))))
(if (<= x 9.5e-115)
(pow (* (* x s_m) c_m) -2.0)
(/ (cos (* 2.0 x)) (* t_0 t_0)))))c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = x * (s_m * c_m);
double tmp;
if (x <= 9.5e-115) {
tmp = pow(((x * s_m) * c_m), -2.0);
} else {
tmp = cos((2.0 * x)) / (t_0 * t_0);
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = x * (s_m * c_m)
if (x <= 9.5d-115) then
tmp = ((x * s_m) * c_m) ** (-2.0d0)
else
tmp = cos((2.0d0 * x)) / (t_0 * t_0)
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = x * (s_m * c_m);
double tmp;
if (x <= 9.5e-115) {
tmp = Math.pow(((x * s_m) * c_m), -2.0);
} else {
tmp = Math.cos((2.0 * x)) / (t_0 * t_0);
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = x * (s_m * c_m) tmp = 0 if x <= 9.5e-115: tmp = math.pow(((x * s_m) * c_m), -2.0) else: tmp = math.cos((2.0 * x)) / (t_0 * t_0) return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(x * Float64(s_m * c_m)) tmp = 0.0 if (x <= 9.5e-115) tmp = Float64(Float64(x * s_m) * c_m) ^ -2.0; else tmp = Float64(cos(Float64(2.0 * x)) / Float64(t_0 * t_0)); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = x * (s_m * c_m);
tmp = 0.0;
if (x <= 9.5e-115)
tmp = ((x * s_m) * c_m) ^ -2.0;
else
tmp = cos((2.0 * x)) / (t_0 * t_0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 9.5e-115], N[Power[N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(s_m \cdot c_m\right)\\
\mathbf{if}\;x \leq 9.5 \cdot 10^{-115}:\\
\;\;\;\;{\left(\left(x \cdot s_m\right) \cdot c_m\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 9.4999999999999996e-115Initial program 65.0%
Taylor expanded in x around 0 52.3%
unpow252.3%
rem-square-sqrt52.3%
swap-sqr58.9%
unpow258.9%
unpow258.9%
unpow258.9%
unswap-sqr79.6%
rem-sqrt-square83.9%
Simplified83.9%
pow183.9%
metadata-eval83.9%
sqrt-pow183.9%
pow283.9%
add-sqr-sqrt83.9%
expm1-log1p-u83.1%
expm1-udef75.6%
pow-flip75.6%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt75.6%
associate-*r*78.2%
metadata-eval78.2%
Applied egg-rr78.2%
expm1-def82.8%
expm1-log1p83.9%
associate-*l*83.9%
Simplified83.9%
if 9.4999999999999996e-115 < x Initial program 66.9%
Taylor expanded in c around 0 62.4%
unpow262.4%
rem-square-sqrt62.4%
swap-sqr66.6%
unpow266.6%
unpow266.6%
unpow266.6%
unswap-sqr82.8%
rem-sqrt-square99.6%
Simplified99.6%
pow177.2%
metadata-eval77.2%
sqrt-pow177.2%
pow277.2%
add-sqr-sqrt77.2%
unpow277.2%
add-sqr-sqrt37.5%
fabs-sqr37.5%
add-sqr-sqrt65.5%
associate-*r*65.1%
add-sqr-sqrt37.2%
fabs-sqr37.2%
add-sqr-sqrt76.9%
associate-*r*76.9%
Applied egg-rr97.5%
Final simplification87.8%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ (/ (/ (cos (* 2.0 x)) (* x s_m)) c_m) (* (* x s_m) c_m)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return ((cos((2.0 * x)) / (x * s_m)) / c_m) / ((x * s_m) * c_m);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = ((cos((2.0d0 * x)) / (x * s_m)) / c_m) / ((x * s_m) * c_m)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return ((Math.cos((2.0 * x)) / (x * s_m)) / c_m) / ((x * s_m) * c_m);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return ((math.cos((2.0 * x)) / (x * s_m)) / c_m) / ((x * s_m) * c_m)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(Float64(cos(Float64(2.0 * x)) / Float64(x * s_m)) / c_m) / Float64(Float64(x * s_m) * c_m)) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = ((cos((2.0 * x)) / (x * s_m)) / c_m) / ((x * s_m) * c_m);
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(x * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{x \cdot s_m}}{c_m}}{\left(x \cdot s_m\right) \cdot c_m}
\end{array}
Initial program 65.6%
Taylor expanded in c around 0 58.2%
unpow258.2%
rem-square-sqrt58.2%
swap-sqr65.1%
unpow265.1%
unpow265.1%
unpow265.1%
unswap-sqr87.3%
rem-sqrt-square96.9%
Simplified96.9%
Taylor expanded in c around 0 76.7%
unpow276.7%
unpow276.7%
sqr-abs76.7%
swap-sqr96.9%
associate-*l*94.3%
associate-*l*96.6%
unpow296.6%
associate-*l*96.9%
Simplified96.9%
div-inv96.9%
associate-*r*96.6%
pow296.6%
associate-/r*96.9%
associate-*r/96.8%
associate-*r*94.5%
*-commutative94.5%
times-frac90.9%
*-commutative90.9%
associate-*r*92.0%
*-commutative92.0%
associate-*l*91.7%
Applied egg-rr91.7%
*-commutative91.7%
associate-/r/95.3%
associate-/l/95.2%
associate-/r*95.3%
associate-/r/95.4%
associate-*l/95.4%
*-lft-identity95.4%
*-commutative95.4%
associate-*r*96.7%
*-commutative96.7%
Simplified96.7%
Final simplification96.7%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (pow (* (* x s_m) c_m) -2.0))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return pow(((x * s_m) * c_m), -2.0);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = ((x * s_m) * c_m) ** (-2.0d0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return Math.pow(((x * s_m) * c_m), -2.0);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return math.pow(((x * s_m) * c_m), -2.0)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(x * s_m) * c_m) ^ -2.0 end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = ((x * s_m) * c_m) ^ -2.0;
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[Power[N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
{\left(\left(x \cdot s_m\right) \cdot c_m\right)}^{-2}
\end{array}
Initial program 65.6%
Taylor expanded in x around 0 54.2%
unpow254.2%
rem-square-sqrt54.2%
swap-sqr60.1%
unpow260.1%
unpow260.1%
unpow260.1%
unswap-sqr77.1%
rem-sqrt-square82.0%
Simplified82.0%
pow182.0%
metadata-eval82.0%
sqrt-pow182.0%
pow282.0%
add-sqr-sqrt82.0%
expm1-log1p-u81.3%
expm1-udef73.5%
pow-flip73.5%
add-sqr-sqrt44.8%
fabs-sqr44.8%
add-sqr-sqrt73.5%
associate-*r*75.3%
metadata-eval75.3%
Applied egg-rr75.3%
expm1-def81.0%
expm1-log1p81.9%
associate-*l*82.0%
Simplified82.0%
Final simplification82.0%
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* x (* s_m c_m))))
(if (<= c_m 2e-46)
(/ 1.0 (* t_0 t_0))
(/ 1.0 (* (* (* x s_m) c_m) (* s_m (* x c_m)))))))c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = x * (s_m * c_m);
double tmp;
if (c_m <= 2e-46) {
tmp = 1.0 / (t_0 * t_0);
} else {
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
}
return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = x * (s_m * c_m)
if (c_m <= 2d-46) then
tmp = 1.0d0 / (t_0 * t_0)
else
tmp = 1.0d0 / (((x * s_m) * c_m) * (s_m * (x * c_m)))
end if
code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = x * (s_m * c_m);
double tmp;
if (c_m <= 2e-46) {
tmp = 1.0 / (t_0 * t_0);
} else {
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
}
return tmp;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = x * (s_m * c_m) tmp = 0 if c_m <= 2e-46: tmp = 1.0 / (t_0 * t_0) else: tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m))) return tmp
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(x * Float64(s_m * c_m)) tmp = 0.0 if (c_m <= 2e-46) tmp = Float64(1.0 / Float64(t_0 * t_0)); else tmp = Float64(1.0 / Float64(Float64(Float64(x * s_m) * c_m) * Float64(s_m * Float64(x * c_m)))); end return tmp end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = x * (s_m * c_m);
tmp = 0.0;
if (c_m <= 2e-46)
tmp = 1.0 / (t_0 * t_0);
else
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c$95$m, 2e-46], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision] * N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(s_m \cdot c_m\right)\\
\mathbf{if}\;c_m \leq 2 \cdot 10^{-46}:\\
\;\;\;\;\frac{1}{t_0 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot s_m\right) \cdot c_m\right) \cdot \left(s_m \cdot \left(x \cdot c_m\right)\right)}\\
\end{array}
\end{array}
if c < 2.00000000000000005e-46Initial program 66.4%
Taylor expanded in x around 0 54.0%
unpow254.0%
rem-square-sqrt54.0%
swap-sqr60.4%
unpow260.4%
unpow260.4%
unpow260.4%
unswap-sqr78.3%
rem-sqrt-square82.2%
Simplified82.2%
pow182.2%
metadata-eval82.2%
sqrt-pow182.2%
pow282.2%
add-sqr-sqrt82.2%
unpow282.2%
add-sqr-sqrt51.8%
fabs-sqr51.8%
add-sqr-sqrt62.4%
associate-*r*61.9%
add-sqr-sqrt46.5%
fabs-sqr46.5%
add-sqr-sqrt80.1%
associate-*r*80.7%
Applied egg-rr80.7%
if 2.00000000000000005e-46 < c Initial program 63.0%
Taylor expanded in x around 0 54.8%
unpow254.8%
rem-square-sqrt54.8%
swap-sqr59.3%
unpow259.3%
unpow259.3%
unpow259.3%
unswap-sqr73.6%
rem-sqrt-square81.4%
Simplified81.4%
pow181.4%
metadata-eval81.4%
sqrt-pow181.4%
pow281.4%
add-sqr-sqrt81.4%
unpow281.4%
add-sqr-sqrt36.9%
fabs-sqr36.9%
add-sqr-sqrt58.6%
associate-*r*58.7%
add-sqr-sqrt27.2%
fabs-sqr27.2%
add-sqr-sqrt78.7%
associate-*r*85.6%
Applied egg-rr85.6%
pow285.6%
associate-*r*81.4%
*-commutative81.4%
associate-*l*88.5%
Applied egg-rr88.5%
unpow288.5%
associate-*r*81.6%
*-commutative81.6%
associate-*l*81.6%
associate-*r*85.7%
*-commutative85.7%
*-commutative85.7%
Applied egg-rr85.7%
*-commutative85.7%
*-commutative85.7%
associate-*l*85.6%
associate-*r*81.6%
*-commutative81.6%
*-commutative81.6%
*-commutative81.6%
Simplified81.6%
Final simplification80.9%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (* (/ 1.0 c_m) (/ 1.0 (* (* x s_m) (* (* x s_m) c_m)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return (1.0 / c_m) * (1.0 / ((x * s_m) * ((x * s_m) * c_m)));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (1.0d0 / c_m) * (1.0d0 / ((x * s_m) * ((x * s_m) * c_m)))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return (1.0 / c_m) * (1.0 / ((x * s_m) * ((x * s_m) * c_m)));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return (1.0 / c_m) * (1.0 / ((x * s_m) * ((x * s_m) * c_m)))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(1.0 / c_m) * Float64(1.0 / Float64(Float64(x * s_m) * Float64(Float64(x * s_m) * c_m)))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = (1.0 / c_m) * (1.0 / ((x * s_m) * ((x * s_m) * c_m)));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[(1.0 / c$95$m), $MachinePrecision] * N[(1.0 / N[(N[(x * s$95$m), $MachinePrecision] * N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{1}{c_m} \cdot \frac{1}{\left(x \cdot s_m\right) \cdot \left(\left(x \cdot s_m\right) \cdot c_m\right)}
\end{array}
Initial program 65.6%
Taylor expanded in x around 0 54.2%
unpow254.2%
rem-square-sqrt54.2%
swap-sqr60.1%
unpow260.1%
unpow260.1%
unpow260.1%
unswap-sqr77.1%
rem-sqrt-square82.0%
Simplified82.0%
pow182.0%
metadata-eval82.0%
sqrt-pow182.0%
pow282.0%
add-sqr-sqrt82.0%
unpow282.0%
add-sqr-sqrt48.1%
fabs-sqr48.1%
add-sqr-sqrt61.5%
associate-*r*61.1%
add-sqr-sqrt41.7%
fabs-sqr41.7%
add-sqr-sqrt79.8%
associate-*r*81.9%
Applied egg-rr81.9%
associate-/r*81.8%
*-un-lft-identity81.8%
associate-*r*79.8%
times-frac78.2%
associate-*r*80.4%
*-commutative80.4%
associate-*l*79.4%
Applied egg-rr79.4%
associate-/l/79.3%
associate-*r*80.4%
*-commutative80.4%
Simplified80.4%
Final simplification80.4%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ 1.0 (* (* (* x s_m) c_m) (* s_m (* x c_m)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 1.0d0 / (((x * s_m) * c_m) * (s_m * (x * c_m)))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(1.0 / Float64(Float64(Float64(x * s_m) * c_m) * Float64(s_m * Float64(x * c_m)))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = 1.0 / (((x * s_m) * c_m) * (s_m * (x * c_m)));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(1.0 / N[(N[(N[(x * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision] * N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{1}{\left(\left(x \cdot s_m\right) \cdot c_m\right) \cdot \left(s_m \cdot \left(x \cdot c_m\right)\right)}
\end{array}
Initial program 65.6%
Taylor expanded in x around 0 54.2%
unpow254.2%
rem-square-sqrt54.2%
swap-sqr60.1%
unpow260.1%
unpow260.1%
unpow260.1%
unswap-sqr77.1%
rem-sqrt-square82.0%
Simplified82.0%
pow182.0%
metadata-eval82.0%
sqrt-pow182.0%
pow282.0%
add-sqr-sqrt82.0%
unpow282.0%
add-sqr-sqrt48.1%
fabs-sqr48.1%
add-sqr-sqrt61.5%
associate-*r*61.1%
add-sqr-sqrt41.7%
fabs-sqr41.7%
add-sqr-sqrt79.8%
associate-*r*81.9%
Applied egg-rr81.9%
pow281.9%
associate-*r*82.0%
*-commutative82.0%
associate-*l*83.1%
Applied egg-rr83.1%
unpow283.1%
associate-*r*81.0%
*-commutative81.0%
associate-*l*79.2%
associate-*r*79.1%
*-commutative79.1%
*-commutative79.1%
Applied egg-rr79.1%
*-commutative79.1%
*-commutative79.1%
associate-*l*80.8%
associate-*r*81.0%
*-commutative81.0%
*-commutative81.0%
*-commutative81.0%
Simplified81.0%
Final simplification81.0%
herbie shell --seed 2024019
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))