I need to find the parametrs a1 and a2 so that the function is differantiable (derivable).I put the condition for it to be continuos and down below is what i found.Im getting stuck however at the last part when finding the parameters,because I'll have -1=1 for a2.Am I putting the conditions wrong?

differentiable function with parameters
82 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 2 best solutions below
On
The function is always continuous.
Lets assume $a_1 \lt a_2$. The function: $$ f(x)=x|x-a_1|+|x-a_2|= \begin{cases} -x^2+(a_1-1)x+a_2 & x\in(-\infty,a_1] \\ x^2-(a_1+1)x+a_2 & x\in(a_1,a_2] \\ x^2-(a_1-1)x-a_2 & x\in(a_2,\infty) \end{cases} $$ has piecewise derivative: $$ \frac{df}{dx}= \begin{cases} -2x+a_1-1 & x\in(-\infty,a_1) \\ 2x-a_1-1 & x\in(a_1,a_2) \\ 2x-a_1+1 & x\in(a_2,\infty) \end{cases} $$
Lets assume $a_2 \lt a_1$. The function: $$ f(x)=x|x-a_1|+|x-a_2|= \begin{cases} -x^2+(a_1-1)x+a_2 & x\in(-\infty,a_2] \\ -x^2+(a_1+1)x-a_2 & x\in(a_2,a_1] \\ x^2-(a_1-1)x-a_2 & x\in(a_1,\infty) \end{cases} $$ has piecewise derivative: $$ \frac{df}{dx}= \begin{cases} -2x+a_1-1 & x\in(-\infty,a_2) \\ -2x+a_1+1 & x\in(a_2,a_1) \\ 2x-a_1+1 & x\in(a_1,\infty) \end{cases} $$ In both cases, the function derivative is continuous iff: $$ -a_1-1=a_1-1, \\ 2a_2-a_1-1=2a_2-a_1+1 $$ From the first equation $a_1=0$. The second equation, never can be satisfied. Here no values of $a_1,a_2$ make the function derivable everywhere.
If both values are equal, the middle branch dissapears, and we only have: $$ -a_1-1=2a_1-a_1+1 $$ which leads to the correct solution $a_1=a_2=-1$
$$ \blacksquare $$
Trying to deal with $f$ as a piecewise defined function can be a bit tedious. You have to consider the cases that $a_1 < a_2$, $a_1 > a_2$, and $a_1 = a_2$. Instead, think about what the sum rule for derivatives tells you. If $g$ is differentiable at $a$, and $h$ is not differentiable at $a$, then $f = g+h$ is not differentiable at $a$. Do you see why? If $f$ were differentiable at $a$, then $h = f-g$ is the difference of two functions that are differentiable at $a$, so it would have to be differentiable at $a$, contradiction.
Apply that idea to this function. Let $g(x) = x|x-a_1|$ and $h(x) = |x-a_2|$. Then $g$ is differentiable for all $x\neq a_1$, but not at $a_1$, and $h$ is differentiable for all $x\neq a_2$, but not at $a_2$. So if $a_1$ and $a_2$ are different, $f$ will not be differentiable at $a_1$ or $a_2$. For instance, here is the graph of $f$ when $a_1 = -1$ and $a_2 = 1$. You can see the two kinks at $a_1$ and $a_2$.
If $a_1 = a_2$, then $f(x) = (x+1)|x-a_1|$. The first factor is differentiable for all $x$, and the second for all $x\neq a_1$. So we only need to check if $f'(a_1)$ exists.
$$ f'(a_1) = \lim_{x\to a_1} \frac{(x+1)|x-a_1|}{x-a_1} = \lim_{x\to a_1} (x+1) \frac{|x-a_1|}{x-a_1} $$ As $x$ approaches $a_1$ from above, the right factor is $+1$, and as $x$ approaches $a_1$ from below, the right factor is $-1$. So \begin{align*} \lim_{x\to a_1^+} (x+1) \frac{|x-a_1|}{x-a_1} &= a_1 + 1\\ \lim_{x\to a_1^-} (x+1) \frac{|x-a_1|}{x-a_1} &= -(a_1 + 1) \end{align*} The function $f$ is differentiable at $a_1$ if and only if $a_1 + 1 = -(a_1 +1)$, or $a_1 = -1$. Compare the graphs of $f$ when $a_1=a_2 = 1$ and $a_1=a_2 = -1$. In the second case, there is a horizontal tangent line at $(-1,0)$.