Oh no, not at all! You're actually getting the point (pun initially not intended). : )
Defining a relation as a set of ordered pairs, we can create the inverse relation simply by swapping the x and y coordinates, and that is what the code does in the second comprehension.
f(x) is initially used in a list comprehension to create the ordered pairs F which is then used in a further comprehension to create the list of ordered pairs G.
An exercise for the students is to then create the function g(x) that produces the same ordered pairs as we find in list G.
So it turns out that we can arrive at the same set of points by either
- altering the original coordinates directly, or
- creating a list from the inverse function.
Of course, #2 is not always possible, for example, if we change f(x) to x^2. Can we create a single function that will produce the green sideways parabola? This opens up further discussion.
I'm using the same strategy for other transformations. Given some function f(x), let's create a list of ordered pairs, then transform it into a new list by scaling or translation or whatever, and now let's try to describe this new list with a new function.
- Michel