Showing differentiabililty at a particular point. I am going through some review problems and I'm stuck in these problems.

For what values of $a$ and $b$ are the following functions differentiable at $x=0$?
$$(\text{i})~~~~~
f(x) = \left\{
        \begin{array}{ll}
            ax + b~&  \text{if $x \lt 0$} \\
            x-x^2~ &  \text{if $x \ge 0$}
        \end{array}~~~~~    \right.
$$
  $$(\text{ii})~~~~~~f(x) = \left\{
        \begin{array}{ll}
            ax^2 + b~&  \text{if $x \lt 1$} \\
            x-x^2~ &  \text{if $x \ge 1$}
        \end{array}~~~~~    \right.
$$

I know I have to show that $\displaystyle \lim_{x\to 0} \frac{f(x)-f(0)}{x}$ exists in both cases but I'm having a little trouble. For example, for the first one, I get $\displaystyle \lim_{x\to 0^+} (1-x) =1.$ But then I get stuck when trying to compute $\displaystyle \lim_{x\to 0^-} \frac{ax+b - f(0)}{x}.$ 
Please, I would like help on both problems. Thanks.
 A: Your work doesn't seem to help a lot since you want to find the values of $a$ and $b$ that make the functions both (first) differentiable and continuous.  You should consider the value of $x$ approaching $0^-$ and $0^+$, which leads to two cases.

Recall that the following statement (its converse is not true) is:

If the function $f(x)$ is differentiable at $x = a$, then the function $f(x)$ is continuous at $x = a$.

First Part
Depending on the type of method required to differentiate the function, you need to take a derivative of each function in piecewise function.  We get
$$f'(x) = \left\{
\begin{array}{c c}
a & \text{if $x < 0$}\\
1 - 2x & \text{if $x \geq 0$}
\end{array}
\right.$$
Set $f'(0^-) = f'(0^+)$, so $a = 1$.  But by the theorem of differentiability and continuity, we also need to find the values of $a$ and $b$, such that $f(0^-) = f(0^+)$.  So
$$a(0) + b = 0 \rightarrow b = 0$$
Therefore, $a = 1$ and $b = 0$, which implies
$$f(x) = \left\{
\begin{array}{c c}
x & \text{if $x < 0$}\\
x - x^2 & \text{if $x \geq 0$}
\end{array}
\right.$$
Second Part
This part is similar to the first.  I expect much of you to try this part by yourself.
