Question: A function is said to be well defined if x=y implies f(x)=f(y). If x=y then surely wont f(x)=f(y). I cant get this through my head. Plz explain what a well defined function is n what is an ill defined one. It puzzles me a lot to think of an ill defined one.

Answer: 
One example of a not-well-defined function would be $f(\frac{a}{b})=a+b.$
Then, while $\frac{1}{2} = \frac{2}{4}$, we have $f(\frac{1}{2}) = 3$ but $f(\frac{2}{4})=6.$ So you'll often see, in proofs about rational numbers, that the fractions is specified to be "in lowest terms" and maybe "with denominator positive", so that the operations given are well-defined.
What makes the concept of a well-defined function $f$ confusing is the fact that functions are by definition well-defined. So to explain what it means to not be well-defined, we have to take an example where $f$ is not a function.

Lets take the following procedure and call it $f$: The input is an integer $n$. The output of $f$ is an element of $\{n+1,\ldots,n+6\}$ determined by rolling a dice. This procedure takes an integer $n$ as input, and returns an integer as output. But it is not well-defined, because if you compute $f(n)$ several times for the same $n$, you do not always get the same output. The term used to describe this behavior is to say that $f$ is not well-defined.

Suppose you have some procedure $f$ that takes as input an element of a set $X$, and returns as output an element of a set $Y$. Then you may only call $f$ a function if you can prove that $x=y$ implies $f(x) = f(y)$. This might seem obvious at first, but it is often non-trivial. For example, suppose that the procedure $f$ involves choosing an element of some non-empty set. In this case, to prove that $f$ is well-defined (and thus: a function), you have to prove that any choice you could have made will result in the same output $f(x)$.