In highschool, functions are often defined like this (example): $$f(x)=x^3-x+3$$ But on the wikipedia page of a mathematical function I read that this is not a formal way of defining a function, but rather just the function $f$ applied to $x$, or something along those lines.
Now I was wondering whether the above mentioned way is a valid way of defining a function as some kind of short form or shorter way or whether it is actually wrong to say that this is a function definition. And why is this way of defining functions used in highscool if it's wrong? And is there maybe a compromise between the completely formal and this kind of informal definition?
From a formal perspective, the only thing wrong with this definition is that we have not specified the domain and codomain of the function. For instance, if we were thinking about this function in calculus, we might want to toss in a $f:\mathbb R\to\mathbb R$ to make it clear that this function would input and output real numbers. But if we were in number theory, we might want it to be $f:\mathbb Z\to\mathbb Z$ to specify that only integer inputs and outputs were desired.