$f(x)= \begin{cases} x^2 & \text{if } -2 ≤ x ≤ 2, \\ 2x & \text{if } x > 2. \end{cases}$
I am finding the derivative at $x = 2$. I am saying that the derivative is $4$ because $x =2$ is on $f(x)$ $=$ $x^2$, and the derivative of $x^2$ is $2x$ and $2(2) = 4$, and thus $f'(2) = 4$, but my classmates say that the function is non-differentiable.
I don't think the second part of the piecewise function affects $x = 2$, but they're all saying I'm incorrect, so I'm looking for reassurance.
The problem with your argument is that the derivative depends not just on the value of $f(x)$ at $x=2$, but on its behaviour around this point. This behaviour differs depending on whether you are approaching from the left or the right. A nice way to see this is to use the limit definition of the derivative: $$ f'(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h} $$ For your function, at $x=2$ this limit does not exist. To see this, we calculate the left and right limits and note that they are not equal.
The right limit is: $$ \lim_{h\to 0^{+}}\frac{f(2+h)-f(2)}{h} = \lim_{h\to 0^{+}}\frac{2h}{h} = 2 $$ while the left limit gives: $$ \lim_{h\to 0^{-}}\frac{f(2+h)-f(2)}{h} = \lim_{h\to 0^{-}}\frac{4h+h^{2}}{h} = 4 $$
Then since these two limits differ, we say that the (two-sided), limit which defines $f'(2)$ does not exist, and so $f(x)$ is not differentiable at $x=2$.