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: KL_borrowhire_firm.m
    path of file: ./repos/Math4Econ/matrix_application/htmlpdfm
    
    the code of the file until where you have to start completion: %% Cobb Douglas Profit 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*
%% 
% In the example here, we will solve a firm optimization problem using a system 
% of linear equations (2 equations and 2 unknowns). The solution method is the 
% same for N inputs with Cobb-Douglas Production Function.
%% Firm and Capital and Labor
% Assume that the firm can choose capital and labor inputs. At the start of 
% a period, a firm rents capital inputs and combines capital with labor to produce. 
% At the end of the period, the firm sells its output and pays interest rates 
% based on how much capital it rented, and also pays wage. Total wage bill is 
% $L \cdot w$, interest payment is $K \cdot r$ (Here we assume that there is no 
% depreciation of capital, so firm can repay principle by returning capital and 
% just pay interest rate). Profit is denoted by $\pi$, period interest rate is 
% $r$, the price of output is $p$, the firm makes $y$ units of output, and the 
% production function is Cobb-Douglas: $A \cdot K^\alpha \cdot L^{\beta}$
% 
% The profit maximization problem is:
%% 
% * $\max_{K, L} \left( p\cdot A\cdot K^{\alpha}\cdot L^{\beta}-r\cdot K-w\cdot 
% L \right)$
%% 
% To find optimal choices, we will assume that $\alpha + \beta < 1$
%% Two First Order Conditions
%% 
% * $\frac{\partial\Pi}{\partial K}=\alpha\cdot p\cdot A\cdot K^{\alpha-1}\cdot 
% L^{\beta}-r$
% * $\frac{\partial\Pi}{\partial L}=\beta\cdot p\cdot A\cdot K^{\alpha}\cdot 
% L^{\beta-1}-w$
%% 
% _Components of profit first oder conditions_: $MPL$ and $MPK$ are always both 
% positive, but they are decreasing with higher $L$ and higher $K$ respectively. 
% On the other hand, the marginal cost of capital and labor are fixed.
%% 
% * $\text{MPK} = \alpha \cdot A\cdot K^{\alpha-1}\cdot L^{\beta}$
% * $\text{MPL} = \beta\cdot A\cdot K^{\alpha}\cdot L^{\beta-1}$
% * $\text{MC}_{K}=r$
% * $\text{MC}_{L}=w$
%% Log Linearizing Optimality Conditions
% To find optimal choices, set the first order conditions you obtained above 
% to be equal to zero.
%% 
% # $\alpha\cdot p\cdot A\cdot K^{\alpha-1}\cdot L^{\beta}=r$
% # $\beta\cdot p\cdot A\cdot K^{\alpha}\cdot L^{\beta -1}=w$
%% 
% A generic system of 2 linear equations and 2 unknowns:
%% 
% * $\left[ {\begin{array}{cc} a & b  \\ d & e  \\ \end{array} } \right] \cdot 
% \left[ {\begin{array}{c} x_1 \\ x_2  \end{array} } \right] = \left[ {\begin{array}{cc} 
% a \cdot x_1 + b \cdot x_2 \\ d \cdot x_1 + e \cdot x_2   \\ \end{array} } \right]  
% = \left[ {\begin{array}{c} o \\ p\\ \end{array} } \right]$
%% 
% Take log of the first order conditions (log linearize), and the two equations 
% above become (Now we can solve for optimal choices using _linsolve._ Note that 
% log linearizing works regardless of how many terms there are in the cobb-douglas 
% production function):
%% 
% * $\left[ {\begin{array}{cc} (\alpha-1) & \beta  \\ \alpha & (\beta-1) \\ 
% \end{array} } \right] \cdot \left[ {\begin{array}{c} \log(K) \\ \log(L)  \end{array} 
% } \right] = \left[ {\begin{array}{cc} (\alpha-1) \cdot \log(K) + \beta \cdot 
% \log(L) \\ \alpha \cdot \log(K) + (\beta
    
function is Cobb-Douglas: $A \cdot K^\alpha \cdot L^{\beta}$
% 
% The profit maximization problem is:
%% 
% * $\max_{K, L} \left( p\cdot A\cdot K^{\alpha}\cdot L^{\beta}-r\cdot K-w\cdot 
% L \right)$
%% 
% To find optimal choices, we will assume that $\alpha + \beta < 1$
%% Two First Order Conditions
%% 
% * $\frac{\partial\Pi}{\partial K}=\alpha\cdot p\cdot A\cdot K^{\alpha-1}\cdot 
% L^{\beta}-r$
% * $\frac{\partial\Pi}{\partial L}=\beta\cdot p\cdot A\cdot K^{\alpha}\cdot 
% L^{\beta-1}-w$
%% 
% _Components of profit first oder conditions_: $MPL$ and $MPK$ are always both 
% positive, but they are decreasing with higher $L$ and higher $K$ respectively. 
% On the other hand, the marginal cost of capital and labor are fixed.
%% 
% * $\text{MPK} = \alpha \cdot A\cdot K^{\alpha-1}\cdot L^{\beta}$
% * $\text{MPL} = \beta\cdot A\cdot K^{\alpha}\cdot L^{\beta-1}$
% * $\text{MC}_{K}=r$
% * $\text{MC}_{L}=w$
%% Log Linearizing Optimality Conditions
% To find optimal choices, set the first order conditions you obtained above 
% to be equal to zero.
%% 
% # $\alpha\cdot p\cdot A\cdot K^{\alpha-1}\cdot L^{\beta}=r$
% # $\beta\cdot p\cdot A\cdot K^{\alpha}\cdot L^{\beta -1}=w$
%% 
% A generic system of 2 linear equations and 2 unknowns:
%% 
% * $\left[ {\begin{array}{cc} a & b  \\ d & e  \\ \end{array} } \right] \cdot 
% \left[ {\begin{array}{c} x_1 \\ x_2  \end{array} } \right] = \left[ {\begin{array}{cc} 
% a \cdot x_1 + b \cdot x_2 \\ d \cdot x_1 + e \cdot x_2   \\ \end{array} } \right]  
% = \left[ {\begin{array}{c} o \\ p\\ \end{array} } \right]$
%% 
% Take log of the first order conditions (log linearize), and the two equations 
% above become (Now we can solve for optimal choices using _linsolve._ Note that 
% log linearizing works regardless of how many terms there are in the cobb-douglas 
% production function):
%% 
% * $\left[ {\begin{array}{cc} (\alpha-1) & \beta  \\ \alpha & (\beta-1) \\ 
% \end{array} } \right] \cdot \left[ {\begin{array}{c} \log(K) \\ \log(L)  \end{array} 
% } \right] = \left[ {\begin{array}{cc} (\alpha-1) \cdot \log(K) + \beta \cdot 
% \log(L) \\ \alpha \cdot \log(K) + (\beta-1) \cdot \log(L)   \\ \end{array} } 
% \right]  = \left[ {\begin{array}{c} \log\left(\frac{r}{\alpha p A}\right) \\ 
% \log\left(\frac{w}{\beta p A}\right)\\ \end{array} } \right]$
%% 
% We can by hand solve by elementary row operation (linsolve).
%% Solving Linear System to find Optimal Choices
% The solution to the problem, with parameter values filled in could be obtained 
% like this:

clear all
% Parameters
w = 1;
r = 1.05;
p = 5;
alpha = 0.3;
beta = 0.5;
A = 1.0;

%% Matrix Form of linear system
B = [log(r/(p*A*alpha)); log(w/(p*A*beta))];
A = [(alpha-1), beta;alpha, beta-1];
%% Solve linear equations, and then exponentiate
linSolu = exp(linsolve(A, B));
%% Solution was for log(K*) and log(L*), exponentiate to get K* and L*
KOpti = linSolu(1)
LOpti = linSolu(2)
%% Relative Choices
% For Cobb-Douglas production functions, how do optimal capital and labor choices 
% relate to each other?

syms w r p alpha beta A 
% Matrix Form of linear system, same as before
B = [log(r/(p*A*alpha)); log(w/(p*A*beta))];
A = [(alpha-1), beta;alpha, beta-1];
% Solve linear equations, and then exponentiate, same as before
% We can use the simplify command to simplify this solution, get rid of exp and log:
linSolu = simplify(exp(linsolve(A, B)))
KOpti = linSolu(1)
LOpti = linSolu(2)
KOpti/LOpti
%% 
% The expressions from Matlab look a little convoluted, but you will notice 
% a lot of similar terms inside the equation. If you try to simplify things a 
% little bit, you will end