I am trying to plot the partial sums and the CesÃ ro means of the function √|x||x|−−√\sqrt{|x|} and for anana_{n}, I obtained the following code which contains FresnelS.

(-((Sqrt[2] FresnelS[Sqrt[2] Sqrt[n]])/n^(3/2)) – (Sqrt[2] FresnelS[Sqrt[2] Sqrt[Abs[n]]])/Abs[n]^(3/2) + (2 Sin[n Ï€])/n + (2 Sin[Ï€ Abs[n]])/Abs[n])/(2 Sqrt[Ï€])

Now my question is, is it possible to graph such a function using Mathematica? I have tried many examples using trial and error and some of the my examples also contain BesselJ which can’t be graphed.

Hence, I would like to know if it is true that if there is BesselJ and FresnelS in the code, then the graph cannot be drawn using Mathematica. Please correct me if I am wrong. I am graphing out its graph using this code:

f[x_] := Sqrt[Abs[Mod[x, 2 Pi, -Pi]]];

s[k_, x_] := ???

partialsums[x_] = Table[s[n, x], {n, {4}}];

c[n_, x_] := (1/n) Sum[s[m, x], {m, 0, n – 1}]

Plot[Evaluate[{f[x], partialsums[x], c[{4}, x]}], {x, -Pi, Pi},

PlotLegends -> {“f(x)=x”, “Fourier, 4 terms”, “Cesaro, 4 terms”},

PlotStyle -> {{Blue}, {Dashed, Thickness[0.006]}, {Red,Thickness[0.006]}}]

=================

=================

1 Answer

1

=================

Coding Issue:

You can try to use DiscretePlot for the above expression out of the box in Mathematica!

DiscretePlot[

Evaluate@(-((Sqrt[2] FresnelS[Sqrt[2] Sqrt[n]])/

n^(3/2)) – (Sqrt[2] FresnelS[Sqrt[2] Sqrt[Abs[n]]])/

Abs[n]^(3/2) + (2 Sin[n Ï€])/n + (2 Sin[Ï€ Abs[n]])/

Abs[n])/(2 Sqrt[Ï€]), {n, 1, 150}]

Your code has minor typos! Before plotting always better to check what your functions are returning given an argument then you can spot the mistake in your code.

f[x_] := Sqrt[Abs[Mod[x, 2 Ï€, -Ï€]]];

s[k_, x_] := Sum[(2 – 2 Cos[n Ï€] – n Ï€ Sin[n Ï€])/(n^2 Ï€) Cos[n x], {n, 1, k}]

partialsums[x_] = First @ Table[N @ s[n, x], {n, {4}}];

c[n_, x_] := Sum[s[m, x], {m, 0, n – 1}]/n;

Plot[Evaluate[{f[x], partialsums[x], c[4, x]}], {x, -Ï€, Ï€},

PlotStyle -> {{Blue}, {Dashed, Thickness[0.006]}, {Red,Thickness[0.006]}}]

Actual Answer:

Definition: Let an∞n=0{a_n}_{n=0}^\infty be a sequence of real (or possibly complex numbers).

The CesÃ ro mean of the sequence {an}\{a_n\} is the sequence {bn}∞n=0\{b_n\}_{n=0}^\infty

with

bn=1n+1n∑i=0ai.\begin{equation}

b_n = \frac{1}{n+1} \sum_{i=0}^{n} a_i.

\end{equation}

Code:

Define the partial sum and the CesÃ ro mean to take only Integer argument!

f[x_] := N @ Sqrt[Abs[Mod[x, 2 Ï€, -Ï€]]];

part[k_?IntegerQ] := Total[(N @ f[#]) & /@ Range[0, k]];

cesaro[k_?IntegerQ] := part[k]/(k + 1);

Testing: Check functions only evaluate for Integer argument.

Evaluate @ {f[k], part[k], cesaro[k]} /. k -> 2

{1.41421, 2.41421, 0.804738}

Now plotting what you want!

DiscretePlot[Evaluate @ {f[k], cesaro[k]}, {k, 1, 50}, Frame -> True,

PlotStyle -> {{Red, PointSize[Medium]}, {Blue, Dashed}}, Joined -> {False, True}]

1

I had modified my post above. I am not trying to graph this function but I am trying to graph this in another terms. Do look at my code above.

– Sandra

Jan 15 ’13 at 20:09

Oops! I see. I think I had a mistake in my post as I just copy and paste. The s[k_, x_] part is wrong. This is one of my tryout for the function Pi/2 – Abs[x] with its correspondence s[k_, x_] but for my actual Sqrt[Abs[Mod[x, 2 Pi, -Pi]]] I can’t find its partial sums due to this Fresnel function.

– Sandra

Jan 15 ’13 at 20:22

So discreteplot is my only choice after all in order for me to graph these type of functions. I am trying to plot like the second diagram you had posted above but to no avail. Thanks Platomaniac. You had solve a lot of my queries with Mathematica.

– Sandra

Jan 15 ’13 at 21:07

@Sandra you can use many other plotting functions too. But DiscretePlot can take your expression as it is.

– PlatoManiac

Jan 15 ’13 at 21:40