The exact analytic soultion
1. Introduction
The problem was still intriguing me with the result of a further study which I present in the following, for clarity as another solution.
I have chosen to write the formulas in the more theoretical text in traditonal form.
Abstract
We calculate here the explcit analytic solution for the integral
$f(k,R)=\int _R^1r^a |\cos (\pi r k)|dr$
with $a=0$ or $a=\frac{1}{2}$, respectively, and $0\leq R<1$.
This covers the two integrals in the orginal formulation of the problem.
The results for $R=0$ are
$f(k, a=0)=\frac{2 \left\lfloor k+\frac{1}{2}\right\rfloor +(-1)^{\left\lfloor k+\frac{1}{2}\right\rfloor } \sin (\pi k)}{\pi k}$
$f(k, a=1/2)=\frac{\sum _{m=1}^{\left\lfloor k+\frac{1}{2}\right\rfloor } \left(\sqrt{2} (-1)^m S\left(\sqrt{2 m-1}\right)+\sqrt{4 m-2}\right)+(-1)^{\left\lfloor k+\frac{1}{2}\right\rfloor } \left(\sqrt{k} \sin (\pi k)-\frac{S\left(\sqrt{2} \sqrt{k}\right)}{\sqrt{2}}\right)}{\pi k^{3/2}}$
Here $S()$ is the function FresnelS
.
The results for $0\leq R<1$ can be expressed as
$f(k,R)=f(k)-\left(\frac{R}{k}\right)^{a+1} f(k R)$
2. Main part
Changing the integration variable to $t\to \pi k r$ leads to
$f(k)=\frac{g(k)}{(\pi k)^{a+1}}$
where
$g(k)=\int _{0}^{\pi k}t^a |\cos (t)|dt$
This can be made more explicit by considering the intervals of k where cos > 0 and cos < 0 for increasing k. We shall call thees functions valid in certain interval in k "partialwaves". Here are the first few
$g(0;k)=\int_0^{\pi k} t^a \cos (t) \, dt,0\leq k<\frac{1}{2}$
$g(1;k)=\int_0^{\frac{\pi }{2}} t^a \cos (t) \, dt-\int_{\frac{\pi }{2}}^{\pi k} t^a \cos (t) \, dt,\frac{1}{2}\leq k<\frac{3}{2}$
$g(2;k)=\int _0^{\frac{\pi }{2}}t^a \cos (t)dt-\int _{\frac{\pi }{2}}^{\frac{3 \pi }{2}}t^a \cos (t)dt + \int _{\frac{3 \pi }{2}}^{\pi k}t^a \cos (t)dt,\frac{3}{2}\leq k<\frac{5}{2}$
and so on.
This can be written recursively for n = 1, 2, 3, ... as
$g(n;k)=g\left(n-1;n-\frac{1}{2}\right)+(-1)^n \int _{\pi \left(n-\frac{1}{2}\right)}^{\pi k}t^a \cos (t)dt,n-\frac{1}{2}\leq k<n+\frac{1}{2}$
In order to calculate the functions g(n;k) (designated ggX[n,k], where X->0 for a = 0 and X->1 for a = 1/2) we need first the expressions for n=0:
Case a = 0
gg0[0, k_] = Integrate[Cos[t], {t, 0, π k}]
Sin[k π ]
Case a = 1/2
gg1[0, k_] = Integrate[Sqrt[t] Cos[t], {t, 0, π k}]
-Sqrt[(π /2)] FresnelS[Sqrt[2] Sqrt[k]] + Sqrt[k] Sqrt[π] Sin[k π ]
Now for n = 1, 2, ... the part of g denpending on k ist the last integral which, including the factor (-1)^n, will be designated gfX[n,k]
For a = 0 we find
Simplify[(-1)^n Integrate[t^a Cos[t], {t, π (n - 1/2), π k},
Assumptions -> { a == 0}], {n \[Element] Integers }]
(-1)^n ((-1)^n + Sin[k π])
(helping Mathematica a bit in the trivial simplification of the minus ones)
gf0[n_, k_] = 1 + (-1)^n Sin[k π]
1 + (-1)^n Sin[k π]
and for n > 0 and a = 1/2
gf1[n_, k_] =
Simplify[(-1)^n Integrate[
Sqrt[t] Cos[t], {t, π (n - 1/2), π k}], {n \[Element] Integers ,
n > 0, k > n - 1/2}]
1/2 (-1)^n Sqrt[π] ((-1)^n Sqrt[-2 + 4 n] -
Sqrt[2] FresnelS[Sqrt[2] Sqrt[k]] + Sqrt[2] FresnelS[Sqrt[-1 + 2 n]] +
2 Sqrt[k] Sin[k π])
The recursion relation is for a = 0
Clear[gg0]
req = {gg0[0, k] == Sin[k π],
gg0[n, k] == gg0[n - 1, π (n - 1/2)] + gf0[n, k]}
{gg0[0, k] == Sin[k π],
gg0[n, k] == 1 + gg0[-1 + n, (-(1/2) + n) π] + (-1)^n Sin[k π]}
The direct attack
RSolve[req, gg0[n, k], n]
RSolve[{gg0[0, k] == Sin[k π],
gg0[n, k] == 1 + gg0[-1 + n, (-(1/2) + n) π] + (-1)^n Sin[k π]},
gg0[n, k], n]
does not work.
Therefore we do it with a the inductive method "examples and guess" as follows:
gg0[0, k_] = Sin[k π];
Table[x = gg0[n - 1, (n - 1/2)] + gf0[n, k]; gg0[n_, k_] = x, {n, 1, 5}]
{2 - Sin[k π], 4 + Sin[k π], 6 - Sin[k π], 8 + Sin[k π],
10 - Sin[k π]}
The general formula is easily deduced to be
Clear[gg0]
gg0[n_, k_] = (2 n + (-1)^n Sin[π k]);
which holds even for n=0.
The "partialwaves" ff0[n,k] are therefore given by
ff0[n_, k_] = gg0[n, k]/(π k)
(2 n + (-1)^n Sin[k π])/(k π)
It is interesting to plot some of them together in one diagram
Plot[Evaluate[Table[ff0[n, k], {n, 0, 3}]], {k, 0, 7/2},
PlotRange -> {-0.5, 1.5},
PlotLabel ->
"'Partialwaves'(0..3) of \!\(\*TagBox[\(f0(k) = \
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \
\(1\)]\*TemplateBox[{RowBox[{\"cos\", \"(\", \nRowBox[{\"\[Pi]\", \" \
\", \"k\", \" \", \"r\"}], \")\"}]},\n\"Abs\"] \[DifferentialD]r\),
HoldForm]\)", AxesLabel -> {"k", "f0(k)"} ]
(* plot_ff0_pw *)
We see that the functions neatly play the "relay"-game in defining the solution.
The blue curve, valid for 0<=k<1/2, relays to the red one at k=1/2. The red has the defining lead from k=1/2 to k=3/2 where it finally relays to the yellow curve, and so forth.
Now we take the final step relating n to k via the obvious formula
nn[k_] := Floor[k + 1/2]
The complete analytic solution of the initial integral is therefore
for a = 0
f0[k_] = ff0[Floor[k + 1/2], k];
as mentioned in the beginning.
The asymptotic behaviour of f0 for k->[Infinity] is obviously
f0as = 2/π
% // N
2/π
0.63662
In the case a = 1/2 the inductive method gives
(To get simpler expressions we divide by Sqrt[π])
gg1[0, k]/Sqrt[π] // Simplify
-(FresnelS[Sqrt[2] Sqrt[k]]/Sqrt[2]) + Sqrt[k] Sin[k π]
1/Sqrt[π]
Table[x = gg1[n - 1, (n - 1/2)] + gf1[n, k]; gg1[n_, k_] = x, {n, 1, 4}] //
Expand // TableForm
$\begin{array}{l}
\sqrt{2}-\sqrt{2} \text{FresnelS}[1]+\frac{\text{FresnelS}\left[\sqrt{2} \sqrt{k}\right]}{\sqrt{2}}-\sqrt{k} \text{Sin}[k \pi ] \\
\sqrt{2}+\sqrt{6}-\sqrt{2} \text{FresnelS}[1]+\sqrt{2} \text{FresnelS}\left[\sqrt{3}\right]-\frac{\text{FresnelS}\left[\sqrt{2} \sqrt{k}\right]}{\sqrt{2}}+\sqrt{k} \text{Sin}[k \pi ] \\
\sqrt{2}+\sqrt{6}+\sqrt{10}-\sqrt{2} \text{FresnelS}[1]+\sqrt{2} \text{FresnelS}\left[\sqrt{3}\right]-\sqrt{2} \text{FresnelS}\left[\sqrt{5}\right]+\frac{\text{FresnelS}\left[\sqrt{2} \sqrt{k}\right]}{\sqrt{2}}-\sqrt{k} \text{Sin}[k \pi ] \\
\sqrt{2}+\sqrt{6}+\sqrt{10}+\sqrt{14}-\sqrt{2} \text{FresnelS}[1]+\sqrt{2} \text{FresnelS}\left[\sqrt{3}\right]-\sqrt{2} \text{FresnelS}\left[\sqrt{5}\right]+\sqrt{2} \text{FresnelS}\left[\sqrt{7}\right]-\frac{\text{FresnelS}\left[\sqrt{2} \sqrt{k}\right]}{\sqrt{2}}+\sqrt{k} \text{Sin}[k \pi ] \\
\end{array}$
We de deduce the formula
Clear[gg1]
gg1[n_, k_] :=
Sum[Sqrt[4 m - 2] + (-1)^m Sqrt[2] FresnelS[Sqrt[2 m - 1]], {m, 1,
n}] - (-1)^n (FresnelS[Sqrt[2] Sqrt[k]]/Sqrt[2] - Sqrt[k] Sin[k π])
The functions ff1 are
ff1[n_, k_] = gg1[n, k]/(π k^(3/2))
Plotting the first 4 partialwaves:
Plot[Evaluate[Table[ff1[n, k], {n, 0, 3}]], {k, 0, 7/2},
PlotRange -> {-0.5, 1.5},
PlotLabel ->
"'Partialwaves'(0..3) of \!\(\*TagBox[\(f1 \((k)\) = \
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(1\)]\*SqrtBox[\(r\)] \
\*TemplateBox[{RowBox[{\"cos\", \"(\", \nRowBox[{\"\[Pi]\", \" \", \
\"k\", \" \", \"r\"}], \")\"}]},\n\"Abs\"] \[DifferentialD]r\),
HoldForm]\)", AxesLabel -> {"k", "f1(k)"} ]
(* plot_ff1_pw *)
A similar "relay"-game is observed.
Notice that the dependence of f on k is given by Sin[π k]/(π k), exactly as in the case a=0.
The final explicit analytical solution is obtained as before by replacing n via k.
Is has the form a finite sum:
f1[k_] := 1/(π k^(3/2)) (Sum[
Sqrt[4 m - 2] + (-1)^m Sqrt[2] FresnelS[Sqrt[2 m - 1]], {m, 1,
Floor[k + 1/2]}] - (-1)^
Floor[k + 1/2] (FresnelS[Sqrt[2] Sqrt[k]]/Sqrt[2] -
Sqrt[k] Sin[k π])) // Simplify
as mentioned in the beginning.
In order to caluclate the asymptotic behaviour of f1[k] for k->[Infinity] we observe that the only term left over is
1/(π k^(3/2)) Sum[Sqrt[4 m - 2], {m, 1, Floor[k + 1/2]}]
The in the limit k->[Infinity] this goes to
f1as = 4/(3 π );
% // N
0.424413
The (not so difficult) proof is left as an exercise to the reader.
Now we plot the functions together with their respective asymptotic value
Plot[{2/π], f0[k]}, {k, 0, 5}, PlotRange -> {0, 1.1},
PlotLabel ->
"The function \!\(\*TagBox[\(f0 \((k)\) = \*SubsuperscriptBox[\(\[Integral]\
\), \(0\), \(1\)]\*TemplateBox[{RowBox[{\"cos\", \"(\", \nRowBox[{\"\[Pi]\", \
\" \", \"k\", \" \", \"r\"}], \")\"}]},\n\"Abs\"] \[DifferentialD]r\),
HoldForm]\)\nand the asymptotic value \!\(\*TagBox[FractionBox[\(2\), \(\[Pi]\
\)],
HoldForm]\)", AxesLabel -> {"k", "f0(k)"}]
(* plot_f0 *)
Plot[{4/(3 π), f1[k]}, {k, 0, 5}, PlotRange -> {0, 1.1},
PlotLabel ->
"The function \!\(\*TagBox[\(f1 \((k)\) = \*SubsuperscriptBox[\(\
\[Integral]\), \(0\), \(1\)]\*SqrtBox[\(r\)] \
\*TemplateBox[{RowBox[{\"cos\", \"(\", \nRowBox[{\"\[Pi]\", \" \", \
\"k\", \" \", \"r\"}], \")\"}]},\n\"Abs\"] \[DifferentialD]r\),
HoldForm]\)\nand the asymptotic value \!\(\*TagBox[FractionBox[\(4\), \
\(3\\\ \[Pi]\)],
HoldForm]\)", AxesLabel -> {"k", "f1(k)"}]
(* plot_f1 *)
3. Summary
1) The exact analytic solution of the integral $f(k)=\int _0^1r^a |\cos (\pi r k)|dr$ was calculated with the result
$f(k, a=0)=\frac{2 \left\lfloor k+\frac{1}{2}\right\rfloor +(-1)^{\left\lfloor k+\frac{1}{2}\right\rfloor } \sin (\pi k)}{\pi k}$
It is the sum of two highly dicontinuious functions which merge to give a smooth function. For a=1/2 the Situation is similar.
2) The solutions are oscillating about a positive value. The oscillation is goverened by the well-known function $\frac{\sin (x)}{x}$
3) As we have shown earlier, the solution is also given by the elliptic integral, so that we have found here an interesting expression (which I coulnd't find in Abramovich/Stegun)
$E(\pi k|1) = 2 \left\lfloor k+\frac{1}{2}\right\rfloor +(-1)^{\left\lfloor k+\frac{1}{2}\right\rfloor } \sin (\pi k)$
4) The procedure described here generalizes to other values of the Parameter a > -1.
5) Last but not least let me point out that I couldn't have found the results without MMA - in finite time! This might justify the presentation of the more or less mathematical topic in this forum.