# Find the value of k such that the following function is differentiable at x=0

$$h(x)=\begin{cases} {4x+2x^2 \sin \left(\frac{1}{x}\right)}{} & \text{if x <0} \\[6pt] {x}\cdot{\cos(x)}+ kx & \text{if x\geq0} \\ \end{cases}$$

I know how to prove they are continuous but how do I show the function is differentiable? Any ideas please? I think $k=3$

Let $f$ be such a function, you may try to expand the details about \begin{align*} \lim_{h\rightarrow 0^{+}}\dfrac{f(h)-f(0)}{h}=\lim_{h\rightarrow 0^{-}}\dfrac{f(h)-f(0)}{h} \end{align*} and solve for $k$.

• Can't I differentiate both sides and put x=0 to find k? – nerv21 Dec 5 '17 at 19:48
• I guess you mean $\lim_{x\rightarrow 0^{+}}f'(x)=\lim_{x\rightarrow 0^{-}}f'(x)$, in this case, it works, but it needs some reasoning, but the safest way to do this question is the left-right limit of the difference quotient. – user284331 Dec 5 '17 at 19:51
• You can differentiate the expression on the right and plug in $0$, but that won't work for the expression on the left, which is not defined at $0$. And taking the limit of $f'(x)$ as $x \to 0^+$ has no guarantee of being correct. (Contrary to what @user284331 says, in this case it does NOT work. (I expect that user284331 just didn't check carefully; this shouldn't be controversial.)) – Toby Bartels Dec 5 '17 at 19:57
• (If you use, say, $4x$ instead of $4x + 2x^2 \sin(1/x)$ on the left, then it's OK to differentiate and plug in $0$, because even though that formula is only given to apply when $x < 0$, the fact that it has a derivative if extended to (and even beyond) $0$ means that the derivative that you get this way is the desired left-hand limit. But $4x + 2x^2 \sin(1/x)$ doesn't give you any result at $x = 0$.) – Toby Bartels Dec 5 '17 at 20:00
• @TobyBartels, I am sorry that I didn't check carefully, yes, the left side would cause some problem. So that's why I said the safest way is to deal with the both-sided difference quotient. – user284331 Dec 5 '17 at 20:03

Let $\Delta (x)=\frac{f (x)-f (0)}{x-0}$

with $f (0)=0.$

$$\lim_{0^-}\Delta (x)=\lim_{0^-}(4+2x\sin (1/x))=4$$ since $$|x\sin (1/x)|\le |x|$$

on the right,

$$\lim_{0^+}\Delta (x)=\lim_{0^+}(\cos (x)+k)=1+k$$

$f$ is differentiable at $0$ if $$1+k=4.$$