Preferences meet the budget constraint: utility maximization and where demand curves come from.
Warming up the engine…
The model of a consumer maximizing utility subject to a budget: indifference curves (preferences) meet the budget line (possibilities) at a tangency.
At the optimum: MRS = MUx/MUy = Px/Py
Slide along your budget line until the rate you're WILLING to swap goods equals the rate the market LETS you swap them. Anywhere else, a cheap trade toward preference is being left on the table.
Price changes rotate the budget line; income changes shift it in parallel, decompose effects accordingly.
Now prove you have it
Move the curve to where you think it lands, and get told exactly which part you got right.
Real-world scenarios on this model
Equilibrium at X 50, Y 40.
Equilibrium: X* = 50.0, Y* = 40.0
Current equations
You have a budget and two goods. The straight line shows every combination you can afford; the curve shows combinations you like equally. The best affordable bundle is where an indifference curve just touches the budget line. Slide income and prices to watch the choice move.
Source: Varian, Intermediate Microeconomics, ch. 2-6