# Plotting function and its approximation function

I have a problem which I have not been able to solve. I want to plot a function and and operator which approximates it when you let w to infinity. I will give all needed information for MWE and my faults.

### MathJax

$$\operatorname{Fejer}(x):= \dfrac{1}{2} \operatorname{sinc}^2\left(\dfrac{x}{2}\right) \quad (x\in \mathbb{R})\\ \operatorname{sinc} x:= \begin{cases} \dfrac{\sin \pi x}{\pi x}, & x\in \mathbb{R} \backslash \{0\}\\ 1, & x=0 \end{cases}\\ \operatorname{Function}(x):=\begin{cases} \dfrac{9}{x^2},& x<3\\ 2,& -3

### Code

sinc[x_] := Piecewise[{{1, Equal[x, 0]}, {Sin[Pi x]/(Pi x), True}}]
Fejer[x_] := 1/2*sinc[x/2]^2
function[x_] :=
Piecewise[
{{9/(x^2), x < -3},
{2, -3 <= x < -2},
{-1/2, -2 <= x < -1},
{3/2, -1 <= x < 0},
{1, 0 <= x < 1},
{-1, 1 <= x < 2},
{0, 2 <= x < 3},
{-50/(x^4), 3 <= x}}]
constant[x_] := 1


With above code I am defining the functions which I gave mathematically above to make it easier for you. Now, I'm trying to define my operator.

operator[w_, kernel_, func_, x_] :=
Sum[
w *
Integrate[func[u], {u, k/w, (k + 1)/w}, Assumptions -> k ∈ Integers] *
kernel[w*x - k],
{k, -Infinity, Infinity}]


I'm not sure about the above code. I used Assumption in the integral because I was getting errors like "integral limits may not reals, please add assumption". I also show it in MathJax so you can understand what I'm trying to do.

Operator

$$(S_wf)(x):=\sum_{k\in \mathbb{Z}} \chi(wx-k) w\int_{k/w}^{(k+1)/w} f(u)du , \quad x\in \mathbb{R}, \, w>0$$

When you take function to br $$1$$ for every $$x\in \mathbb{R}$$, operator gives $$1$$. Anyway when I running code

operator[w, Fejer, constant, x]


or

operator[5, Fejer, constant, x]


it gives nothing. When I tried plot

Plot[Operator[5, Fejer, cons, x], {x, 0, 5}]


it quits the kernel without an error.

When I tried

Plot[Operator[5, Fejer, function, x], {x, 0, 5}]


It gives many errors and some of them are:

NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

NIntegrate::nlim: u = 0.2 k is not a valid limit of integration.

General::stop: Further output of NIntegrate::nlim will be suppressed during this calculation.

Finally, I'm adding a result which I'm trying to reach.

• GSKS is not defined. Feb 19, 2021 at 21:23
• I named it operator, I edited my question. Thank you Feb 19, 2021 at 21:46

Clear["Global*"]
$Version (* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)  The definition of Fejer can be simplified to Fejer[x_] := 1/2*Sinc[x Pi/2]^2 function[x_] := Piecewise[{{9/(x^2), x < -3}, {2, -3 <= x < -2}, {-1/2, -2 <= x < -1}, {3/2, -1 <= x < 0}, {1, 0 <= x < 1}, {-1, 1 <= x < 2}, {0, 2 <= x < 3}, {-50/(x^4), 3 <= x}}] Operator[w_, kernel_, func_, x_] := Sum[w*Integrate[func[u], {u, k/w, (k + 1)/w}, Assumptions -> k ∈ Integers]* kernel[w*x - k], {k, -Infinity, Infinity}] constant[x_] := 1 Operator[w, Fejer, constant, x] // FullSimplify (* 1/4 (2 + (1/(π^2 w^2 x^2)) Cos[π w x] (-4 + w^2 x^2 (4 PolyGamma[1, w x] + PolyGamma[1, 1/2 - (w x)/2] - PolyGamma[1, 1 + (w x)/2])) + Sec[(π w x)/2]^2) *)  Evaluate the function to be plotted Plot[Operator[5, Fejer, constant, x] // FullSimplify // Evaluate, {x, 0, 5}, WorkingPrecision -> 20, PlotRange -> {0, 1.1}]  This example is quite slow Plot[Operator[5, Fejer, function, x] // N[#, 30] & // Evaluate, {x, 0, 5}, WorkingPrecision -> 25]  EDIT: Higher precision is needed for negative values of x Plot[Operator[5, Fejer, function, x] // N[#, 40] & // Evaluate, {x, -5, 5}, WorkingPrecision -> 30]  • Thank you sir for helping me. Can I learn when we are use N[ . ] , Evaluate, and WorkingPrecision. I used your code and it runs correctly. But when I tried with bigger$w$it sucks. Also I tried with$w=5$but in range$[-5,5]\$ its again did not give correct result. So my question is when I want to change someting in operator how can I decide other properties of Plot? Feb 20, 2021 at 1:16
• Plot has the attribute HoldAll; so Evaluate is often needed with Plot. Use of N` can simplify and accelerate evaluation of a function that cannot be analytically simplified. Highly complicated functions which involve extensive computation are prone to precision problems. High precision is then needed. How much is very case-dependent. Feb 20, 2021 at 1:41