How to define an automorphism for $S_3 \times C_8$ in GAP? Consider the group $W:= S_3 \times C_8$. How can I define an automorphism for $W$? For example 
$f:W ‎\longrightarrow‎ W$; $f(x,y)=(x,y^{5}g(x))$ where $g:S_3 ‎\longrightarrow‎ C_2$ is defined as follows: $g(\sigma)=y^4$ if $\sigma$ is even and $g(\sigma)=id$ if $\sigma$ is odd, $x$ is arbitrary element of $S_3$, $y$ is an arbitrary element of $C_8$, and $a$ is the generator of $C_8$.
 A: The question has been unedited within 20 days. I've modified it trying to make the notation consistent enough to give an answer. 
First, let's create our groups:
gap> S3:=SymmetricGroup(3);
Sym( [ 1 .. 3 ] )
gap> C8:=CyclicGroup(8);
<pc group of size 8 with 3 generators>
gap> G:=DirectProduct(S3,C8);
<group of size 48 with 5 generators>
gap> Size(G);
48

Now, for a direct product there are associated Projection and Embedding operations:
gap> x:=Random(G);
DirectProductElement( [ (1,3), f1*f3 ] )
gap> Image(Projection(G,2),x);
f1*f3
gap> Image(Projection(G,1),x);
(1,3)
gap> Image(Embedding(G,1),(1,2,3));
DirectProductElement( [ (1,2,3), <identity> of ... ] )
gap> Image(Embedding(G,2),GeneratorsOfGroup(C8)[1]);
DirectProductElement( [ (), f1 ] )

We shall use these operations to construct $f$ from the question, but first we need to define $g$:
gap> g:=function(x) 
> if SignPerm(x)=1 then 
>   return GeneratorsOfGroup(C8)[1]^4;
> else
>   return One(C8);
> fi;  
> end;    
function( x ) ... end

Now create f as follows:
gap> f:=function(h)
> local p1, p2, e1, e2, x, y;
> p1:=Projection(G,1);
> p2:=Projection(G,2);
> e1:=Embedding(G,1);
> e2:=Embedding(G,2);
> x:=h^p1;
> y:=h^p2;
> return x^e1 * (y^5*g(x))^e2;
> end;
function( h ) ... end

Then call GroupHomomorphismByFunction:
gap> aut:=GroupHomomorphismByFunction(G,G,f);
MappingByFunction( <group of size 48 with 5 generators>, 
<group of size 48 with 5 generators>, function( h ) ... end )

Attention: It is documented in GroupHomomorphismByFunction entry in the GAP manual that "No test is performed on whether the functions actually give an homomorphism between both groups because this would require testing the full multiplication table."
In this case we may check it ourselves and see that f is not a homomorphism at all:
gap> ForAll(Tuples(G,2),t -> t[1]^aut*t[2]^aut = (t[1]*t[2])^aut);
false

Oops! Let's modify $f$ as follows: $f(x,y) = (x,a^4 y g(x))$:
gap> f1:=function(h)
> local p1, p2, e1, e2, x, y, a;
> p1:=Projection(G,1);
> p2:=Projection(G,2);
> e1:=Embedding(G,1);
> e2:=Embedding(G,2);
> x:=h^p1;
> y:=h^p2;
> a:=GeneratorsOfGroup(C8)[1];
> return x^e1 * (a^4*y*g(x))^e2;
> end;
function( h ) ... end

and try to create another homomorphism:
gap> aut1:=GroupHomomorphismByFunction(G,G,f1);
MappingByFunction( <group of size 48 with 5 generators>, 
<group of size 48 with 5     generators>, function( h ) ... end )

Now we have an automorphism:
gap> ForAll(Tuples(G,2),t -> t[1]^aut1*t[2]^aut1 = (t[1]*t[2])^aut1);
true
gap> Source(aut1)=G;
true
gap> Image(aut1)=G;
true

Moreover, it is properly recognised as an element of AutomorphismGroup(G):
gap> A:=AutomorphismGroup(G);
<group of size 48 with 5 generators>
gap> aut1 in A;
true

Remark: as we may see, it is potentially unsafe to use GroupHomomorphismByFunction since it returns a MappingByFunction and does not check whether it is a homomoprhism. To use it, one has to be sure that the mapping indeed is a homomorphism. I'd prefer to use GroupHomomorphismByImages where images of generators would be calculated using functions similar to f above (which may also take extra arguments in this case, since it does not need to comply with GroupHomomorphismByFunction syntax). A simple example is:
gap> gens:=GeneratorsOfGroup(G);;
gap> aut2:=GroupHomomorphismByImages(G,G,gens,List(gens,w->w^aut1));
[ DirectProductElement( [ (1,2,3), <identity> of ... ] ), 
  DirectProductElement( [ (1,2), <identity> of ... ] ), DirectProductElement( [ (), f1 ] ), 
  DirectProductElement( [ (), f2 ] ), DirectProductElement( [ (), f3 ] ) ] -> 
[ DirectProductElement( [ (1,2,3), <identity> of ... ] ), DirectProductElement( [ (1,2), f3 ] ), 
  DirectProductElement( [ (), f1 ] ), DirectProductElement( [ (), f2 ] ), 
  DirectProductElement( [ (), f3 ] ) ]

Now we see that it works with aut1, but it does not work with aut which is not a homomorphism:
gap> aut3:=GroupHomomorphismByImages(G,G,gens,List(gens,w->w^aut));
fail

It remains only to check that 
gap> Image(aut2)=G;
true

to see that we've constructed the desired automorphism. And indeed,
gap> aut2 in A;
true

