MATLAB Solving (part of) a Bellman Equation in MATLAB

Example, given the Bellman and guess:

 

this is from ECON210B day 11 notes

Step One: eliminate ‘c’ and insert our solution, now solve the problem:

 

find your FOC:

 

Step Two: If you got this far, MATLAB can do the rest of the algebra for you:

Establish your symbols

syms A k alfa s betty M c

 Set up your equation to solve, & remember we want to find consumption c and savings s

    x = solve(((-1/(A*(k^(alfa))-s))+((betty*M)/s)), A*k^alfa-s-c, 'c, s');

 

This creates an array called ‘x’ with two fields ‘c’ and ‘s’.

Just type:

sK=x.s

& then:    cK=x.c

 

You’ll get the result:

sK = betty*M*A*k^alfa/(1+betty*M)

cK = A*k^alfa/(1+betty*M)

 

Exactly what we had in our notes:

 

…more work to take out M

syms A k alfa s betty M c

x = solve(((-1/(A*(k^(alfa))-s))+((betty*M)/s)), A*k^alfa-s-c, (alfa/(1-alfa*betty))-M, 'c, s, M');

sK=x.s

cK=x.c

M=x.M


results:
sK = betty*alfa*A*k^alfa
cK = A*k^alfa-betty*alfa*A*k^alfa
M  = -alfa/(-1+alfa*betty)

s(k) looks good,
you simplify c(k) to (1-alpha*beta)(A*k^alpha)
M you just found by plugging your earlier solutions for s and c into your objective function

PS, I've never used Mathematica or Maple, but people have been telling me that are much easier than MATLAB for this kind of symbolic algebra problem. Perhaps you should use them. 


Comments