Equilibrium Interest Rate

back to Fan's Intro Math for Econ, Matlab Examples, or MEconTools Repositories
We derived demand and supply for credit here: Demand and Supply Derivation and Graphs.
We rewrite here the supply curve for credit which is a function of interest rate r:
We can also rewrite the demand curve for credit which is a function of interest rate r:
At equilibrium, demand equals to supply, shown graphically as the intersection point in Demand and Supply Derivation and Graphs.
We can solve for equilibrium by trying out a vector of interest rate points, or using nonlinear solution methods.
Alternatively, although this is not a system of linear equations, we can approximate these equations using first order taylor approximation, then they become a system of linear equations. We can then using linsolve to find approximate equilibrium Q and r.

First Order Taylor Approximation

Here, we discussed the formula for First Order Taylor Approximation: Definition of Differentials. Using the formula we have from there:
We approximate the demand and Supply curves. Now x is the interest rate, is the demand or supply at interest rate x we are interested in. a is the interest rate level where we solve for actual demand or supply. We approximate the by using information from .
For the problem here, let us approximate around , this is 100 percent interest rate.
Note the demand and supply curves are monotonic, and they are somewhat linear for segments of r values. If they are not monotonically increasing or decreasing, we should not use taylor approximation.

Approximate the Supply

The Supply equation comes from Optimal Savings Choice in a 2 period Model with initial Wealth, applying the formula above with :
clear all
syms a b r
% Supply equation
S = a - b/(1+r);
% For Approximation, need to get the derivative with respect to R
SDiffR = diff(S, r)
SDiffR = 
% Now evaluate S at r = 1 and evaluate S'(r) also at r = 1
SatRis1 = subs(S, r, 1)
SatRis1 = 
SDiffRris1 = subs(SDiffR, r, 1)
SDiffRris1 = 
% We now have an equation that approximates supply
SupplyApproximate = SatRis1 + SDiffRris1*(r-1)
SupplyApproximate = 

Approximate the Demand

The Demand equation comes from Optimal Borrowing Choice Firm Maximization, Applying the formula above with :
clear all
syms h k r
% Supply equation
D = h/r^k;
% For Approximation, need to get the derivative with respect to R
DDiffR = diff(D, r)
DDiffR = 
% Now evaluate D at r = 1 and evaluate D'(r) also at r = 1
DatRis1 = subs(D, r, 1)
DatRis1 = 
h
DDiffRris1 = subs(DDiffR, r, 1)
DDiffRris1 = 
% We now have an equation that approximates supply
DemandApproximate = DatRis1 + DDiffRris1*(r-1)
DemandApproximate = 

Solve approximate Demand and Supply using a System of Linear Equations

Now we have two linear equations with two unknowns, we can rearrange the terms. Note that only r and are unknowns, the other letters are parameters.
Starting with the equations from above:
we end up with this system of two equations and two unknowns (Solving for Two Equations and Two Unknowns):
We can plug this into matlab and solve for it
syms a b h k r
COEFMAT = [1, -b/4;1, k*h];
OUTVEC = [a-(3*b)/4; h + k*h];
approximateSolution = linsolve(COEFMAT, OUTVEC);
QEquiApproximate = approximateSolution(1)
QEquiApproximate = 
REquiApproximate = approximateSolution(2)
REquiApproximate = 
Now we have approximate analytical equations for demand and supply. If our was close to true equilibrium rate, we would have a good approximation of how parameters of the model, the constants, impact the equilibrium interest rate and quantity demanded and supplied.
See this page for how this is applied to the credit demand and supply example: First Order Taylor Approximation of Demand and Supply for Capital