# Supply and Demand Curves under Perfect Competition

I am real learning microeconomics with a bit more math under my belt, but could not understand why the MR=P in competitive markets. This was my attempt at reasoning Given, $$R= P*q$$
For a linear demand curve $$q=a-bp$$
$$p= a-q/b$$
$$R= aq-q^2/b$$
$$MR= dR/dq$$
$$MR=a-2q/b$$
Which doesn't seem equal to price
I have two questions
a) How did I go wrong ?
b) How do we go from this to the MC curve being the supply curve mathematically ?

First, there is an error in your last equation: You forgot to divide $$2q$$ by $$b$$. But that doesn't help here, because the problem is that you are mixing things up. Your equation for $$p$$ describes the demand curve of the market, but in a competitive market individual firms are by assumption price takers, so they treat the price $$p$$ as a constant. Then, $$R=pq$$ and therefore $$MR=p$$. (What you calculated is the $$MR$$ curve of a monopolist instead.)
Given this, and remembering that the profit maximizing $$q$$ is the one where $$MR=MC$$, you can substitute $$p$$ for $$MR$$ and get that the supplied quantity $$q$$ is the one where $$p=MC$$.