How can I find the tangent plane of this piecewise function? My professor encouraged us to think about the following problem:
Given
$\ f(x,y) = \begin{cases} 
          x^2+y^2-2y+1 & x^2=2y \\
          1-2y & x^2\neq2y 
       \end{cases}$
find, if they exist, the tangent planes of $f(x,y)$ for the points:
a) $(x_0,y_0)=(2,2)$
b) $(x_0,y_0)=(0,0)$

I know that the tangent plane equation is:
$Z_t=f(x_0,y_0)+f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0)$
My first instinct was to calculate $f_x(2,2)$ and $f_y(2,2)$ for $f(x,y)=x^2+y^2-2y+1$, given that $2^2=2(2)$. I found the following tangent plane:
$Z_t=4x+2y-7$
Likewise for $(x_0,y_0)=(0,0)$, I found:
$Z_t=1-2y$
BUT this appears to be completely wrong. I suspect I need to calculate the partial derivatives of this function applying the definition. For example:
$f_x(2,2)= \lim_{x \to 2} \frac{\overbrace{f(x,2)}^{-3}-\overbrace{f(2,2)}^{-5}}{x-2}$
But this limit doesn't exist. I'm confused. Should I conclude that because the partial derivative with respect to $x$ doesn't exist at this point, then the tangent plane doesn't exist either?
If I move on to $(x_0,y_0)=(0,0)$, I think I'm able to calculate the partial derivatives:
$f_x(0,0)= \lim_{x \to 0} \frac{f(x,0)-f(0,0)}{x}=0$
and
$f_y(0,0)= \lim_{y \to 0} \frac{f(0,y)-f(0,0)}{y}=2$
So I get the following tangent plane:
$Z_t=1-2y$
Which I had found previously. I don't know what to make of that. Where am I going wrong? I could use some guidance

For a function to be differentiable at a certain point, the limit that defines the derivtive needs to exist and be unique (left and right limit). Your function is not continuous at $(x, y) = (2, 2)$, because
$$f(2, 2) = 5 \ne -3 = \lim_{x \to 2, y \to 2} f(x, y)$$
So it's  non-differentiable in that point (It's not even continuous).
For the $(0, 0)$ you don't have such problem, but just to make sure, you should calculate the values and derivatives of both sides ofthe definition at $(0, 0)$ and justify what I said.
Generally speaking you should always check these things at the border of the piecewise definitions.
