Combination of a piecewise defined function and a square function Let's say I have two functions, $f(x)=x^2$, and:
$$g(x)=
\begin{cases}
- 4 & x \leq 0\\
|x- 4| & x > 0
\end{cases}$$
Now I have to write combinations $f\circ g$ and $g\circ f$.
I think $f\circ g$ should be:
$$f\circ g(x)=
\begin{cases}
16 & x \leq 0\\
(x- 4)^2 & x > 0
\end{cases}$$
and $g\circ f$ should be $g\circ f(x)= |x^2- 4|$, considering that $x$ will always be positive, but now I don't get how would I graph these composite functions, and also how to check continuity at $x=0$, especially of $g\circ f$ since I just eliminated half part of it.

$f(x) = x^2$
$$
g(x) = \begin{cases}
         -4 & \text{if \(x \leq 0\)}\\
         |x - 4| & \text{if \(x > 0\)}
         \end{cases}
$$
You correctly found that
\begin{align*}
(f \circ g)(x) & = f(g(x))\\
               & = \begin{cases}
                   f(-4) & \text{if \(x \leq 0\)}\\
                   f(|x - 4| & \text{if \(x > 0\)}
                   \end{cases}
                   \\
              & = \begin{cases}
                  16 & \text{if \(x \leq 0\)}\\
                  |x - 4|^2 & \text{if \(x \geq 0\)}
                  \end{cases}
                  \\
              & = \begin{cases}
                  16 & \text{if \(x \leq 0\)}\\
                  (x - 4)^2 & \text{if \(x \geq 0\)}
                  \end{cases}          
\end{align*}

Since
\begin{align*}
\lim_{x \to 0^+} (f \circ g)(x) & = 16\\
\lim_{x \to 0^-} (f \circ g)(x) & = 16\\
\end{align*}
we obtain
$$\lim_{x \to 0} (f \circ g)(x) = 16$$
For a function to be continuous at $x = 0$, the limit as $x$ approaches $0$ must exist and the function must be equal to its limit when $x = 0$.  Since $(f \circ g)(0) = 16$,
$$\lim_{x \to 0} (f \circ g)(x) = (f \circ g)(0)$$
Thus, the function $f \circ g$ is continuous at $x = 0$.
Since $x^2 > 0$ unless $x = 0$, where $f(0) = 0$, we obtain
\begin{align*}
(g \circ f)(x) & = g(f(x))\\
               & = g(x^2)\\
               & = \begin{cases}
                   -4 & \text{if \(x^2 \leq 0\)}\\
                   |x^2 - 4| & \text{if \(x^2 > 0\)}
                   \end{cases}
                   \\
              & = \begin{cases}
                  -4 & \text{if \(x = 0\)}\\
                  |x^2 - 4| & \text{otherwise}
                  \end{cases}     
\end{align*}

Observe that
\begin{align*}
\lim_{x \to 0^+} (g \circ f)(x) = 4\\
\lim_{x \to 0^-} (g \circ f)(x) = 4
\end{align*}
Hence,
$$\lim_{x \to 0} (g \circ f)(x) = 4$$
Thus, the limit of the function exists at $x = 0$.  However, $(g \circ f)(0) = -4$.  Since
$$\lim_{x \to 0} (g \circ f)(x) \neq (g \circ f)(0)$$
the function $g \circ f$ is not continuous at $x = 0$ because it is not equal to its limit.  Since the continuity could be removed by defining $(g \circ f)(0) = 4$, which would require defining $g(x) = 4$ when $x = 0$, the function $g \circ f$ is said to have a removable discontinuity at $x = 0$.
