# Homework Help: Piece-wise function problem

1. May 19, 2010

### thereddevils

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

Function f and g are defined as follows :

f(R)=R , f(x)=x^2 , g(R)=R , g(x)=x+1,x>=0 , -x , x<0 (its a piecewise function) . Find fg(x) and gf(x) .

2. Relevant equations

3. The attempt at a solution

fg(x)=
(x+1)^2 , x>=0
x^2 , x<0

gf(x)=
x^2+1 , x>=0
-x^2 , x<0

Am i correct ? What are the things i will need to look into when face questions like this ? Cheking the domain ?

2. May 19, 2010

### phyzguy

Re: function

This looks correct to me.

3. May 19, 2010

### D H

Staff Emeritus
Re: function

If you mean f(g(x)) and g(f(x)) then what you have for f(g(x)) is correct, but the other is not.

4. May 19, 2010

### thereddevils

Re: function

thanks but why ? How did you see that ?

5. May 19, 2010

### D H

Staff Emeritus
Re: function

Show your steps on how you derived g(f(x)).

6. May 19, 2010

### thereddevils

Re: function

ok . Basically , i just substituted the function f(x) into the function g(x) , without doing any other checkings because i do not know what to check . Could you guide me on thsi ? Thanks .

7. May 19, 2010

### D H

Staff Emeritus
Re: function

Hint: Is f(x) ever negative?

8. May 19, 2010

### phyzguy

Re: function

Ah, based on DH's hint, I now agree that you have done g(f(x)) incorrectly. Thereddevils, do you see it now?

9. May 19, 2010

Re: function

thanks !