Libraries in Python

Teaching Demo: Winter Makler

"Floor" function

  • floor(3) = 3
  • floor(3.5) = 3
  • floor(7.9) = 7
  • floor(-2.5) = -3
  • A Floor function rounds a number down to the nearest whole number
  • Progress bar

Coding a floor function

def floor(n):
	if n == int(n):
    	return int(n)
    else:
    	if n >= 0:
        	return int(n)
        else:
        	return int(n) - 1

Drawing Indifference Curves

  • Evaluate the utility function at a point
  • Set the function equal to that level, and solve for \(x_2\) as a function of \(x_1\)
  • Plot!

Utility Function

Utility at (4,3)

u(x_1,x_2) = 4x_1^{1 \over 2}x_2
u(x_1,x_2) = 2x_1 + 4x_2
u(x_1,x_2) = x_1^2 + x_2^2
24
20
25
4 \times 4^{1 \over 2} \times 3 =
2 \times 4 + 4 \times 3 =
4^2 + 3^2 =

Drawing Indifference Curves

  • Evaluate the utility function at a point
  • Set the function equal to that level, and solve for \(x_2\) as a function of \(x_1\)
  • Plot!

Utility Function

Util. at (4,3)

u(x_1,x_2) = 4x_1^{1 \over 2}x_2
u(x_1,x_2) = 2x_1 + 4x_2
u(x_1,x_2) = x_1^2 + x_2^2

Equation of Ind. Curve

24
20
25
4x_1^{1 \over 2}x_2 = 24
2x_1 + 4x_2 = 20
x_1^2 + x_2^2 = 25

Drawing Indifference Curves

  • Evaluate the utility function at a point
  • Set the function equal to that level, and solve for \(x_2\) as a function of \(x_1\)
  • Plot!

Utility Function

u(x_1,x_2) = 4x_1^{1 \over 2}x_2

Indifference Curve Passing through (4,3)

x_2 = {6 \over \sqrt{x_1}}

x_2
x_1
1
4
9

Drawing Indifference Curves

  • Evaluate the utility function at a point
  • Set the function equal to that level, and solve for \(x_2\) as a function of \(x_1\)
  • Plot!

Utility Function

u(x_1,x_2) = 2x_1+4x_2

Indifference Curve Passing through (4,3)

x_2 = 5 - {1 \over 2}x_1

x_2
x_1
0
4
10

Drawing Indifference Curves

  • Evaluate the utility function at a point
  • Set the function equal to that level, and solve for \(x_2\) as a function of \(x_1\)
  • Plot!

Utility Function

u(x_1,x_2) = x_1^2+x_2^2

Indifference Curve Passing through (4,3)

x_2 = \sqrt{25 - x_1^2}

x_2
x_1
0
4
5

Partial Derivatives

  • Derivatives of a multivariable function with respect to one of the variables
  • In economic terms, it's the marginal utility from another unit of one of the goods, holding the other good constant
  • Mechanically: just treat everything as a constant except for the variable you're taking the partial derivative with respect to

Partial Derivatives and Marginal Utility

Utility Function

u(x_1,x_2) = 4x_1^{1 \over 2}x_2
u(x_1,x_2) = 2x_1 + 4x_2
u(x_1,x_2) = x_1^2 + x_2^2
MU_1 = {\partial u(x_1,x_2) \over \partial x_1}
MU_2 = {\partial u(x_1,x_2) \over \partial x_2}

Solution Functions

  • Often, curves in economics are parameterized: the constants in them are parameters, and when those parameters change, the curves shift.
  • Example: shifts in supply and demand curves, like you saw in Econ 1 or high school
  • The equilibrium point is a multivariable function of those underlying parameters