Well-defined functions on equivalence classes Could someone please explain how to develop a proof and the reasoning behind the following:
My professor said that to determine if a function is well-defined, we check to see if equivalent elements map to equivalent elements. 
1) f : Q -> Q by f(p,q) = (2p + q) / 2q. Given: (p1,q1) ~ (p2,q2) => p1q2 = q1p2. 
His proof went along something like this:
f(p1, q1) = f(p2, q2)
=>
(4 * q1 * p2) + (2 * q1 * q2) = (4 * q1 * p2) + (2 * q1 * q2) (LINE 1)
=>
(4 * p1 * q2) + (2 * q1 * q2) = (4 * q2 * p2) + (2 * q1 * q2)
=>
(2 * p1 + q1) / (2 * q1) ~ (2 * p2 + q1) / (2 * q2)
Q.E.D
I don't understand how he got what I labeled as line 1. Did he input (p1, q1) and (p2,q2) into the function and then cross-multiply? If so, shouldn't it have been (4 * p1 * q2) + (2 * q1 * q2) = (4 * p2 * q1) + (2 * q1 * q2)?
Another question. My book says that the following function is NOT well defined:
g: Q -> Q by g(m/n) = m + n. The example is g(1/2) = 3 but g(2/4) = 6.
This is NOT well defined because 3 is not equivalent to 6 right and because (1,2) and (2,4) are equivalent, so we expect to get equivalent outputs, right?

what you are trying to demonstrate is that if $p_1q_2=p_2q_1$ then 
$$
(2p_1+q_1)(2q_2) = (2p_2+q_2)(2q_1)
$$
which is a fairly easy arithmetic exercise
