Finding $f(1)$ from the given integral function 
Consider the function-
  $$g(x)=\begin{cases} 1, \text{ if } x\in[-1,1]\\ 0, \text{ otherwise } \end{cases}$$
and $$f(x)=\lim_{h\to0}\frac{1}{2h}\int_{x-h}^{x+h}g(y)dy$$
then what is the value of $f(1)?$

My attempt:
We get, $$f(1)=\lim_{h\to0}\frac{1}{2h}\int_{1-h}^{1+h}g(y)dy$$
Applying Newton-Leibnitz for the nuemerator after applying L'Hopital for this $0/0$ limit, we get
$$f(1)=\frac{g(1+h)+g(1-h)}{2}=1$$
Am I correct?
 A: You are replacing the wrong variable in your solution.
$$
f(1)=\lim_{h\to 0}\frac{1}{2h}\int_{1-h}^{1+h}g(y)dy.
$$
Now, for each fixed $h<2$, 
$$
\int_{1-h}^{1+h}g(y)dy=1-(1-h)=h.
$$
Thus, 
$$
f(1)=\lim_{h\to 0}\frac{h}{2h}=\lim_{h\to 0}\frac{1}{2}=\frac{1}{2}.
$$
A: $$f(1)=\lim_{h\to0}\frac{1}{2h}\int_{1-h}^{1+h}g(y)dy = \lim_{h\to0}\frac{1}{2h}\int_{1-h}^{1}g(y)dy = \lim_{h\to0}\frac{1}{2h}(1-(1-h)) ={1\over 2}$$
A: Since the function under limit is an even function of $h$ it is sufficient to deal with $h\to 0^{+}$ only. 
We have $$\lim_{h\to 0^{+}}\frac{1}{2h}\int_{1-h}^{1+h}g(y)\,dy=\lim_{h\to 0^{+}}\frac{1}{2h}\int_{1-h}^{1}g(y)\,dy$$ The integral evaluates to $h$ and hence the above limit is $1/2$.
Your approach is fine but the issue is that you seem to assume $g$ continous at $1$.
A: The two sided limit, $\lim_{h \rightarrow 0}~g(1+h)$, does not exist because $g(x)$ is discontinuous in $x=1$. (To be more specific, we are dealing with a jump discontinuity.) This will cause problems when computing $f(1)$. 
If we would to take the one-sided limit from above, then we would get $lim_{h \rightarrow 0^+}~g(1+h) = 0$ and $\lim_{h \rightarrow 0^+}~g(1-h) = 1$. 
I have not done the full derivation but I am guessing the final answer would be $f(1)=1/2$. 
I hope this helps you out enough, good luck solving the math problem!
