This is a work-in-progress course website for Mathematics for Economists. Course covers a limited subset of topics from Mathematics for Economists (Simon and Blume 1994), and uses various definitions from the book. Applications focus on two period borrowing and savings problems. Matlab’s symbolic toolbox is used throughout.
Materials are written in matlab livescript files and shown as HTML files. To obtain matlab codes, see here and here for github set up. For HTML files, click on the links below.
From other repositories: For dynamic borrowing and savings problems, see MEconTools and Dynamic Asset Repository; For code examples, see also Matlab Example Code, Stata Example Code, Python Example Code, R Example Code; For intro econ with Matlab, see Intro Mathematics for Economists, and for intro stat with R, see Intro Statistics for Undergraduates. See here for all of Fan’s public repositories.
Files are from the Math4Econ repository. Please contact FanWangEcon for issues or problems.
1 Notations and Functions
- Real Number and Intervals: mlx | m | pdf | html
- Definition and draw a line.
- m: linspace() + line() + set(gca, yaxis off) + pbaspect()
- Interval Notations and Examples: mlx | m | pdf | html
- Closed, open intervals.
- What is a Function?: mlx | m | pdf | html
- Domain, argument, do-domain, image/value, range.
- Graph a circle.
- m: sin() + plot()
- Function Notations: mlx | m | pdf | html
- Consistent function naming.
- Monomials and Polynomial of the 3rd Degree: mlx | m | pdf | html
- Monomial, polynomial, degree of polynomial.
- Graph polynomial of the 3rd degree and monomials of different degrees.
- m: syms x + f(x) = a + x + fplot(@(x) f(x,a), [x_low, x_high])
- Local and Global Maximum: mlx | m | pdf | html
- local and global maximum.
- m: syms + solve() + diff() + double() + double(solve(diff(f,x),x)), fplot(f,[x_low, x_high])
2 Commonly Used Functions
- Exponential and Compounding Interest Rates: mlx | m | pdf | html
- Exponential function and rules: a^b. Base e exponential, e = 2.71828.
- Infinitely compounding interest rate (continuous time).
- e^r: borrow 1 dollar, given r, meaning r percent interest, e^r is how much to pay back in principle + interests given infinite compounding.
- Log linear equation with a constant term, substraction and division.
- m: exp() + fplot() + double(subs())
- Exponential and Log Functions: mlx | m | pdf | html
- log and natural log (log in matlab base e, log in google base 10).
- log rules, and why: log(xy) = log(x) + log(y); log(x^a) = alog(x).
- log difference and small rates of change.
- m: linspace() + log()
3 Derivatives
- Derivative Definition and Rules: mlx | m | pdf | html
- Derivative notations, limit definition, and key rules.
- m: syms + diff()
- Continuity and Differentiability: mlx | m | pdf | html
- Continuous point, set and function, continuously differentiable.
- Elasticity and Derivative: mlx | m | pdf | html
- Elasticity of demand at price p, given h change in p.
- Point elasticity of demand at price p.
- Elasticity and the limiting definition of derivative.
- First Order Taylor Approximation: mlx | m | pdf | html
- Differential: change along the tangent line to approximate change in function value.
- First order taylor approximation and the limiting definition of derivative.
- Differential approximating marginal productivity of labor.
- m: syms + f(L) = L^a + sub(f, 1)
- Higher Order Derivatives Cobb Douglas: mlx | m | pdf | html
- Cobb-Douglas production function, first and second derivatives.
- Convex and Concave functions.
- m: syms + f(L) = L^a + diff(diff(f, L),L) + fplot() + title({‘title one’ ‘subtitle’}) + ylabel({‘ylab abc’ ‘ylab efg’}) + legend{[‘line a’],[‘lineb’],, ‘Location’,’NW’}
4 Univariate Applications
- Marginal Product of Labor: mlx | m | pdf | html
- Marginal product for each additional units of workers given different levels of capital.
- m: plot() + scatter() + legend([‘k=’,num2str(K1)], [‘k=’,num2str(K1)])
- Derivative of Cobb-Douglas Production Function: mlx | m | pdf | html
- Marginal product of labor given different levels of capitals.
- m: syms + diff() + fplot()
- Derivative Approximation: mlx | m | pdf | html
- Marginal product and tangent lines.
- m: syms + diff() + fplot() + lengend{}
- Household’s Savings Problem: mlx | m | pdf | html
- Endowments today and tomorrow, borrowing and savings, no shocks.
- Grid based or analytical solution.
- Supply curve of savings (asset).
- m: max() + diff() + solve() + plot() + scatter()
- Firm’s Borrowing Problem: mlx | m | pdf | html
- Profit maximization choosing capital, with labor fixed.
- Grid based or analytical solution.
- Demand curve of capital (asset).
- Overlay demand and supply curves, visualize interest rate equilibrium
- m: max() + diff() + solve() + plot() + scatter()
5 Matrix Basics
- Laws of Matrix Algebra: mlx | m | pdf | html
- Scalar: Associative + Communtative + Distributive laws; Matrix: all apply except A times B != B times A.
- m: transpose()
- Matrix Addition and Multiplication: mlx | m | pdf | html
- Scalar, matrices, and matrix dimensions.
- m: dot product
- Creating Matrixes in Matlab: mlx | m | pdf | html
- Vectors, matrixes and multiple matrixes.
- m: ceil() + eye() + tril() + triu() + rand(N,M,Q)
6 System of Equations
- System of Linear Equations: mlx | m | pdf | html
- One or multiple linear equations.
- Coefficient matrix and augmented form.
- Solving for Two Equations and Two Unknowns: mlx | m | pdf | html
- Two equations and two unknowns matrix form.
- Graphical intersection of two lines.
- Using linear solver linsolve.
- m: linsolve + double(solve(y_1 - y_2 == 0))
- System of Linear Equations Row Echelon Form: mlx | m | pdf | html
- Two equations and two unknowns.
- Elementary row operations and row echelon form.
- Matrix Inverse: mlx | m | pdf | html
- Find the inverse of a matrix.
7 Matrix Applications
- Firm Maximization Problem with Capital and Labor: mlx | m | pdf | html
- First order conditions Cobb-Douglas production function with Capital and Labor.
- Log linearize first order conditions, matrix form and linsolve Cobb-Douglas production function.
- Own and cross price elasticities
- m: linsolve() + simplify(exp(linsolve())) + mesh() + meshgrid() + contourf() + clabel() + zlabel()
- Household Maximization with Two Goods and Budget: mlx | m | pdf | html
- Preference over two good, cobb douglas utility.
- Indifference curves and budget set.
- m: linspace() + meshgrid() + mesh() + contourf() + clabel() + colormap() + zlabel() + plot()
- Capital Demand and Supply Equilibrium Analysis: mlx | m | pdf | html
- Simplified nonlinear form of demand and supply as functions or the interest rate.
- First order Taylor linear approximation of nonlinear demand and supply.
- m: diff() + subs(S,r,1) + linsolve()
- First Order Taylor Approximation of Demand and Supply Curves: mlx | m | pdf | html
- Exact solutions for (approximated) equilibrium interest rate and asset supply/demand given linearized demand and supply equations.
- Graphical illustration of exact equilibrium and linear approximated equilibrium.
- Analyze how productivity, elasticity, wealth, discount factor impact equilibrium prices and quantity given exact solutions to linear approximation.
- m: linspace() + subs(diff(S,r), r, r0) + subs(D, {Z,beta}, {Z_num, beta_num}) + fplot() + plot() + line.Color + line.LineStyle
8 Uncertainty
- Risky Assets and Different States of the World: mlx | m | pdf | html
- Bad and good states of the world.
- Safe savings and risky investments with uncertain returns.
- Borrowing to finance risky investments.
- m: solve(diff(U, D)==0, diff(U, B)==0, D, B)
9 Equality Constrained Optimization
- Profit Maximization and Cost Minimization: mlx | m | pdf | html
- Profit maximization and cost minimization with Cobb Douglas production function given quantity constraint. Constant or decreasing returns to scales, optimal capital and labor given quantity constraint.
- m: GRADIENT = subs(GRADIENT, {A,p,w,r,q,alpha,beta},{1,1,1,1,2,0.3,0.7}) + solu = solve(GRADIENT(1)==0, GRADIENT(2)==0, GRADIENT(3)==0, K, L, m, ‘Real’, true)
- Firm Marginal Cost and Profit given Constant Returns to Scale: mlx | m | pdf | html
- Profit maximization over outputs given cost minimization.
- Marginal costs and constant returns to scales, perfect competition and zero profits.
- Marshallian Constrained Utility Maximization: mlx | m | pdf | html
- Budget constrained intertemporal utility maximization.
- Marshallian solutions, indirect utility
- Analytical solution, matlab symbolic solution, matlab fminunc numerical solutions
- m: diff() + gradient() + fmincon()
- Hicksian Constrained Expenditure Minimization: mlx | m | pdf | html
- Optimal expenditure minimization choice given indirect utility.
- Hicksian solutions (Dual Problem).
- Analytical solution, matlab symbolic solution.
- m: diff() + gradient()
- graph: budget + indifference + endowment and optimal choices
- Income and Substitution Effects: mlx | m | pdf | html
- Slusky decomposition, expenditure minimization given two prices.
- Analytical solution, matlab symbolic solution.
- m: diff() + gradient()
10 Inequality Constrained Optimization
- Firm Profit Maximization Problem with Borrowing Constraint: mlx | m | pdf | html
- Constrained on capital/borrowing, solve for cases.
- If constraint binds, re-optimize labor choice given capital bound.
- Borrowing and Savings with Borrowing Constraint: mlx | m | pdf | html
- Unconstrained and constrained problem.
- Analytical solution and fmincon solution.
- Optimal borrowing/savings with varying endowments and interests rates.
- m: U = @(b) log(z1 - b) + matlabFunction(subs(U, {z1, z2}, {z1v, z2v})); + fmincon(U, b0, A, q); + optimoptions(‘FMINCON’,’Display’,’off’);
- Labor and Borrowing/Savings Choices with Borrowing Constraint: mlx | m | pdf | html
- Unconstrained work/leisure and borrow/savings problem.
- Constrained work/leisure and borrow/savings problem given borrow bound.
- Analytical and matlab symbolic solutions.
- Numerical solution with fmincon.
- m: d_L_b = diff(L, b); + d_L_H = diff(L, H); + GRAD = [d_L_b; d_L_H] + solu = solve(GRAD(1)==0, GRAD(2)==0, b, H, ‘Real’, true); + solu = simplify(solu) + fmincon(U_neg, b0, A, q) + fmincon(U_neg, b0, A, q, [], [], [], [], [], options) + legendCell = cellstr(num2str(Z2_vec’, ‘Z2=%-d’)) + plot()
11 Equilibrium and Policy
- Equilibrium Interest Rate and Tax: mlx | m | pdf | html
- Households supply savings or borrow (with constraint) to smooth consumption.
- Firms borrow to finance capital inputs.
- Solve for excess demand and supply of assets and equilibrium interest rate.
- The effect of a tax on savings and subsidy for borrowing on equilibrium interest rate.
- m: U_neg = @(x) -1(log(z1 - x(1)) + beta_vec(j)log(z2 + x(1)r_vec(i)(1-tau))) + excess_credit_supply = (sum(b_opti_mat, 2) + (-1)FIRM_K’) + min(abs(excess_credit_supply)) + plot(r, excess_credit_supply)*
- Equilibrium Interest Rate and Wage: mlx | m | pdf | html
- Households supply labor and enjoy leisure, firms demand labor.
- Households borrow with constraints and supply savings, firm demand capital.
- Solve for excess supply of assets and labor over wage and interest rates grid.
- Solve for market clearing wage and interest rates.
- m: U_neg = @(x) -1(log(z1 + W_vec(j)x(2) - x(1)) + psilog(x(3)) + beta_vec(h)log(z2 + x(1)(R_vec(i)))) + options = optimoptions(‘FMINCON’,’Display’,’off’); + [x_opti,U_at_x_opti] = fmincon(U_neg, b0, A, q, [], [], [], [], [], options); + KD(i,j) = subs(K_opti,{r,w},{R(i), W(j)}) + LD(i,j) = subs(L_opti,{r,w},{R(i), W(j)}) + jet(numel(chart)) + plot(R, b_opti); + plot(R, -k_opti);*
Please contact for issues or problems.