I am trying to build up some intuition of what the various notions of analysis mean. By intuition of continuity is that it means the graph of the function is 'connected', but not necessarily in any nice way. This lead me to ask the question 'Given a function $f: \mathbb{R} \to \mathbb{R}$ and a point $x_0 \in \mathbb{R}$, what assumptions must we impose on $f$ so that we can say $f$ is 'approximately a line' in some neighbourhood of $x_0$?'
To apply Taylor's theorem, we need that $f$ is twice continuously differentiable at $x_0$. However I am only interested in some tiny neighbourhood of $x_0$, so can we weaken these assumptions?
We certainly can't weaken them all the way down to continuity at $x_0$; for example the function $g: \mathbb{R} \to \mathbb{R}$ defined by $$g(x) = \begin{cases} x \sin(\frac{1}{x}), \ x \neq 0 \\ 0, \qquad \quad \ x=0 \end{cases}$$ is continuous at $x_0 = 0$, but certainly cannot be approximated by a line there. Differentiability at $x_0$ also won't do; consider $h: \mathbb{R} \to \mathbb{R}$ given by $$h(x) = \begin{cases} x^2 \sin(\frac{1}{x}), \ x \neq 0 \\ 0, \qquad \quad \ \ \ x=0. \end{cases}$$ This is differentiable and hence continuous at $x_0 = 0$. Indeed it is differentiable everywhere, but it is not continuously differentiable at $0$; it's derivative is $h': \mathbb{R} \to \mathbb{R}$ given by $$h'(x) = \begin{cases} 2x\sin(\frac{1}{x}) - \cos(\frac{1}{x}), \ x \neq 0 \\ 0, \qquad \qquad \qquad \qquad x=0 \end{cases}$$ whose limit at $0$ doesn't exist. Going one step further, we consider $k: \mathbb{R} \to \mathbb{R}$ given by $$k(x) = \begin{cases} x^3 \sin(\frac{1}{x}), \ x \neq 0 \\ 0, \qquad \quad \ \ \ x=0. \end{cases}$$ Again this is differentiable everywhere, but now it is continuously differentiable at $0$ (and so everywhere); it's derivative is $k': \mathbb{R} \to \mathbb{R}$ given by $$k'(x) = \begin{cases} 3x^2\sin(\frac{1}{x}) - x\cos(\frac{1}{x}), \ x \neq 0 \\ 0, \qquad \qquad \qquad \qquad \quad \ x=0 \end{cases}$$ which is continuous everywhere. However this function obviously still can't be approximated by a straight line near $0$ (since it takes on positive, negative, and zero values arbitrarily near the origin, and a straight line through the origin can only take on positive, negative, $\textit{or}$ zero values near the origin).
At first I thought the problem was that the value of the derivatives of $g, h$ and $k$ around $x_0 = 0$ were unbounded, i.e. their 'slopes' grow without bound, however this is only the case for $g$; the derivative of $h$ near $0$ is approximately between $-1$ and $1$ and the derivative of $k$ near $0$ is approximately $0$. Then I thought the problem was that that the derivatives of $g, h,$ and $k$ had arbitrarily many sign changes near $x_0 = 0$, however this also can't be right.
So now I'm just confused. Do we in fact need all the assumptions warranted by Taylor's theorem, i.e. twice continuously differentiable at $x_0$, to guarantee that a function is 'like a line' at a point? Do we actually need more hypotheses than Taylor's theorem in that we have to assume information about $f$ not at $x_0$, i.e. in some neighbourhood?
Thanks in advance. I also wouldn't mind comments explaining your intuitions about related notions in analysis.
tl;dr: what restrictions must we place on a function $f: \mathbb{R} \to \mathbb{R}$ so that when we 'zoom in close enough', it looks like a straight line?