Question
Determine the values of $a$ and $b$ such that the following function is differentiable at 0.
$$f(x) = \begin{cases} ax^3cos(\frac 1 x) + bx + b, & \text{if }x \lt 0 \\ \sqrt{a + bx}, & \text{if }x \geq 0 \end{cases}$$
My solution
For $f$ to be differentiable at $0$, $f$ must first be continuous at $0$.
$$\implies \lim\limits_{x\to0^-}f(x) = \lim\limits_{x\to0^+}f(x)$$
Consider
\begin{align} \lim\limits_{x\to0^-}f(x) & = \lim\limits_{x\to0^-}[ax^3cos(\frac 1 x) + bx + b]. \\[5 mm] \because \lim\limits_{x\to0^-}ax^3cos(\frac 1 x) & = \lim\limits_{x\to0^-}bx \\[5 mm] & = 0 \end{align}
$$\therefore \lim\limits_{x\to0^-}f(x) = b$$
Then, consider
\begin{align} \lim\limits_{x\to0^+}f(x) & = \lim\limits_{x\to0^+}\sqrt{a + bx} \\[5 mm] & = \sqrt{a}. \end{align}
$$\implies a = b^2$$
Furthermore, for $f$ to be differentiable at $0$,
$$\lim\limits_{x\to0^-}\frac {f(x) - \sqrt{a}} x = \lim\limits_{x\to0^+}\frac {f(x) - \sqrt{a}} x$$
When $a = b^2$,
\begin{align} \lim\limits_{x\to0^+}\frac {f(x) - \sqrt{a}} x & = \lim\limits_{x\to0^+}\frac {\sqrt{a + bx} - \sqrt{a}} x \\[5 mm] & = \lim\limits_{x\to0^+}\frac b {\sqrt{a + bx} + \sqrt{a}} \\[5 mm] & = \frac b {2\sqrt{a}} \\[5 mm] & = \frac 1 2 \\[5 mm] \implies \lim\limits_{x\to0^-}\frac {f(x) - \sqrt{a}} x & = \lim\limits_{x\to0^-}\frac {ax^3cos(\frac 1 x) + bx + b - \sqrt{a}} x \\[5 mm] & = \lim\limits_{x\to0^-}\frac {b^2x^3cos(\frac 1 x) + bx} x \\[5 mm] & = \lim\limits_{x\to0^-}[b^2x^2cos(\frac 1 x) + b] \\[5 mm] & = \frac 1 2 \end{align}
$$\because \lim\limits_{x\to0^-}b^2x^2cos(\frac 1 x) = 0$$
$$\therefore b = \frac 1 2$$
$$\implies a = \frac 1 4$$
I would like to know if my proposed solution is logical and correct. Moreover, any alternative solutions that are more elegant or succinct are welcomed as well :)
Thank you all in advance!
Edit
Following a discussion with MPW, looks like all is well, except perhaps the fact that
$$\implies a = b^2$$
should have been left as
$$\implies \sqrt{a} = b$$
It looks essentially correct and nicely detailed to me, good work.
My only comment would be that you're assuming $b\geq 0$ when you use $\sqrt{b^2} = b$, so it might be worth considering the computations under the assumption $b<0$ to see if you get a second solution (I haven't pursued this). Note this would give that $\sqrt{b^2} = -b$.
On the face of it, I don't see an immediate reason to exclude $b<0$.