In a perfect competition, I know that that the demand curve facing a firm in a competition is a horizontal line whereas the demand curve facing a market is a line with negative slope. How is this mathematically possible? Isn’t the aggregate demand curve of the market equal to the sum of demand curves of the firms? If all the firms have a horizontal line as the demand curve, how can the sum be a line with a negative slope?
In this case, you should not think about this as “aggregate demand”, which is a macro-econ concept. In this case, the firm faces a horizontal demand curve because demand for a homogenous product (perfect competition) is perfectly elastic. The consumer will completely abandon Firm A for Firm B if Firm A raises their price. If Firm A keeps its price at market levels, they will be able to sell all quantity produced. The demand curve facing the market is still downward sloping because of the law of demand for a normal good. As price declines, quantity demanded for that good increases.