Using the differentiation rules and the derivative table, find the derivative of the function y=|x^2-2x-3|



y'=(2x-2)\cdot\text{sgn}(x^2 - 2x - 3 )


First, we write the function without a modulus. For this it is necessary to study the sign of its argument

  • Studying the sign of the absolute value argument


    Let’s start by studying the equation:

    x^2 - 2x - 3 = 0


    Ìt is a quadratic equation of type ax^2+bx+c=0, so it has solutions only if the discriminant

    \Delta = b^2 - 4ac


    is positive or zero. In our case a = 1, b = -2 and c = -3 therefore

    \Delta = (-2)^2 - 4 \cdot 1 \cdot (-3) = 4 + 12 = 16


    The roots of the equation are given by the formula

    x = \frac{-b \pm \sqrt\Delta}{2a}


    or

    x = \frac{2 \pm \sqrt{16}}{2} = \frac{2 \pm 4}{2}


    Simplifying we find:

    x = 3 \quad \text{and} \quad x = -1


    Since a>0, the sign of the polynomial is positive for -1 and 3, and is negative when x and x>3, and it is negative for the internal values 1:

    \text{sgn}(x^2 - 2x - 3 ) =\begin{cases} 1 & \text{if } x < -1 \text{ or } x > 3 \\ -1& \text{if } -1 < x < 3 \end{cases}


  • Function expression without absolute value

    y = |x^2 - 2x - 3| = \begin{cases} x^2 - 2x - 3 & \text{if } x < -1 \text{ or } x > 3 \\ -(x^2 - 2x - 3) & \text{if } -1 < x < 3 \end{cases}


  • Calculating the derivative

  • We note that in x=-1 e x=3 we cannot use the differentiation theorems because the analytic expression of the function is different on the left and right of each of the two values. We can instead use the rules on each open interval


    - For x\in (-\infty, -1) \cup (3,+\infty):

    y = x^2 - 2x - 3 \implies y' = 2x - 2


    - For x\in (-1, 3):

    y = -(x^2 - 2x - 3) = -x^2 + 2x + 3 \implies y' = -2x + 2



  • Conclusion

  • The derivative of the function y = |x^2 - 2x - 3| for x\neq -1 and x\neq 3 is:

    y' = \begin{cases} 2x - 2 & \text{if } x < -1 \text{ or } x > 3 \\ -2x + 2 & \text{if } -1 < x < 3 \end{cases}


    which we can also write compactly as

    y'=(2x-2)\cdot\text{sgn}(x^2 - 2x - 3 )

Warning!

The function is not differentiable at the points  x = -1 and  x = 3 , that is f'(-1) and f'(3) do not exist.

To support this statement, we use the definition of derivative: let's see how it works in the case of x=3. Let f be our function, recalling its expression


            f(x) = |x^2 - 2x - 3| =
            \begin{cases}
            x^2 - 2x - 3 & \text{if } x < -1 \text{ or } x > 3 \\
            -(x^2 - 2x - 3) & \text{if } -1 < x < 3
            \end{cases}


For \Delta x=h\neq 0, the variation of the function is



            f(3+h)-f(3)=
            \begin{cases}
            (3+h)^2 - 2(3+h) - 3 & \text{if } h > 0\\
            -[(3+h)^2 - 2(3+h) - 3] & \text{if } h < 0
            \end{cases}


Here, we are using the fact that f(0)=0, and that f is calculated as follows: for values greater than three, that is, when h >0, f is read from the first line, whereas when h the input of f is less than three, so we read f from the second line. We can think of h as small, since we will study the limit as h approaches 0. By carrying out the calculations, we arrive at  


            f(3+h)-f(3)=
            \begin{cases}
            h^2+4h & \text{if } h >0 \\
             -h^2-4h & \text{if } h < 0  
            \end{cases}


Thus, the difference quotient of f at x=3 is



            \frac{f(3+h)-f(3)}{h}=
            \begin{cases}
            h+4 & \text{if }h > 0\\
             -h-4 & \text{if } h < 0  
            \end{cases}


Now we study the limit as h approaches zero: we notice that the right-hand limit (i.e., for positive values of h) is 4. On the other hand, the left-hand limit is -4.
This means that the limit of the difference quotient does not exist


\lim_{h\to 0}\frac{f(3+h)-f(3)}{h}\qquad \text{does not exist} 


We therefore conclude that f is not differentiable at x=3.}

With the same type of reasoning we study the case x=-1.