An example of the spectrum functor Let $A,B,$ and $R$ be $k$-algebras. There is a functor from the category of $k$-algebras to the category of sets, called $\operatorname{Spec}A$, defined by $R\mapsto\operatorname{Hom}_{k\text{-alg}}(A;R)$. If $f: A\rightarrow B$ is a $k-$algebra homomorphism, then there is also the induced map $\operatorname{Spec}B(R)\rightarrow\operatorname{Spec}A(R)$ given by $\phi\in\operatorname{Spec}B(R)=\operatorname{Hom}_{k\text{-alg}}(B;R)\mapsto\phi\circ f\in \operatorname{Spec}A(R)=\operatorname{Hom}_{k\text{-alg}}(A;R).$
I'm trying to work out the following example. Let $A=k[x],B=k[y_1,\dots,y_n]$. Define $f: k[x]\rightarrow k[y_1,\dots,y_n]$ by $x\mapsto h(y_1,\dots,y_n)$. In this case $\operatorname{Spec}A(R)=R, \operatorname{Spec}B(R)=R^n$ and the induced map $R^n\rightarrow R$, according to what I was told, must be given by the formula $(r_1,\dots,r_n)\mapsto h(r_,\dots,r_n)$. But I don't see why this is true. What I see is that since $\operatorname{Spec}B(R)=\operatorname{Hom}_{k\text{-alg}}(B;R)$ and $\operatorname{Spec}A(R)=\operatorname{Hom}_{k\text{-alg}}(A;R)$ and assuming the definition of the induced map, it should be given by $\phi \mapsto \phi\circ f$. How one obtains $(r_1,\dots,r_n)\mapsto h(r_,\dots,r_n)$?
 A: You should figure out the identification
\begin{align*}
\operatorname{Hom}_{k\text{-alg}} (k [Y_1, \ldots, Y_n], R) & \cong \operatorname{Hom}_{\text{Set}} (\{Y_1, \ldots, Y_n\}, R) \cong R^n,\\
\phi & \mapsto (\phi (Y_1),\ldots,\phi (Y_n))
\end{align*}
—since $k [Y_1, \ldots, Y_n]$ is the free $k$-algebra on generators $Y_1,\ldots,Y_n$, a morphism $\phi\colon k [Y_1, \ldots, Y_n]\to R$ is determined by its values $(\phi (Y_1), \ldots, \phi (Y_n)) = (r_1,\ldots,r_n) \in R^n$. The same way, a morphism $k[X]\to R$ is determined by its value on $X$, i.e. an element of $R$:
\begin{align*}
\operatorname{Hom}_{k\text{-alg}} (k [X], R) & \cong R,\\
\psi & \mapsto \psi (X).
\end{align*}
Now a morphism $\phi\colon k [Y_1, \ldots, Y_n]\to R$ indeed corresponds to the composition $\phi\circ f\colon k[X] \to k [Y_1, \ldots, Y_n]\to R$, and we have
$$\phi \circ f (X) = \phi (h (Y_1,\ldots,Y_n)) = h (\phi (Y_1),\ldots,\phi (Y_n)) = h (r_1,\ldots,r_n).$$

P.S. By the way, a morphism $A\to B$ induces a natural transformation of functors $\operatorname{Hom}_{k\text{-alg}} (B,-) \Rightarrow \operatorname{Hom}_{k\text{-alg}} (A,-)$.
