How is this $K$-automorphism well-defined? I'm currently reading Hungerford algebra's chapter about Galois theory, I cannot understand the following example

Let $F=K(x)$ with $K$ any field. For each $a\in K$ with $a\neq 0$ the map $\sigma_a:F\to F$ given by $f(x)/g(x)\mapsto f(ax)/g(ax)$ is a $K$-automorphism of $F$

By $K(x)$, he means not the quotient field of the polynomials in one variable in $K$ but the smallest field containing $K$ and $x$ (otherwise he wouldn't put $f(x)/g(x)$ but $f/g$)
But if we set $K=Q$, $x=i$, $a=2$ and $f(X)=X^2+1, g(X)=1$, then $0=f(i)/1\mapsto ((2i)^2+1)/1=-3$, thus $\sigma_a$ is not well-defined.
What am I missunderstanding?
 A: In order that the map $\sigma_a$ is well defined, it's necessary that $x$ is transcendental over $K$.
Your example precisely shows this. More generally, if $x$ is a root of the polynomial $f(X)$, also $ax$ should be a root of $f$, for every $a\in K$, $a\ne0$: this is impossible over an infinite field.
In the case where $x$ is transcendental, the map $\sigma_a$ can be defined in two steps. First we consider the unique ring homomorphism $\varphi\colon K[x]\to K(x)$ such that $\varphi(\alpha)=\alpha$, for $\alpha\in K$, and $\varphi(x)=ax$. Then $f$ admits a unique extension to a ring homomorphism $\sigma K(x)\to K(x)$, by $\sigma_a(f(x)/g(x))=\varphi(f(x))/\varphi(g(x))$.
This is a $K$-homomorphism by definition. It is an automorphism, because $\sigma_{a^{-1}}$ is its inverse.

Suppose $f(x)=0$, for $x$ algebraic over $K$, with $f\in K[X]$, $f\ne0$, monic and minimal: $f(x)=b_0+b_1X+\dots+b_{n-1}X^{n-1}+X^n$
If $ax$ is a root of $f$ for every $a\in K$, $a\ne0$, then, for $a\ne0$,
$$
g(X)=
\frac{b_0}{a^n}+\frac{b_1}{a^{n-1}}X+\dots+\frac{b_{n-1}}{a}X^{n-1}+X^n
$$
has $x$ as a root, so
$$
b_0=a^nb_0, b_1=a^{n-1}b_1,\dots, b_{n-1}=ab_{n-1}
$$
Since $b_0\ne0$, this means $a^n=1$, for all $a\in K$, $a\ne0$. Therefore $K$ is a finite field and $n=|F|-1$.
But then, $a^{k}\ne 1$ for some $a\ne0$, whenever $0<k<n$, so we conclude that $f(X)=X^{n}+b_0$, which seems to be quite a restrictive setup, not intended in the statement of the example.
