Determining domain and range Intro
I am trying to find a systematic method of finding the domain and range of a function. If I do find a successful method, I could potentially make a computer program that calculates domain and ranges.
I think my method would be best explained by an example.

Method
We have a function $ y = \cos(\arccos x) $, and I want to find the domain and range of this function.
I make the following table.
| expression  | domain      | range       |
|-------------|-------------|-------------|
|x            |(-inf,+inf)  |(-inf,+inf)  |
|arccos x     |[-1, 1]      |[0, pi]      |
|cos(arccos x)|[0, pi]      |[-1, 1]      |

Here is what I do:


*

*Plug in domain of previous range, and trim if needed. ex: range of x (-inf,+inf) -> domain of arccos x [-1, 1]

*Create range corresponding to function and given domain ex: domain of arccos x [-1, 1] -> [0, pi]

*Repeat steps 1 and 2 until whole function completed.


So my conclusion is that the domain and range of $y = \cos(\arccos x)$ are [0, pi] and [-1, 1] respectively.
However, I'm obviously incorrect. The domain should be [-1, 1].

Question
What's wrong with my logic (or, shall I say "illogic")?

 A: The domain of $(f \circ g)(x)$ is the set of $x$ such that $g(x)$ is the domain of $f(x)$. Your logic finds the set of $g(x)$ that is in the domain of $f(x)$. In order for us to get all the way back to $x$, we need to work backwards.
Start with the domain of $\cos(x)$, $\Bbb{R}$, and then find its intersection with the range of $\arccos x$, $[0, \pi]$. Clearly, this is $[0, \pi]$.
Now, find the set of $x$ such that $g(x) \in [0, \pi]$. In this case, since $[0, \pi]$ is the whole range, we know that the answer is the whole domain, or $[-1, 1]$, so we get the correct answer here. However, in general, this table is not enough information because had the set from the previous step been a subset of the full range, this simple table wouldn't have been able to help us and we would've needed to use the properties of the actual function to figure it out.
A: The domain of your "final" function is the domain of the first one, restricted on each step. 
Let's revisit your steps.

  
*
  
*Plug in domain of previous range, and trim if needed. ex: range of x (-inf,+inf) -> domain of arccos x [-1, 1]

So, the domain for $x$ should be so that the range is included in $[-1,1]$, so our domain is $[-1,1]$ by the moment.


  
*Create range corresponding to function and given domain ex: domain of arccos x [-1, 1] -> [0, pi]

Here, you determine the range of $\arccos$ based in the domain given, which is $[-1,1]$. Thus, the range is $[0,\pi]$.


  
*Repeat steps 1 and 2 until whole function completed.
  

The next step would be to restrict even more our initial domain (which is so far at $[-1,1]$). We do this as follows: which is the domain of $\cos$? it is $\Bbb R$ so our restriction on our previous range (which is $[0,\pi]$) is that it must be included in $\Bbb R$, and it is! so no change on our initial domain is needed, and it remains being $[-1,1]$.
Notice that $[0,\pi]$ is the domain of an intermediate function, and not from the initial function. That's where your contradiction comes from. 
