# 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.

• Be careful, $f(0) = 0$, so $(g \circ f)(0) = g(0)$. Nov 25, 2020 at 19:11
• @N.F.Taussig and what about the values less than x for g o f? Nov 26, 2020 at 3:54
• I do not understand the question you wrote in the comments. Nov 26, 2020 at 9:44
• @N.F.Taussig if 0 and all numbers greater than 0 are in the domain of gof will i still plot the graph for the part when x would be negative Nov 26, 2020 at 9:49
• All real numbers are in the domain of $g \circ f$. Notice that $(g \circ f)(0) = g(f(0)) = g(0^2) = g(0) = -4$. For any other value of $x$, $f(x) = x^2 > 0$, so $(g \circ f)(x) = g(f(x)) = g(x^2) = |x^2 - 4|$. Nov 26, 2020 at 9:53

$$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$$.

• Thank you soo much i have been stuck for a long time.. Just i dont get one thing .. How did you do the step right above the 2nd graph... The one where you have written otherwise Nov 26, 2020 at 12:16
• We know that $f(x) \geq 0$, with equality holding if and only if $x = 0$. Thus, when $x = 0$, $f(x) \leq 0$, so $(g \circ f)(0) = g(f(0)) = g(0) = -4$. If $x \neq 0$, then $f(x) = x^2 > 0$, so $(g \circ f)(x) = g(x^2) = |x^2 - 4|$. Nov 26, 2020 at 15:13
• Thank you ..got it Nov 27, 2020 at 6:12