An abbreviation of the Latin phrase "quod erat demonstrandum". It literally translates as "which was to be demonstrated", and is a formal way of ending a mathematical, logical or physical proof. It's purpose is to alert the reader that the immediately previous statement, which naturally was arrived at by an unbroken chain of logic, was the original statement that we were trying to prove.
"I refuse to prove that I exist," says God, "for proof denies faith, and without faith I am nothing."
"But," say Man, "the Babel fish is a dead giveaway, isn't it? It could not have evolved by chance. It proves you exist, and so therefore, by your own arguments, you don't. QED."
"Oh dear," says God, "I hadn't thought of that" and promply vanishes in a puff of logic." -- Douglas Adams, from "A Hitchiker's Guide to the Galaxy"
Proof that x + 3 = 0 if x = -3
x + 3 = (-3) + 3
Appending 'Schmain' to 'Pain' indicates complete nonchalance on the behalf of the utterer with regard to the promised, expected or forthcoming pain.
The idea being expressed is that Pain will affect him no more than Schmain would. There is no such thing as Schmain.
Macduff: You are entering a world of pain, boy.
Macbeth: Pain Schmain.