Relatively free algebras in a variety generated by a single algebra Suppose $A$ is an algebra of signature $\mathcal{L}$ and $V=Var(A)$ is the variety generated by $A$. I want to know is it possible to classify relatively free elements of $V$? As a special case, for a group $G$, under what conditions $G$ is free in $Var(G)$?
 A: Suppose that $A$ is a finite universal algebra with minimal cardinality of a generating set $d$.  Then $A$ is relatively free in some variety iff it is relatively free on $d$ generators in the variety it generates, in which case it is free on any generating set of $d$ elements.  Moreover, this occurs iff each map from a fixed $d$-element set generating $A$ to $A$ extends to an endomorphism.
It is easy to check that if $A$ is relatively free in some variety then it is relatively free in $Var(A)$.  Next note that if $A$ is relatively free on $k$ generators, then the cardinality of $Hom(A,A)$ is $|A|^k$.  On the other hand, $|Hom(A,A)\leq |A|^d$ and so $k\leq d$.  But $d$ was minimal, so $A$ is free on $d$ generators.  Also note that if $X$ is a free set of $d$-generators, then we can map $X$ to any other set of $d$-generators and this extends to a surjective homomorphism which is injective by finiteness.  So all $d$-element generating sets are free generating sets.
Clearly if $A$ is relatively free on $d$ generators, then any map from a $d$-element generating set (necessarily a free generating set) to $A$ extends to an endomorphism.  Suppose the converse holds.  Let $B$ be the free algebra on $d$ generators in the variety generated by $A$. It is well known that $B$ embeds in a finite product $A^m$ where $m=|A|^d$.  Let $g_i\colon B\to A$ be the projection to the $i^{th}$ factor.  If $f$ is the map taking the $d$ generators of $A$
to the free generators of $B$, then we can extend $g_if$ to an endomorphism $h_i$ of $A$ by hypothesis on $A$.  The product $h$ of these $h_i$ gives a homomorphism of $A$ to $A^m$ sending the generators of $A$ to the generators of $B$.  Hence $h$ splits the canonical surjection $B\to A$.
Added. This last argument doesn't require finiteness. A universal algebra $A$ is relatively free if and ony if it has a generating set $X$ such that each map from $X$ to $A$ extends to an endomorphism. 
A: More general than my comment above, but still only a partial answer: Notice that $\text{Var}(A)$ is generated by any $B\in\text{Var}(A)$ that has $A$ as a subalgebra (or quotient, or subquotient).  It would seem that only in very special varieties would all such $B$'s be free.
A: Free algebras of $V(\textbf{A})$ lie in $SP(\textbf{A})$ (subalgebra of product).  Unless your algebra is trivial or very special,  I do not see a better characterization of free algebras forthcoming.
