# Working with Function Domain

Consider $f(x)=x^2+1$ and $g(x)=\sqrt{x-1}$. Note that $(f\circ g)(x)=x$ and this checks in Mathematica.

Clear[f, g, x]
f[x_] = x^2 + 1;
g[x_] = Sqrt[x - 1];
f[g[x]]


The output is:

x


However, the domain of this function (using real numbers) is $D=[1,\infty)$, but Mathematica's FunctionDomain (probably working with complex numbers),

FunctionDomain[f[g[x]],x]


returns:

True


Which means all real numbers. Any way to get this command to focus on the reals?

I found one way:

Clear[f, g, x]
f[x_] = x^2 + 1
g[x_] = Surd[x - 1, 2]


Then,

FunctionDomain[f[g[x]], x]


returned $x\ge 1$.

Any other way?

Clear[f, g, x]
f[x_] := x^2 + 1;
g[x_] := Sqrt[x - 1];


Possible approach:

FunctionDomain[{f[g[x]], g[x] >= 0}, x]
(* x >= 1 *)


More general:

FunctionDomain[{f[g[x]], Element[g[x], Reals]}, x]
(* x >= 1 *)

• Very helpful alternatives. Thanks. Mar 18 '16 at 19:20
• @David Glad it was useful.
– user31159
Mar 18 '16 at 20:50
• I'm thinking what happened with my original question is that Mathematica evaluates f(g(x)), looks at the final answer, then finds the domain of the result. So, I'm currently thinking that if I want my algebra students to use Mathematica to check the domain of the composition of two functions, the best approach would be to first check the domain of g, then the domain of $f\circ g$. Mar 18 '16 at 21:34
• @David Yes, FunctionDomain do not have an attribute of the form HoldXXX, so its internal definition will be used after the evaluation of f[g[x]] only. So in the end it fires as FunctionDomain[x, x]. The same thing happens in my propositions, but we kept the domain of definition of g in the process by adding a constraint in the input. I agree with your alternative, first FunctionDomain could be checked on g, and then the domain obtained could feed the FunctionDomain of f in the constraints part.
– user31159
Mar 18 '16 at 22:08