Determine the values of a and b that makes the function differentiable everywhere Given $$f(x)=ax^3\cos(1/x)+bx+b$$ for $$x<0$$
and
$$f(x)=\sqrt{a+bx}$$
for $$x\ge0$$
Where $$a,b$$
are positive constants.
Determine the values of a and b, if any, that make f differentiable everywhere.
Proposed solution:
(1) $$f'(x)=3ax^2\cos(\frac{1}{x})+ax\sin(\frac{1}{x})+b$$
and (2) $$f'(x)=\frac{1}{2}(a+bx)^{-\frac{1}{2}}b$$ 
From (2), $$f(0)=a^{\frac{1}{2}}, f'(0)=\frac{1}{2}(a^{-\frac{1}{2}})b$$ and
From (1), $$\lim_{x \rightarrow 0-}f(x)=b$$ (Using Squeeze theorem)
Since differentiability implies continuity,
(3)
$$\lim_{x \rightarrow 0-}f(x)=\lim_{x \rightarrow 0}f(x)=b=f(0)=a^{\frac{1}{2}}$$
For f(x) to be differentiable at 0, using (3),
$$\frac{1}{2}=3ax^2\cos(\frac{1}{x})+ax\sin(\frac{1}{x})+a^{\frac{1}{2}}$$
which is unsolvable.
So a,b does not exist.
Am I right? Thanks.
 A: From continuity, we indeed get $b = \sqrt{a}$.
Plugging this in the derivatives, we get 
$$\lim_{ x \uparrow 0} f'(x) = b =  \lim_{x \downarrow 0 } f'(x) = \frac{1}{2} \frac{ b}{\sqrt{a}} = \frac{1}{2}$$
So $a= \frac{1}{4}$ and $b= \frac{1}{2}$ makes the function differentiable.
A: Generally, setting the two different pieces of the piecewise function equal to each other and setting their derivatives equal is a good shortcut and will usually yield the correct answer.  However, technically what you are getting at is proving continuity and differentiability.  To do this, you should use the definitions of these two things when $x=0$ (since that's the point when you switch between the two functions).
Continuous
To show continuity, use
$$\lim_{x \to 0} f(x) = f(0)$$
This will require the use of two different one sided limits since $f(x)$ is different to the left and right of $x=0$.  Solve
$$\lim_{x \to 0^{-}} ax^3cos\bigg(\frac{1}{x}\bigg)+bx+b = \sqrt{a}$$
$$\lim_{x \to 0^{+}} \sqrt{a+bx} = \sqrt{a}$$
Simplifying the left sided limit's equation will give you $$b=\sqrt{a}$$ and the right sided limit's equation will just give you $$\sqrt{a}=\sqrt{a}$$ which is not particularly useful.  However, we will save the $b=\sqrt{a}$ equation for later.
Differentiable
Now we also need to show that the function is differentiable at $x=0$.  In order to show this, we need to be able to say that this limit exists:
$$\lim_{h \to 0} \frac{f(x+h)-f(x)}{h}.$$
Since we need this limit to exist at $x=0$ specifically, we can instead show the existence of this limit:
$$\lim_{h \to 0} \frac{f(0+h)-f(0)}{h}.$$
In order for this limit to exist, both of its one sided limits need to exist and they need to be equal.  So we need these to be equal:
$$\lim_{h \to 0^{-}} \frac{f(h)-f(0)}{h} = \lim_{h \to 0^{+}} \frac{f(h)-f(0)}{h}$$
$$\lim_{h \to 0^{-}} \frac{\Big[ah^3cos\big(\frac{1}{h}\big)+bh+b\Big]-\Big[\sqrt{a}\Big]}{h} = \lim_{h \to 0^{+}} \frac{\Big[\sqrt{a+bh}\Big]-\Big[\sqrt{a}\Big]}{h}$$
Since we already know $b=\sqrt{a}$, we can plug that in for $b$ now to simplify.
$$\lim_{h \to 0^{-}} \frac{ah^3cos\big(\frac{1}{h}\big)+h\sqrt{a}+\sqrt{a}-\sqrt{a}}{h} = \lim_{h \to 0^{+}} \frac{\sqrt{a+h\sqrt{a}}-\sqrt{a}}{h}$$
$$\lim_{h \to 0^{-}} \frac{h\Big[ah^2cos\big(\frac{1}{h}\big)+\sqrt{a}\Big]}{h} = \lim_{h \to 0^{+}} \frac{\Big[\sqrt{a+h\sqrt{a}}-\sqrt{a}\Big]}{h}\cdot \frac{\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}{\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}$$
$$\lim_{h \to 0^{-}} \frac{h\Big[ah^2cos\big(\frac{1}{h}\big)+\sqrt{a}\Big]}{h} = \lim_{h \to 0^{+}} \frac{a+h\sqrt{a}-a}{h\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}$$
$$\lim_{h \to 0^{-}} \bigg[ah^2cos\Big(\frac{1}{h}\Big)+\sqrt{a}\bigg] \ = \ \lim_{h \to 0^{+}} \frac{a+h\sqrt{a}-a}{h\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}$$
$$\lim_{h \to 0^{-}} \bigg[ah^2cos\Big(\frac{1}{h}\Big)+\sqrt{a}\bigg] \ = \ \lim_{h \to 0^{+}} \frac{h\sqrt{a}}{h\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}$$
$$\lim_{h \to 0^{-}} \bigg[ah^2cos\Big(\frac{1}{h}\Big)+\sqrt{a}\bigg] \ = \ \lim_{h \to 0^{+}} \frac{\sqrt{a}}{\sqrt{a+h\sqrt{a}}+\sqrt{a}}$$
$$\lim_{h \to 0^{-}} \bigg[ah^2cos\Big(\frac{1}{h}\Big)+\sqrt{a}\bigg] \ = \ \lim_{h \to 0^{+}} \frac{\sqrt{a}}{\sqrt{a+h\sqrt{a}}+\sqrt{a}}\cdot \frac{\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}{\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}$$
$$\lim_{h \to 0^{-}} \bigg[ah^2cos\Big(\frac{1}{h}\Big)+\sqrt{a}\bigg] \ = \ \lim_{h \to 0^{+}} \frac{\sqrt{a}\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]}{\Big[\sqrt{a+h\sqrt{a}}+\sqrt{a}\Big]^2}$$
$$\sqrt{a} = \frac{\sqrt{a}\Big[\sqrt{a}+\sqrt{a}\Big]}{\Big[\sqrt{a}+\sqrt{a}\Big]^2}$$
$$\sqrt{a} = \frac{\sqrt{a}\Big[2\sqrt{a}\Big]}{\Big[2\sqrt{a}\Big]^2}$$
$$\sqrt{a} = \frac{2a}{4a}$$
$$\sqrt{a} = \frac{1}{2}$$
$$a=\frac{1}{4}$$
So we know $a=\frac{1}{4}$ and since we also know $b=\sqrt{a}$ needs to be true for the function to be continuous, we know $$b=\frac{1}{2}.$$
I know this seems more complicated than it needs to be, but there may be cases where you would need to show this using the limit definitions of what it means for a function to be continuous and differentiable.  Here is a site with a more thorough explanation of how to work through a problem like this and why you would want to do it this way.  The function is simpler though so the limits are much less complex.
https://jakesmathlessons.com/limits/solution-find-the-values-of-a-and-b-that-make-the-function-differentiable-everywhere/
