A problem on compositions of functions

72 Views Asked by At

$$f(x) = \begin{cases} x-1 & x \geq 0 \\ 1-x & x <0 \end{cases}$$

$$g(x) = \begin{cases} x& x\geq 0 \\ x^2 & x < 0 \end{cases}$$

It asks me for the compositions $f(g(x))$.

What I did: it seemed easy to me, since

$$f(g(x)) = \begin{cases} x-1 & x \geq 0 \\ 1-x^2 & x < 0 \end{cases}$$

$$g(f(x)) = \begin{cases} x-1 & x \geq 0 \\ (1-x)^2 & x < 0 \end{cases}$$

Instead in the solution there is:

$$g(f(x)) = \begin{cases} 1-x & x < 0 \\ (x-1)^2 & 0 \leq x < 1 \\ x-1 & x \geq 1 \end{cases}$$

I don't get that solution. Some clarifications?

1

There are 1 best solutions below

2
On BEST ANSWER

Hint. To see why your answer $$ (\color{red}{\times}) \qquad f(g(x)) = \begin{cases} x - 1 & \text{if } x \ge 0, \\ 1 - x^2 & \text{if } x < 0 \end{cases} $$ is incorrect, consider $f(g(-2))$. Clearly $$ g(-2) = (-2)^2 = 4, $$ so $$ f(g(-2)) = f(4) = 4 - 1 = 3. $$ However, your answer suggests that $$ (\color{red}{\times}) \qquad f(g(-2)) = 1 - (-2)^2 = -3. $$ Try to identify the mistake that caused this discrepancy. Then, use this understanding to fix your expressions for $f(g(x))$ and $g(f(x))$.

Here's an additional hint in case you cannot find the mistake.

When evaluating $f(g(x))$ using the piecewise definition of $f$, we need to case on whether $g(x) \ge 0$ or $g(x) < 0$ rather than case on whether $x \ge 0$ or $x < 0$. The variable $x$ in the expression $f(g(x))$ is not the same variable as the variable $x$ in the expression $f(x)$. In other words, when evaluating $f(g(\color{red}{x}))$ using the definition $$ f(\color{blue}{x}) = \begin{cases} \color{blue}{x} - 1 & \text{if } \color{blue}{x} \ge 0, \\ 1 - \color{blue}{x} & \text{if } \color{blue}{x} < 0, \end{cases} $$ we are making the variable binding $\color{blue}{x} = g(\color{red}{x})$ so that $f(\color{blue}{x}) = f(g(\color{red}{x}))$. The variables $\color{red}{x}$ and $\color{blue}{x}$ are distinct and should not be conflated.