# Domain and codomain of a function

I am wondering if it is possible to get domain and codomain of a function in Mathematica (by using only built-in functions if possible). For example, I would like to give as input the function $$tan(x)$$ and to obtain the output "domain" $$x \neq \frac{\pi}{2} + k \, \pi$$ with $$k$$ integer, and "codomain" $$R$$.

Thank you so much for your willingness.

You can use FunctionDomain and FunctionRange:

FunctionDomain[Tan[x], x]


1/2 + x/π ∉ Integers

FunctionRange[Tan[x],x,y]


True

FunctionRange[Sin[x], x, y]


-1 <= y <= 1

• how the answer $$1/2 + x/π ∉ \mathbb{Z}$$ is related to the right result $$x ≠ π / 2 + k π$$?

The two expressions are equivalent: Move $$\pi/2$$ to the lhs and divide both sides of the second expression by $$\pi$$ to get $$x/π - 1/2 ≠ k$$ ($$k$$ integer).

• Why does Mathematica return the first expression (not the second) as the answer?

The first one is simpler by LeafCount:

1/2 + x/π ∉ Integers // LeafCount


11

ForAll[k, Element[k, Integers], x != k + π/2] // LeafCount


14

• Hello @kglr thank you for your extremely clear reply. True means R or C? – Gennaro Arguzzi Nov 8 '18 at 8:48
• @Gennaro, my pleasure. Thank you for the accept. – kglr Nov 8 '18 at 8:49
• True means R or C? – Gennaro Arguzzi Nov 8 '18 at 8:50
• @GennaroArguzzi, i think it means Reals. – kglr Nov 8 '18 at 9:08
• Hi @kglr, I have another doubt: how the answer 1/2 + x/π ∉ Integers is related to the right result $x \neq \frac{\pi}{2} + k \, \pi$? – Gennaro Arguzzi Nov 10 '18 at 6:21