# Piece wise function

1. Apr 23, 2010

### thereddevils

1. The problem statement, all variables and given/known data

Given that f(R)=R , g(R)=R be defined respectively by

$$f(x)=\begin{cases} \sin x+2 & \text{if } x>1 \\ \cos x-2 & \text{if } x\leq 1\end{cases}$$

$$g(x)=\begin{cases}2x+3& \text{if } x>0 \\ x^2 & \text{if } x\leq 0 \end{cases}$$

Find f o g and g o f

2. Relevant equations

3. The attempt at a solution

i have no idea to begin except for the obvious substitution of g(x) into the function f(x) . I am not sure how to adjust the domain .

2. Apr 23, 2010

### rock.freak667

For x>1, wouldn't f(x) = sinx +2 and g(x)=2x +3 ?

3. Apr 23, 2010

### HallsofIvy

Staff Emeritus
You need to be careful of the domains. If $x\le 0$, $g(x)= x^2$ but then $x^2< 1$ if x> -1 and $x^2> 1$ if x< -1.

If x> 0, $g(x)= 2x+ 3$ and, since x is positive, that is always larger than 3 which is larger than 1.

You need to divide into three intervals: for x<-1, $g(x)= x^2> 1$ so $f(g(x))= f(x^2)= sin(x^2)+ 2$. for $-1\le x\le 0$, $g(x)= x^2\le 1$ so $f(g(x))= f(x^2)= cos(x^2)- 1$. For x> 0, g(x)= 2x+ 3 and f(g(x))= f(2x+3)= sin(2x+3)+ 2.

Now, you do g(f(x))

4. Apr 23, 2010

thanks !