Calculate the one-sided limits at $x=1$:
- $\displaystyle\lim_{x\to 1+}f(x)=\lim_{x\to 1+}2=2$
- $\displaystyle\lim_{x\to 1-}f(x)=\lim_{x\to 1-}x^2=1$
Since they are not equal, $f$ is not continuous at $x=1$. The rest that you did has some mistakes (you do not calculate one-sided limits when you should) but more importantly is not necessary (and may be time consuming in an exam with limited time).
If $f$ has a primitive $F$, by definition $f$ satisfies $F'=f$.
Now, by Darboux theorem $f$ satisfies the IVP.
A function with a jump discontinuity cannot satisfy the IVP:
First proof: analytical
let $\varepsilon=\frac{|f(x_0^-)-f(x_0^+)|}{3}$. By limit definition, there exists $\delta_1,\delta_2$ such that $x_0-\delta_1<x<x_0\rightarrow |f(x_0^-)-f(x)|<\varepsilon$ and $x_0<x<\delta_2+x_0\rightarrow |f(x_0^+)-f(x)|<\varepsilon$.
Setting $\delta=\min(\delta_1,\delta_2)$ we obtain that
$$f\big((x_0-\delta,x_0+\delta)\big)\subset \big(f(x_0^-)-\varepsilon,f(x_0^-)+\varepsilon\big)\cup \big(f(x_0^+)-\varepsilon,f(x_0^-)+\varepsilon\big)\cup {f(x_0)}$$
But this contradicts the IVP.
- Second proof: topological
We claim that a function $h:\mathbb{R}\to \mathbb{R}$ satisfies the IVP only if it maps closed intervals to intervals (in $\mathbb{R}^*$). The fact that $h$ cannot have a jump discontinuity then trivially follows.
To prove our claim, let $h([a,b])$ be a set that is not an interval (and thus it is not path connected, since the only path connected sets in $\mathbb{R}*$ are the intervals). Then there is a point $y\in[h(a),h(b)]$ that is not in $h([a,b])$, and this clearly contradicts the IVP.
- Note:On the existence of primitive
To answer your other question: the IVP is not enough to ensure the existence of a primitive. Actually, it is not enough to even ensure the non boundedness of the function (see, for example, the Base 13 function).
- Note: A proof of Darboux Theorem
The case in which $f=F'=k'$ is trivial. Let $F$ be a differentiable mom constant function defined on a closed interval $[a,b]$ and let $f=F'$, and let $y$ be a number in $(f(a),f(b))$ (if instead $f(b)<f(a)$ the proof is no different).
Now, let $h(x):=F(x)-xy$. This function is continuous and so, by Weierstrass theorem, it has a maximum and a minimum. They can't both be on the boundary of the interval, since this would imply the fact that $F$ is constant. Thus, at least one of those point is on the interior of the interval, and by Fermat theorem in this point (let us call it $\zeta$) we have $h'(\zeta)=0\rightarrow f(\zeta)-y=0\rightarrow f(\zeta)=y$.
Best Answer
OK, next thought - the function $f(\frac pq)=\frac1q$ and zero elsewhere. That's closer; it has limits of zero everywhere. But then each rational is a removable discontinuity, not a jump discontinuity. Closer, but still not it.
The next idea after that: let's build an increasing function with jumps at every rational. Let $g$ be an enumeration of the rationals; for each rational $r$, $g(r)$ is a different positive integer $n$. Then, define $$f(x) = \sum_{r\in\mathbb{Q},r\le x}\frac1{g(r)^2+g(r)}$$ Since $\sum_n \frac1{n^2+n}$ converges (to $1$), that sum is finite for every $x$.
Choose some arbitrary $x$ and $\epsilon>0$. Let $n$ be such that $\epsilon\ge\frac1n$. There are only finitely many values $r_1,r_2,\dots,r_n$ with $g(r_i)\le n$. If we choose $\delta$ such that $(x,x+\delta)$ contains none of these $r_i$, then for $y\in (x,x+\delta)$, $$f(y)-f(x)=\sum_{r\in\mathbb{Q},x<r\le y}\frac1{g(r)^2+g(r)} \le \sum_{j=n+1}^{\infty}\frac1{j^2+j}=\frac1{n+1}<\epsilon$$ From that, $\lim_{y\to x^+}f(y)=f(x)$ for all $x$. We have limits from the right.
For limits from the left, consider the variant function $$f^*(x)=\sum_{r\in\mathbb{Q},r< x}\frac1{g(r)^2+g(r)}$$ This $f^*$ is equal to $f$ except at the rationals, where $f(r)-f^*(r)=\frac1{g(r)^2+g(r)}$. Again, choose arbitrary $x$ and $\epsilon>0$, and let $n$ be such that $\epsilon\ge \frac1n$. Find $\delta$ such that $(x-\delta,x)$ contains none of the $n$ points $r_i$ with $g(r_i)\le n$. Then, for $y\in (x-\delta,x)$, $$f^*(x)-f(y) = \sum_{r\in\mathbb{Q},y\le r< x}\frac1{g(r)^2+g(r)} \le \sum_{j=n+1}^{\infty}\frac1{j^2+j}=\frac1{n+1}<\epsilon$$ From that, $\lim_{y\to x^-}f(y) = f^*(x)$ for all $x$, and we have limits from the left.
Of course, these limits $\lim_{y\to x^+}f(y)=f(x)$ and $\lim_{y\to x^-}f(y) = f^*(x)$ differ for every rational $x$, so there's a jump discontinuity at every rational.
With $f$ discontinuous at a dense set of points, it fails to be continuous on any interval, and can't be a piecewise continuous function. Done. We have our example.
I defined this as a function from $\mathbb{R}$ to $\mathbb{R}$, but it's easy to get a function on a smaller interval. Restricting $f$ works, as does using an enumeration of the rationals in that smaller interval.