You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: household_c1_c2_constrained.m
    path of file: ./repos/Math4Econ/opti_hh_constrained_brsv/htmlpdfm
    
    the code of the file until where you have to start completion: %% Intertemporal Utility Maximization 
% *back to* <https://fanwangecon.github.io *Fan*>*'s* <https://fanwangecon.github.io/Math4Econ/ 
% *Intro Math for Econ*>*,*  <https://fanwangecon.github.io/M4Econ/ *Matlab Examples*>*, 
% or* <https://fanwangecon.github.io/MEconTools/ *MEconTools*> *Repositories*
%% 
% We previously solved for the unconstrained household's savings and borrowing 
% problem: <https://fanwangecon.github.io/Math4Econ/derivative_application/K_save_households.html 
% unconstrained problem>. 
%% Utility Maximization over Consumption in Two Periods
%% 
% * *Utility*: $U(c_{1}, c_{2}) = \log(c_{1}) + \beta \cdot \log(c_{2})$
% * *Budget Today*: $c_{1} + b \le Z_1$
% * *Budget Tomorrow*: $c_{2} \le b\cdot (1+ r ) + Z_2$
% * $c_1 > 0$, $c_2 > 0$
%% 
% We have solved this problem as an unconstrained maximization problem by eliminating 
% the consumption terms (<https://fanwangecon.github.io/Math4Econ/derivative_application/K_save_households.html 
% unconstrained problem>). If we keep the consumption terms but eliminatethe $b$ 
% term, then the problem is a constrained maximization problem with an income 
% constraint:
%% 
% * *Budget Today and Tomorrow Together*: $c_{2} = (Z_1 - c_1)(1+r) + Z_2$
%% 
% Note that we have replaced the inequality symbol by an equality symbol. The 
% income constraints are always going to bind because households will not waste 
% income given log utility which is always increasing in consumption. This also 
% means we don't have to worry about the positive consumption constraints, because 
% households will never consume at 0 since utility is not defined. We can rewrite 
% the budget constraint as follows:
%% 
% * *Budget Today and Tomorrow Together*: $c_{1}\cdot(1 + r) + c_{2} = Z_1 \cdot 
% (1+r) + Z_2$
%% 
% Rewriting the problem as we do above has a nice interpretation. In this 
    
function when it is evaluated at the 
% optimal choices, it is called indirect utility:
%% 
% * *Indirect Utility function*: $U(c^{\ast}_1(r,Z_1,Z_2), c^{\ast}_2(r,Z_1,Z_2)) 
% = V^{\ast}(r,Z_1,Z_2)$
%% 
% Given the solutions, we have:
%% 
% # $V^{\ast}(r,Z_1,Z_2) = \log\left( \frac{Z_1 + Z_2\cdot \frac{1}{1+r}}{1 
% + \beta} \right) + \beta \cdot \log\left( \frac{Z_1 \cdot (1+r) + Z_2}{1 + \frac{1}{\beta}} 
% \right)$
% # $V^{\ast}(r,Z_1,Z_2) = \log\left( \frac{Z_1 \cdot \left( 1 + r \right) + 
% Z_2 }{\left(1 + \beta\right) \cdot \left(1+r \right) } \right) + \beta \cdot 
% \log\left( \frac{Z_1 \cdot (1+r) + Z_2}{\left(1+\beta\right)\cdot \beta^{-1}} 
% \right)$
% # $V^{\ast}(r,Z_1,Z_2) = \left(1 + \beta\right) \log\left( \frac{Z_1 \cdot 
% \left( 1 + r \right) + Z_2 }{1 + \beta} \right) + \log \left( \frac{\beta^{\beta}}{1+r} 
% \right)$
% # $V^{\ast}(r,Z_1,Z_2) = \log\left( \left( \frac{Z_1 \cdot \left( 1 + r \right) 
% + Z_2 }{1 + \beta} \right)^{\left(1 + \beta\right)} \cdot  \left( \frac{\beta^{\beta}}{1+r} 
% \right) \right)$
%% Optimal Borrowing and Savings Choices
% We can also now find the optimal borrowing and savings choice, which is, given 
% $c^{\ast}_{1} + b^{\ast} = Z_1$:
%% 
% * $b^{\ast} = Z_1 - \frac{Z_1 + Z_2\cdot \frac{1}{1+r}}{1 + \beta}$
% * $b^{\ast} = \frac{\beta \cdot Z_1 - Z_2\cdot \frac{1}{1+r}}{1 + \beta}$
%% 
% You could also express the above expression as: $b^{\ast} = \frac{\beta \cdot 
% (1+ r) \cdot Z_1 - Z_2}{\left(1 + \beta\right)\cdot\left(1+r\right)}$, which 
% is what we obtained before from the <https://fanwangecon.github.io/Math4Econ/derivative_application/K_save_households.html 
% unconstrained problem>. Looking at the optimal borrowing and savings choice, 
% we can see that sometimes the household wants to borrow, sometimes save, depending 
% on the numerator, specifically:
%% 
% * $b^{\ast} >0$ if $\beta \cdot (1+ r) > \frac{Z_2}{Z_1}$
% * $b^{\ast} \le 0$ if $\beta \cdot (1+ r) \le \frac{Z_2}{Z_1}$
%% 
% This tells us that whether a househodl borrows is dependent on the ratio of 
% endowments: $\frac{Z_2}{Z_1}$, and the discount rate multiplied by $1+r$. The 
% preference for future multiplied by the total return to savings must be higher 
% than the ratio of endowment tomorrow versus today for households to want to 
% save. In another word, suppose $\beta \cdot (1+r) > 1$, the household will be 
% willing to save even if there is more endowment tomorrow than today.
%% Computational Solution to the Equality Constrained Problem
% Matlab can solve the optimal choices for us. We can use diff and solve.

beta = 0.95;
z1 = 1;
z2 = 2;
r = 0.05;
syms r c1 c2 mu
% The Lagrangian
lagrangian = (log(c1) + beta*log(c2)) - mu*( c2 + (1+r)*c1 - z1*(1+r) - z2)
% Derivatives
d_lagrangian_c1 = diff(lagrangian, c1);
d_lagrangian_c2 = diff(lagrangian, c2);
d_lagrangian_mu = diff(lagrangian, mu);
GRADIENTmax = [d_lagrangian_c1; d_lagrangian_c2; d_lagrangian_mu]
% Given we have many symbols, type K, L, mu at the end