def test_surplus_tax(self): """Practice problem 2.3 """ sp.var('x p W') benefit = et.benefit_from_demand(x, p, 100 - p) sp.plot(benefit, (x, 0, 100)) cons = Consumer(x, p, benefit) cons_sub = Consumer(x, p, benefit, other=W - x*p/2) self.assertEqual(cons_sub.surplus().subs(p, 50) - cons.surplus().subs(p, 50), 1562.5)
def test_surplus_tax(self): """Practice problem 2.3 """ sp.var('x p W') benefit = et.benefit_from_demand(x, p, 100 - p) sp.plot(benefit, (x, 0, 100)) cons = Consumer(x, p, benefit) cons_sub = Consumer(x, p, benefit, other=W - x * p / 2) self.assertEqual( cons_sub.surplus().subs(p, 50) - cons.surplus().subs(p, 50), 1562.5)
def total_benefit(self): return et.benefit_from_demand(self.q, self.p, self.demand)