How can I specify the domain of a function symbolically?

Assume I have a very simple linear function.

$f(x)=2x$

If I want to say that the domain of this function is all the real numbers, how would I write this with symbols? Do I need to use set-builder notation? What would the set-builder notation for something like this look like? What other notations are available?

I suppose I could just write "for all real x" followed by the function, like in course text books and on tests. But I want to learn the formal, symbolic way of writing this with less words. Because I know I will have to learn it sooner or later in my studies. I would prefer sooner. My teachers are holding back on this, as if I am not prepared for these fancy symbols yet or some nonsense like that. Or maybe they just don't know it themselves...

If there is no mention of what the domain of the function is, is it always assumed to be the real number set then? Implicit domain definition, eh? What about explicit then?

One way I can think of is writing something like this.

$ \displaystyle f(x)=2x|x\in\Bbb{R}$

Is this unconventional?

Another way I could think of is something like this.

$D=\left\{\Bbb{R}\right\}$

I use the upper case D to mean "domain". This is now a set of all real numbers, referenced by "D". But how do I connect the domain to the function rule? What is the notation for this?

I am thinking about doing something like this.

$D=\left\{x|x\in\Bbb{R}\right\}$

Is this legit? How else would I connect the domain set to the function rule?

$f:X\to Y$

Is this what I am looking for in fact? I have seen notations like this on the web, on Wikipedia, among other places.

How is this interpreted? My understanding is that X and Y are two sets, and this is read as "X to Y", relating set X to set Y. Does the colon carry any special meaning? The lower case "f" is the name of the function, of course. So upper case X and Y letters are used for the related sets, and lower case x and f(x) for the discrete values within these sets?

So my set D would correspond to the set X in this example, correct? It's the domain set?

What about the Y or the f(x)? How do I describe this with symbols?

If there are no constraints on Y, then the function is defined for all discrete x values of set X?

$Y=\left\{f(x)\right\}$

Something like that?... maybe?

What are your thoughts? Am I on the right track or am I completely lost? Perhaps if someone were to write a few examples for me I would better understand this notation. It doesn't seem too hard, but my teachers won't hear of it. So I have to rely on the web as my teacher.

And what's the deal with x values equal to zero?

Here is a very simple example.

$g(x)=1/x$

I understand we are not supposed to divide by zero, because that would mean the end of the universe. But when writing down the domain of such function, my teachers always just state the following.

$x\neq 0$

Is this really the "domain" of the function? Because I thought the "domain" of a function was supposed to tell us what x values the functiondefined for, not what x values itisdefined for. Isn't this wrong?is not

The domain is supposed to include "what is", not "what is not". Or am I wrong? The x equal to zero is a point of exclusion, not inclusion.

Who cares what x values the function isn't defined for? If I know what x values itisdefined for then I can easily figure out what x values it is not defined for. Especially when there is only a single point at which the function isnotdefined.

So this is really a short hand version of something more formal like this.

$D=\left\{x|x\in\Bbb{R}, x\neq 0\right\}$

Or simply like this.

$D=\left\{\Bbb{R}, x\neq 0\right\}$

But this can also be described alternatively, like this.

$D=\left\{x|x\in\Bbb{R}, x\lt 0 \quad \text{and} \quad x\gt 0\right\}$

Or simply like this.

$D=\left\{x\lt 0 \quad \text{and} \quad x\gt 0\right\}$

So my question is this! Are these exclusion points supposed to be defined as part of the domain of a function?