Does there exist function that behaves in this way around some point and is continuous at that point? Suppose that we have some function $f: \mathbb R \to \mathbb R$ such that $f$ is integrable (Riemann or Lebesgue, choose one, or some other maybe more general type of integration, if there is such) on some inteval $(a,b)$. 
Now suppose that there exist point $x_0 \in (a,b)$ and sequence $\varepsilon_n$ such that $\varepsilon_n$ is positive and strictly decreasing and $\lim_{n \to \infty} \varepsilon_n =0$ and that $\varepsilon_n$ is such that we have $\int_{x_0}^{x_0 + \varepsilon_{2k-1}} f(x)dx>0$ and $\int_{x_0}^{x_0 + \varepsilon_{2k}} f(x)dx<0$ for every $k \in \mathbb N$.
The question is:

1) Can we have such an $f$ that is continuous at $x_0$?

 A: Hint: Consider the derivative of $x^m\sin (1/x^n)$ for appropriate positive integers $m,n.$ (Here thinking $x_0 = 0.$)
A: Yes we can : I take $I=[0,1],$ $\varepsilon_n=\frac{1}{n}$ for $n\in\mathbb{N}^*$ and I define on each subintervals $I_n:=[\frac{1}{n+1},\frac{1}{n}]$ (note $m_n=\frac{\frac{1}{n}+\frac{1}{n+1}}{2}=\frac{2n+1}{2n(n+1)}$ the middle of that interval) my function 
$f:I\to \mathbb{R}$ such as :


*

*In english, the graph of $f|_{I_n}$ is the triangle which base is $I_n$ and last point is $(m_n,(-1)^n \frac{1}{4n})$ (the main idea : up and down triangles such as the first one "covers" the second, the third, etc. and the second one "covers" the third one, the fourth, etc.), and $f(0)=0$ ;

*In mathematics (even if only the idea is important),  $$f|_{I_n}:x\mapsto(-1)^n(x-\frac{1}{n+1}) \text{ if } x\in[\frac{1}{n+1},m_n] \text{ and } (-1)^n(x-m_n)\times\frac{\frac{1}{n+1}-m_n}{\frac{1}{n}-m_n}+m_n-\frac{1}{n-1} \text{ else} $$ and $f(0)=0$.
Once this written, we can remark that $f$ is continuous : the only point where it is not immediate is $0$ but one can easily see that if we define $f(0)=0,$ then $f$ is continuous on $I$. Finally we can see that :


*

*$f$ is continuous so Riemann-integrable 

*$\int_0^{\varepsilon_n}f(t)dt$ is strictly positive when $n$ is even and strictly negative when $n$ is odd (writing $\int_0^{\varepsilon_n}f(t)dt=\int_0^{\varepsilon_{n-1}}f(t)dt+\int_{\varepsilon{n-1}}^{\varepsilon_n}f(t)dt$ and do majorations)
and we get the function you were looking for.
