The demand curve
Suppose that starting from a condition of equilibrium, the price of X falls relative to Y. We now have a condition where the utility from the last shilling spent on X will be greater than the utility from the last shillings spent on Y. Mathematically this can be written as:
In order to restore the equilibrium the consumer will buy more of X (and less of Y), thus reducing the marginal utility of X. The consumer will continue substituting X for Y until equilibrium is achieved. Thus we have attained the normal demand relationship that, ceteris paribus, as the price of X falls, more of it is bought. We have therefore a normal downward-sloping demand curve. The demand curve we have derived is the individuals' demand curve for a product. The market demand curve can be then obtained by aggregating all the individual demand curves.
The explanation we have obtained here is of the price (or substitution) effect.