then rt(x) == rt(y). For instance, rt(6) = 7. However, we cannot say any such thing for ro because it uses a global variable that it modifies. The referential opacity of ro makes reasoning about programs more difficult. For example, say we wish to reason about the following statement: int i = ro(x) + ro(y) * (ro(x) - ro(x)); One may be tempted to simplify this statement to: int i = ro(x) + ro(y) * 0; int i = ro(x) + 0; int i = ro(x); However, this will not work for ro because each occurrence of ro(x) evaluates to a different value. Remember that the return value of ro is based on a global value that is not passed in and which gets modified on each call to ro. This means that mathematical identities such as no longer hold. Such mathematical identities will hold for referentially transparent functions such as rt. However, a more sophisticated analysis can be used to simplify the statement to: int tmp = g; int i = x + tmp + 1 + (y + tmp + 2) * (x + tmp + 3 - (x + tmp + 4)); g = g + 4; int tmp = g; int i = x + tmp + 1 + (y + tmp + 2) * (x + tmp + 3 - x - tmp - 4)); g = g + 4; int tmp = g; int i = x + tmp + 1 + (y + tmp + 2) * (-1); g = g + 4; int tmp = g; int i = x + tmp + 1 - y - tmp - 2; g = g + 4; int i = x - y - 1; g = g + 4; This takes more steps and requires a degree of insight into the code infeasible for compiler optimization. Therefore, referential transparency allows us to reason about our code which will lead to more robust programs, the possibility of finding bugs that we couldn't hope to find by testing, and the possibility of seeing opportunities for optimization. See also Idempotence in computer science Liskov substitution principle Rewrite rule References External links http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/referential_transparency https://stackoverflow.com/a/9859966/655289 by Prof. Uday Reddy (University of Birmingham) http://okmij.org/ftp/Computation/PrincipiaMathematica.txt Programming language theory