The cosine function has a range of #[-1,1]#, meaning the inverse cosine function has a domain of #[-1,1]#. The reason #cos(arccos(3pi))# is undefined is because #arccos(3pi)# is undefined, as #3pi# is outside of the domain for #arccos#.

To put it another way, #arccos(x)# is a value such that #cos(arccos(x))=x#. If #|x|>1#, then no such value exists within the real numbers.

Note in the following graph #y=arccos(x)# that #arccos# is only defined for #-1<=x<=1#.

graph{arccos(x) [-2, 2, -1, 4]}

There is no problem for the second one, as #cos(2pi)=1#, which is within the domain of #arccos#. #arccos(cos(2pi)) = arccos(1)#, which is a value such that #cos(arccos(1)) = 1#.

Because there are infinitely many values #x# such that #cos(x) = 1#, we need to make some restriction to make #arccos(1)# produce a unique result. The restriction used is #0 <= arccos(x) <= pi#. Note again within the above graph that the maximum value for #y# is #pi# and the minimum value for #y# is #0#.

Within the interval #[0,pi]#, the only value #x# such that #cos(x)=1# is #x=0#. Thus, we see why the second result occurs:

#arccos(cos(2pi)) = arccos(1) = 0#