\chapter{Firms}
\label{chap:firms}
\index{Firms%
@\emph{Firms}}%

\section{Firms}

There at least one representative firm for each production industry.  Most industries will have a both corporate and non-corporate firms.  Corporate firms may be as many as three - with a domestic corporation, a multi-national parent corporation, and a multi-national subsidiary corporation (the follows the structure of the CORTAX model in terms of the types of corporations).  However, for computational and calibration issues, we will simplify and have just a single multinational corporation for each production industry.  The extent of overseas operations will be a an element of calibration - therefore the degree to which each industries firm is multinational will vary across industry.

The costs of making this simplification is that it would be more difficult to handle legislation about corporate inversion (but even that isn't handled well in the CORTAX structure).  It also makes it more difficult to do multi-country interactions of tax policy, which is what CORTAX is designed for.  I think out other features, such as a diverse set of industries and corporate and non-corporate firms, are more relevant for US tax policy and are difficult to fit in the CORTAX framework due to computational and calibration issues.

We start by describing a fully domestic corporate firm and it's optimal investment, employment, and financial policies.  We then add the international components that describe the multinational nature of this firm.  Next, we discuss the problem of the non-corporate firm.   The functional forms describing the technologies and constraints of the firms are the same across industry, but the parameter values (of both the policy variant and policy invariant) parameters may vary across sector.  In the notation below, we drop the industry subscripts for clarify of exposition.

\section{The Problem of the Domestic Corporation}

The objective of the firm is to maximize firm value.  Firms do this by choosing investment and labor demand, as well as financial policies such as new equity issues, dividend distributions, and borrowing.  There are a total of six endogenous variables in the domestic corporation's problem: investment demand ($I$), demand of effective labor units ($EL$), the stock of corporate debt ($B$), the amount of new equity issues ($VN$), dividend distributions, $DIV$, and the price of output ($p$).  The firm makes choices over the first five of these variables.  The last is determined by an assumption about market structure.  In particular, we assume that firms have a decreasing returns to scale production function and thus realize economic profits.  \textcolor{red}{We pin down the price of output by assuming that there is free entry into the market.  Thus, firms must set price at marginal cost.  With a decreasing returns to scale function, such a price still produces economic profits.  This condition then provides the final equation to identify our six exogenous variables.}

\textcolor{red}{One issue to be resolved is how we handle differential returns on equity across industry and corporate/non-corporate status.  For example, the returns to some firms might differ because they have more overseas profits and/or more ability to shift income overseas to avoid US taxation.}

\subsection{The Value of the Firm}

The household's portfolio problem described in Section \ref{sec:portfolio} allows for differential returns on debt and equity.  It also makes clear that after tax returns differ across savers as they face different tax treatment.  In the formulation of the value of the firm, we use the tax rate on the marginal investor.  \textcolor{red}{It is an open question as to who this investor is, but we will take it to be the domestic investor with the median amount of savings.}  Noting that all individual level tax rates represent those on this marginal investor, we can derive the value of the firm in period $t$, $V_{t}$ in the following way.  The after-tax return on firm equity in period $t$ is given by:

\begin{equation}
\label{eqn:equity_return}
r_{e,t} = \frac{(1-\tau^{d}_{t})DIV_{t}+(1-\tau^{g}_{t})(V_{t+1}-V_{t}-VN_{t})}{V_{t}},
\end{equation}

\noindent\noindent where  $VN_{t}$ are new equity issues in period $t$ (that dilute the value of period $t$ shareholders) and $DIV_{t}$ are dividends distributed in period $t$. The policy parameters $\tau^{d}_{t}$ and $\tau^{g}$ are the period $t$ marginal tax rates on dividends and capital gains for the marginal investor.

\subsubsection{An aside on after-tax rates of return}

\textcolor{red}{Note that the notation for the return on equity differs from that in Section \ref{sec:portfolio}, where $r_{e,t}$ is the before tax return.  In the current section, $r_{e,t}$ denotes the after-tax return for the marginal investor.  To the after-tax return for all investors, we have two options.  First, we can use the decision rules of firms (which imply dividend distributions an firm value) to find the pre-tax rate of return, call it $r^{pre}_{e,t}$:}

\begin{equation}
r^{pre}_{e,t}=\frac{DIV_{t}+V_{t+1}-V_{t}-VN_{t}}{V_{t}},
\end{equation}

\noindent\noindent \textcolor{red}{We then define the gross, after-tax return for a individual of lifetime income group $j$, age $s$, in period $t$ as in Section \ref{sec:portfolio}: $\rho_{e,s,j,t}=(1+r^{pre}_{e,t}(1-\tau^{cap}(y_{j,s,t})))$.}

\textcolor{red}{A second way to do this would be to use the firms decision rules to find the after tax return for each investor:}

\begin{equation}
r_{e,j,s,t} = \frac{(1-\tau^{d}_{j,s,t})DIV_{t}+(1-\tau^{g}_{j,s,t})(V_{t+1}-V_{t}-VN_{t})}{V_{t}},
\end{equation}

\noindent\noindent \textcolor{red}{where the gross, after-tax return would be described by $\rho_{e,s,j,t}=1+r_{e,j,s,t}$.}

\textcolor{red}{The main difference between the two methods is that the first allows for the model to include some elements of the dividend clientele hypothesis (depending on the detail on asset holdings imputed to the micro simulation model).  In particular, the tax rate, $\tau^{cap}(y_{j,s,t})$ would be calibrated from the microsimulation model and therefore would be a weighted average of the tax rates on dividends and capital gains for filers in a particular age-income group, where the weighting depends on the amount of capital gains versus dividend income for those filers.  In contract, the second method assumed that all households get the same mix of dividends and capital gain income.  However, the second method benefits from using the model's endogenous split between dividend and capital gains income, rather than assuming that the split is the same over time (but varies in the cross-section).  So, to summarize, the first method allows for cross-sectional variation in the split between dividend and capital gains income (but no variation over time within a filer type), while the second method allows for variation over time (but not across filer types).}

\subsection{The Value of the Firm, cont'd}
We can rearrange Equation \ref{eqn:equity_return} to solve for $V_{t}$:

\begin{equation}
\begin{split}
(1-\tau^{g}_{t})V_{t+1} &=V_{t}r_{e,t}-(1-\tau^{d}_{t})DIV_{t}+(1-\tau^{g}_{t})V_{t}+(1-\tau^{g}_{t})VN_{t}\\
\implies  V_{t+1} & = \frac{r_{e,t}V{t}-(1-\tau^{d}_{t})DIV_{t}}{(1-\tau^{g}_{t})}+V_{t}+VN_{t} \\
\implies  V_{t+1} & = V_{t}\left(\frac{r_{e,t}}{(1-\tau^{g}_{t})}+1\right)+VN_{t} - \left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}}\right)DIV_{t} \\
\implies V_{t} &= \left(\frac{1}{1+\frac{r_{e,t}}{(1-\tau^{g}_{t})}}\right)\left[V_{t+1} - VN_{t} + \left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}}\right)DIV_{t}\right]  \\
\end{split}
\end{equation}

\noindent\noindent Letting $ \left(\frac{1}{1+\frac{r_{e,t}}{(1-\tau^{g}_{t})}}\right) = 1+\theta_{t}$, we can solve for $V_{t}$ by repeatedly substituting for $V_{t+1}$ and applying the transversality condition ($\lim_{T \to \infty} \prod_{t=1}^{T}(1+\theta_{t})V_{T}=0$):

\begin{equation}
\label{eqn:solve_vs}
\begin{split}
& V_{t}=\frac{V_{t+1}}{(1+\theta_{t})} - \frac{VN_{t}}{(1+\theta_{t})}  + \frac{\left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}}\right)DIV_{t}}{(1+\theta_{t})} \\
\implies &  V_{t}=\frac{V_{t+2}}{(1+\theta_{t})(1+\theta_{t+1})} - \frac{VN_{t+1}}{(1+\theta_{t})(1+\theta_{t+1})}  + \frac{\left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}}\right)DIV_{t+1}}{(1+\theta_{t})(1+\theta_{t+1})} - \frac{VN_{t}}{(1+\theta_{t})}  + \frac{\left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}}\right)DIV_{t}}{(1+\theta_{t})} \\
\implies &  V_{t}= \frac{V_{t+3}}{(1+\theta_{t})(1+\theta_{t+1})(1+\theta_{t+2})} - \frac{VN_{t+2}}{(1+\theta_{t})(1+\theta_{t+1})(1+\theta_{t+2})}  + \frac{\left(\frac{1-\tau^{d}_{t+2}}{1-\tau^{g}_{t+2}}\right)DIV_{t+2}}{(1+\theta_{t})(1+\theta_{t+1})(1+\theta_{t+2})} \\
& - \frac{VN_{t+1}}{(1+\theta_{t})(1+\theta_{t+1})}  + \frac{\left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}}\right)DIV_{t+1}}{(1+\theta_{t})(1+\theta_{t+1})} - \frac{VN_{t}}{(1+\theta_{t})}  + \frac{\left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}}\right)DIV_{t}}{(1+\theta_{t})} \\
& \text{and so on...} \\
\implies & V_{t}=\underbrace{\prod_{\nu=t}^{\infty}\left(\frac{1}{1+\theta_{\nu}}\right)V_{\infty}}_{=0 \text{ by transversality condition}} - \sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[VN_{u} - \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)DIV_{u}\right]\\
\implies & V_{t}= \sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[ \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)DIV_{u}-VN_{u}\right]\\
\end{split}
\end{equation}

\subsection{Firm Production}

Firm's combine capital, $K$, and effective labor, $EL$, with a fixed factor of production, $A$ to produce output, $X$.  We can think of the fixed factor of production as ``location specific capital".  It is fixed in the sense that its supply is perfectly inelastic.  It is location specific in the sense that it is proportional to the size of the population in the firm's home country at time $t$. \textcolor{red}{CORTAX documentation at first suggests this factor is chosen optimally by the firm, but there is not first order condition for this choice shown.  The documentation does state that this factor is paid its marginal product.  So there are only economic profits before you account for the return to this factor of production.  I'm also not sure if we need this fixed factor of production to be proportional to the population.  CORTAX says yes so that you don't have productivity differential arising from differences in country size.  They consider multi-country model, but only steady state.  Do we need something similar so productivity doesn't depend upon population at time $t$?}  We write the amount of output produced as a function of this fixed factor and the value added, $VA$, from the input of capital and labor:

\begin{equation}
X_{t} = A_{t}(VA_{t})^{\alpha_{v}},
\end{equation}

\noindent\noindent where $\alpha_{v}$ is the share of output attributable to the firm's value added and the fixed factor of production is given by:

\begin{equation}
A_{t} = (A_{0,t}\omega_{t}N_{t})^{1-\alpha_{v}}
\end{equation}

\noindent\noindent  So the input from fixed factor of production used by the firm is given by the level of total factor productivity (TFP), $A_{0,t}$, and a exogenous share of the population, $N_{t}$ where the share is given by the parameter $\omega_{t}$ (\textcolor{red}{Not sure if we want this to vary by time, or just across production industry.}).  The share parameters must sum to one.  That is, $\sum_{m=1}^{M} \omega_{m,t} = 1$.     We assume that TFP grows at the same rate across industry, with the growth rate given by $g_{a}$.  The value added is given by a CES function:

\begin{equation}
\label{eqn:prod_fun}
F(A_{0,t},K_{t},EL_{t})=VA_{t} =A_{0,t} \left[(\gamma_{})^{1/\epsilon_{}}(K_{t})^{(\epsilon-1)/\epsilon_{}}+(1-\gamma_{})^{1/\epsilon_{}}(e^{g_{y}t}EL_{t})^{(\epsilon_{}-1)/\epsilon_{}}\right]^{(\epsilon_{}/(\epsilon_{}-1))},
\end{equation}

\noindent\noindent where $\epsilon$ gives the elasticity of substitution between capital and labor and $\gamma$ is the share parameter in the CES production function.  Effective labor units are affected by labor augmenting technological change.  The growth rate of this technology is give by $g_{y}$.  If $\alpha_{v}<1$, then the production function exhibits decreasing returns to scale with respect the firm's inputs of capital and labor.

We can derive the marginal products of capital and labor as:

\begin{equation}
\label{eqn:mpk}
MPK_{t}=\frac{\partial X_{t}}{\partial K_{t}}=A_{0,t}^{\frac{\epsilon-1}{\epsilon}} \left(\frac{\alpha_{v}X_{t}}{VA_{t}}\right)\left(\frac{\gamma VA_{t}}{K_{t}}\right)^{\frac{1}{\epsilon}}
\end{equation}

\begin{equation}
\label{eqn:mpl}
MPL_{t}=\frac{\partial X_{t}}{\partial EL_{t}}=A_{0,t}^{\frac{\epsilon-1}{\epsilon}} \left(\frac{\alpha_{v}X_{t}}{VA_{t}}\right)\left(\frac{(1-\gamma) VA_{t}}{EL_{t}}\right)^{\frac{1}{\epsilon}}
\end{equation}

\subsection{Firm Accounting}

Here we define a few accounting concepts and constraints relevant to the firm's problem.

\subsubsection{Cash Flow Constraint}
The firm's choices of investment and labor demand, as well as financial policies to finance these expenditures must satisfy the firm's cash flow constraint, which is given by:

\begin{equation}
\label{eqn:cash_flow}
\begin{split}
& \underbrace{p_{t}X_{t}+B_{t+1}+VN_{t}}_{\text{financial inflows}} =\\
 & \underbrace{w_{t}EL_{t} + (1+r_{b,t})B_{t} + c(B_{t+1},K_{t}) + p^{k}_{t}I_{t}(1+\Phi_{t}) + DIV_{t} + \tau^{p}_{t}p^{k}_{t}K_{t} + TE_{t} + \Psi(VN_{t})}_{\text{financial outflows}}
\end{split}
\end{equation}

\noindent\noindent Here, $p_{t}$ is the price of output, $B_{t+1}$ is the stock of debt at the beginning of period $t+1$ (so that new debt issues in period $t$ are equal to $B_{t+1}-B_{t}$), $VN_{t}$ are new equity issues (as noted above).  Labor costs are given by the wage rate times the number of effective labor units employed, $w_{t}EL_{t}$.  The interest rate of bond holdings is given by $r_{b,t}$ and the costs of holding debt are given by $c(B_{t+1},K_{t+1})$.  These costs might represent bankruptcy costs and other frictions in the debt markets.  The variable $p^{k}_{t}$ denotes the price of capital, $I_{t}$ represents investment, and $\Phi_{t}$ are the costs to adjusting the capital stock through new investment.  The firm also pays dividends, $DIV_{t}$, property taxes at a marginal rate of $\tau^{p}$ on the nominal value of its capital stock, income taxes $TE_{t}$, and costs to new equity issues, $\Psi(VN_{t})$.  Costs to new equity issues represent frictions in the equity markets such as those arising from information asymmetries.

We impose to constraints on variables in the cash flow constraint: $DIV_{t}\geq0$ and $VN_{t}\geq0$.  In practice, firm's can and do buy back shares, but we restrict share repurchases in the model since the IRS treats share repurchases as dividends if they are done on a regular basis.  Our model therefore restricts the distribution of firm value to shareholders to be through dividend issues.  Note that we do not impose a constraint debt.  Positive values of $B$ indicate firm borrowing, while negative values represent firm saving.  Thus, retained earnings are held in the form of bonds that earn a rate of return $r_{b,t}$.

The law of motion of the capital stock is given by:
\begin{equation}
\label{eqn:lom_capital}
K_{t+1}=(1-\delta)K_{t} + I_{t},
\end{equation}

It is assumed that costs of debt take the following form:

\begin{equation}
\label{eqn:debt_cost}
c(B_{t+1},K_{t}) = \chi_{bk}\left(\frac{B_{t+1}}{K_{t}}\right)^{\ve_{bk}},
\end{equation}

\noindent\noindent where $\chi_{bk}$ is a scaling parameter and $\ve_{bk}$ is the curvature parameter. \textcolor{red}{Note the timing convention used here.  Leverage is determined by the current capital stock, not the one-period ahead capital stock.  While the investment made with the loan may be used as collateral for the loan, we assume that the costs of debt depend upon the ratio the loan to the current capital stock. This seems realistic if there is uncertainty about the potential value of the investments.  We will need to adjust this cost function in a way so that savings (i.e., $B<0$) result in no cost.}

Adjustment costs are assumed to be a quadratic function of deviations from the steady-state investment rate:
\begin{equation}
\label{eqn:adj_cost}
\Phi_{t}=\frac{\left(\frac{\beta}{2}\right)\left(\frac{I_{t}}{K_{t}}-\mu\right)^{2}}{\left(\frac{I_{t}}{K_{t}}\right)}
\end{equation}

\noindent\noindent The parameter $\beta$ is the scaling parameter for the adjustment cost function and $\mu$ is the steady-state investment rate, which is determined as $\mu=\delta+g_{y}+g_{n}$

Costs to new equity issues are assumed to be of the form:

\begin{equation}
\label{eqn:equity_cost}
\Psi(VN_{t})= \psi_{1}VN_{t} + \psi_{2}VN_{t}^{2}
\end{equation}

\textcolor{red}{We can play around with these function forms.  The key points are that we have increasing marginal costs in each. It's also very convenient for the steady state costs of adjusting the capital stock to equal zero.  We also need to think about forms that are easy to calibrate and want to avoid fixed costs (and other non-convexities) that may make computation difficult.}

If the firm has a net financial surplus before choosing it's financial policy (dividends, new equity, bond holdings), then it will either save the excess, earning a rate of return $r_{b,t}$ or will distribute the excess as dividends.  In making this choice it will consider the corporate income tax rate to the gains return on retained earnings as well as the capital gains taxes on the marginal investor in the benefits to the retained earnings.  It will consider taxes on dividend income in the benefits to dividend distributions.  If the firm has net financial deficit, then it will use new equity and/or bond issues to satisfy the cash flow constraint. In making this choice, it will consider the costs of debt and equity as well as the tax implications of each.  In particular, that interest payments on debt may be tax deductible and that the after-tax dilution of shareholder value is affected by the capital gains tax rate.

\subsubsection{Accounting Concepts}

It is useful to define some accounting concepts.  We define firm profits from a financial accounting perspective as:

\begin{equation}
\label{eqn:profit_book}
\Pi^{book}_{t} = p_{t}X_{t}-w_{t}EL_{t}-\delta K_{t} -\Phi_{t}p^{k}_{t}I_{t}-(1+r_{b,t})B_{t}- c(B_{t+1},K_{t})-\tau^{p}_{t}K_{t}-TE_{t}
\end{equation}

We define firm profits from a tax accounting perspective as:
\begin{equation}
\label{eqn:profit_tax}
\begin{split}
\Pi^{tax}_{t}= & p_{t}X_{t}-w_{t}EL_{t}-f_{e,t}p^{K}_{t}I_{t}-\Phi_{t}I_{t}-f_{i,t}r_{b,t}B_{t}-f_{c,t}c(B_{t+1},K_{t})+f_{p,t}\delta B_{t}+...\\
& f_{b,t}B_{t+1}-f_{d,t}\delta^{\tau}_{t}K^{\tau}_{t}-f_{ace,t}r_{ace,t}K^{\tau}_{t}-\tau^{p}_{t}p^{k}_{t}K_{t}
\end{split}
\end{equation}

\noindent\noindent Note that we are assuming that investment may or may not be deductible (depending upon the dummy variable $f_{e,t}$), but that investment adjustment costs are always deductible (i.e., they are not preceded by $f_{e,t}$).  Under a pre-pay consumption tax system, investments are not deductible from the tax base.  Whether or not adjustment costs are deductible under a pre-pay consumption tax depends upon what you think these costs derive from.  For example, if adjustment costs are from retraining employees to use new equipment, then these costs may be deductible under a consumption tax system (pre or post-pay) because they would likely be in the form of wage/labor costs.\footnote{It's not clear how best to handle this and \citet{DZ2013} are vague on this point.}  The other indicator variables, $f_{i,t}$, $f_{c,t}$,$f_{p,t}$, $f_{b,t}$, $f_{d}$, and $f_{ace,t}$, allow for various consumption tax policies to be incorporated into the model.  The parameter $f_{i,t}=1$ if interest on debt is deductible and 0 if not (\textcolor{red}{Since we will allow firms to lend with their retained earnings, we need to think about that fact that this indicator is not always symmetric.  That is, one might have a tax system where interest income is taxes, but interest payments are not deductible (or fully deductible).}).  The indicator $f_{c,t}$ equals one if debt costs are deductible (\textcolor{red}{Not sure if we want this - maybe just assume they are deductible are capital adjustment costs are.}).  The parameter $f_{p,t}$ is equal to one the principle on corporate borrowing is deductible from the corporate income tax based.  Principle on loans would be deductible in a post-pay consumption tax system.  The parameter $f_{b,t}$ is equal to one if the proceeds from firm borrowing is included in the corporate tax base.  Such proceeds would be included in a pre-pay consumption tax system.  The parameter $f_{d,t}$ is equal to one if capital can be depreciated and zero if not.  For example, in a post-pay consumption tax framework, $f_{e,t}=1$ and $f_{d,t}=0$. We allow for allowance of corporate equity (ACE) policies through the $f_{ace,t}$ indicator variable, which equals one if there is an allowance for corporate equity.  We use the notation $r_{ace,t}$ for the rate of return use for the corporate equity allowance.  In practice, this maybe set to $r_{b,t}$ or $r_{e,t}$ or another rate of return. \textcolor{red}{The fiscal capital stock is currently used as the basis for the ACE system.  I think this needs to be adjusted for the fraction of the capital stock that is supported by equity, but I'm not totally sure.}

The tax basis of the capital stock is given by $K^{\tau}_{t}$.  The law of motion for the tax basis of the capital stock is given by:

\begin{equation}
\label{eqn:lom_taxcapital}
K^{\tau}_{t+1}=(1-\delta^{\tau}_{t})(K^{\tau}_{t} + (1-f_{e})p^{K}_{t}I_{t}),
\end{equation}

%\noindent\noindent where $\delta^{\tau}$ is the rate if depreciation for tax purposes.  Note how we form the law of motion for the tax basis.  The above formulation accounts for the fact that investment in year $t$ receives a depreciation deduction in year $t$.\footnote{The IRS specifies a partial year rule, where one deducts the value of investment proportional to the amount of the year in which the asset was in place.  We ignore this detail and assume all assets are in place for the entire year.}  We can think about modifying this so that you get no deduction in the year the investment is made, which may or may not be more consistent with the ``time to build" built into the law of motion for the physical capital stock.
%
%
%\noindent\noindent Note that $K^{\tau}_{u}$ tracks depreciation deductions in in all periods $u=t,...,\infty$.  Future depreciation deductions on the tax basis of the capital stock in existence at time $u$ do not affect investment decisions at time $u$ (or forward) since the tax basis is predetermined.\footnote{Note that if there were financial frictions (e.g. a borrowing constraint or costly external finance), then investment would be dependent on cash flow and would then be affected by changes in the value of deductions for the existing capital basis.}  However, future depreciation deductions for investments made at time $u$ do affect investment decisions (since they lower the after-tax cost of investment).  Therefore it's useful to distinguish between old and new capital.
%
%The time $u$ value of future depreciation deductions on the capital stock existing at the beginning of period $u$ is given by $K^{\tau}_{u-1}$.  We can determine this value as:
%
%\begin{equation}
%\label{eqn:z}
%\begin{split}
%f_{d}Z_{u}K^{\tau}_{u-1} &=  \sum^{\infty}_{j=u} \prod_{\nu=u}^{j} \left(\frac{1}{1+\theta_{\nu}}\right)f_{d}\Omega_{j}\tau^{b}_{j}\delta^{\tau}(1-\delta^{\tau})^{j-u}K^{\tau}_{u} \\
%&= f_{d} K^{\tau}_{u-1} \underbrace{\sum^{\infty}_{j=u} \prod_{\nu=u}^{j} \left(\frac{1}{1+\theta_{\nu}}\right)f_{d}\Omega_{j}\tau^{b}_{j}\delta^{\tau}(1-\delta^{\tau})^{j-u}}_{Z_{u}} \\
%& = f_{d} K^{\tau}_{u-1} Z_{u},
%\end{split}
%\end{equation}
%
%\noindent\noindent where $Z_{u}$ is the net present value of future depreciation deductions per dollar of investment.  With this, we derive the time $u$ value of future depreciation deductions on investments made at time $u$, $I^{\tau}_{u}$.  These are given by $f_{d}(1-f_{e})Z_{u}I_{u}$.  Now we can rewrite Equation \ref{eqn:vs} describing the value of the firm at time $t$ as:
%
% \begin{equation}
%\label{eqn:vs_w_z}
%\begin{split}
%V_{t} = &  \sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right) (1-\tau^{b}_{u})\Omega_{u}(p_{u}X_{u}-w_{u}EL_{u})  \\
% & - K_{t} \left\{(1-\tau^{b}_{u})\Omega_{u}\tau^{p}_{u}+(1-f_{i}\tau^{i}_{u})i_{u}\Omega_{u}b-\delta(p_{u}-b-\Omega_{u}(p_{u}-f_{p}\tau^{b}_{u}b))\right\}  \\
% & - I_{u}\left\{1-b+\Omega_{u}f_{b}\tau^{b}_{u}b-\Omega_{u}f_{e}\tau^{b}_{u} - f_{d}(1-f_{e})Z_{u} + (1-\Omega_{u}\tau^{b}_{u})\Phi_{u}\right\} \\
% &  + f_{d}Z_{t}K^{\tau}_{t-1} \\
%\end{split}
%\end{equation}

Total income taxes on the firm are thus given by:

\begin{equation}
\label{eqn:corp_tax}
\begin{split}
TE_{t}= \tau^{b}_{t}\Pi^{tax}_{t} +\tau^{ic}_{t}p^{K}_{t}I_{t},
\end{split}
\end{equation}

\noindent\noindent  where $\tau^{b}_{t}$ is the tax rate on business income will be used to represent either an entity level tax or the tax rate on the distributions of income to owners for those firms not subject to an entity level tax.

\subsection{Optimal Firm Policy}

Using the cash flow constraint, we can solve for dividends as a function of the other endogenous variables, exogenous variables, and parameters:

\begin{equation}
\label{eqn:div}
\begin{split}
DIV_{t}&=\Pi^{book}_{t} + B_{t+1} + VN_{t}\\
 & = p_{t}X_{t}+ B_{t+1} + VN_{t}-w_{t}EL_{t}-\delta K_{t} -\Phi_{t}p^{k}_{t}I_{t}-(1+r_{b,t})B_{t} - c(B_{t+1},K_{t})-\tau^{p}_{t}K_{t}-TE_{t}
\end{split}
\end{equation}

The problem of the firm is maximize firm value, $V_{t}$, to the constraints on dividends and equity issues, and the laws of motion for the economic and fiscal capital stock.  That is, it solves:

\begin{equation}
\label{eqn:V_max}
\begin{split}
        &V_{t}= \max_{\{DIV_{u},VN_{u}, I_{u}, K_{u+1}, EL_{u}, B_{u+1}, K^{\tau}_{u+1},p_{u}\}^{\infty}_{u=t}} \sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[ \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)DIV_{u}-VN_{u}\right]\\
        &\text{subject to:} \\
        &DIV_{u}\geq 0\\
        &VN_{u}\geq 0\\
        &K{u+1}=(1-\delta)K_{u}+ I_{u} \\
        &K^{\tau}_{t+1}=(1-\delta^{\tau}_{t})(K^{\tau}_{t} + (1-f_{e})p^{K}_{t}I_{t})
      \end{split}
    \end{equation}

We can substitute in Equation \ref{eqn:div} for $DIV_{t}$ in the above and write the Lagrangian of the firm's problem as:

 \begin{equation}
\label{eqn:lagrangian}
\begin{split}
\mathcal{L}_{t} =& \max_{\{VN_{u}, I_{u}, K_{u+1}, EL_{u}, B_{u+1}, K^{\tau}_{u+1},p_{u}\}^{\infty}_{u=t}}   \sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right) \left[ \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right) \left(p_{u}X_{t}+ B_{u+1}... \right. \right. \\
& \left. \left.  + VN_{u}-w_{u}EL_{u}-\delta K_{u} -\Phi_{u}p^{k}_{u}I_{t}-(1+r_{b,u})B_{u} - c(B_{t+1},K_{t})-\tau^{p}_{u}K_{u}-TE_{u}\right)  - VN_{u} ...\right. \\
&\left. + q_{u}\left((1-\delta)K_{u}+I_{u}-K_{u+1}\right) + \lambda^{\tau}\left((1-\delta^{\tau}_{u})(K^{\tau}_{u}+(1-f_{e,u})p^{k}_{u}I_{u})-K^{\tau}_{u+1}\right) ...\right. \\
& \left.+ \lambda^{v}_{t}VN_{u} ... \right. \\
& \left. + \lambda^{d}\left(p_{u}X_{u}+ B_{u+1} + VN_{u} - w_{u}EL_{u} - (1+r_{b,u})B_{u} - c(B_{u+1},K_{u+1})... \right.\right.\\
& \left.\left. - p^{k}_{u}I_{u}(1+\Phi_{u}) - \tau^{p}_{u}p^{k}_{u} - TE_{u} -\Psi(VN_{u})\right) \right]
\end{split}
\end{equation}

The maximization problem yields the following first order conditions:

With respect to labor:
\begin{equation}
\label{eqn:foc_l}
\begin{split}
&\frac{\partial \mathcal{L}_{t}}{\partial EL_{u}} = \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[ \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)\left[p_{u}MPL_{u} - w_{u} - \frac{\partial TE_{u}}{\partial EL_{u}}\right] ... \right. \\
& \left. - \lambda^{d}_{u}\left[p_{u}MPL_{u} - w_{u} - \frac{\partial TE_{u}}{\partial EL_{u}}\right] \right] = 0  \\
& \implies  p_{u}MPL_{u}- \frac{\partial TE_{u}}{\partial EL_{u}} = w_{u}
\end{split}
\end{equation}

Labor demand is determined through this intratemporal trade off between the costs and benefits of employing additional labor in the production process. The left hand side gives the marginal revenue, or benefits from employing more labor, and the right hand save gives the costs, which are the wages paid to the additional labor.

With respect to investment:
 \begin{equation}
\label{eqn:foc_i}
\begin{split}
\frac{\partial \mathcal{L}_{t}}{\partial I_{u}} & =  \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right) \left[ q_{u} + \lambda^{\tau}_{u}(1-\delta^{\tau}_{u})(1-f_{e,u})p^{k}_{u} -  \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right) \left[p^{k}_{u}(1+ \frac{\partial \Phi_{u}}{\partial I_{u}}I_{u} + \Phi_{u}) + \frac{\partial TE_{u}}{\partial I_{u}} \right] - \right. \\
& \left. \lambda^{d}_{u}\left[p^{k}_{u}(1+ \frac{\partial \Phi_{u}}{\partial I_{u}}I_{u} + \Phi_{u}) + \frac{\partial TE_{u}}{\partial I_{u}} \right]\right]= 0 \\
& \implies q_{u} + \lambda^{\tau}_{u}(1-\delta^{\tau}_{u})(1-f_{e,u})p^{k}_{u} =  \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}} + \lambda^{d}_{u}\right)\left[p^{k}_{u}(1+ \frac{\partial \Phi_{u}}{\partial I_{u}}I_{u} + \Phi_{u}) + \frac{\partial TE_{u}}{\partial I_{u}}\right]
\end{split}
\end{equation}

With respect to the one-period ahead capital stock:

 \begin{equation}
\label{eqn:foc_k}
\begin{split}
 \frac{\partial \mathcal{L}_{t}}{\partial K_{u+1}}  &=  - \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)q_{u}  + \prod_{\nu=t}^{u+1}\left(\frac{1}{1+\theta{\nu}}\right)\left[(1-
\delta)q_{u+1} ... \right. \\
&\left. +    \left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}}\right)\left[p_{u+1}MPK_{u+1} - p^{k}_{u+1}\frac{\partial \Phi_{u+1}}{\partial K_{u+1}}I_{u+1} - \frac{\partial c(B_{u+2},K_{u+1})}{\partial K_{u+1}}-\tau^{p}_{u+1}p^{k}_{u+1}-\frac{\partial TE_{u+1}}{\partial K_{u+1}} \right] \right. \\
& \left. - \lambda^{d}_{u}\left[p_{u+1}MPK_{u+1} - p^{k}_{u+1}\frac{\partial \Phi_{u+1}}{\partial K_{u+1}}I_{u+1} - \frac{\partial c(B_{u+2},K_{u+1})}{\partial K_{u+1}}-\tau^{p}_{u+1}p^{k}_{u+1}-\frac{\partial TE_{u+1}}{\partial K_{u+1}} \right] \right] = 0 \\
&\implies q_{u} = \left(\frac{1}{1+\theta_{u+1}}\right)\left[(1-\delta)q_{u+1} ... \right. \\
& \left. +  \left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u+1} \right)\left[p_{u+1}MPK_{u+1}- p^{k}_{u+1}\frac{\partial \Phi_{u+1}}{\partial K_{u+1}}I_{u+1}  ... \right.\right. \\
& \left.\left.- \frac{\partial c(B_{u+2},K_{u+1})}{\partial K_{u+1}}-\tau^{p}_{u+1}p^{k}_{u+1}-\frac{\partial TE_{u+1}}{\partial K_{u+1}} \right] \right]
\end{split}
\end{equation}

\noindent\noindent The Euler equation described in Equation \ref{eqn:foc_i} relates Tobin's $q$, given by $q_{u}$, to the marginal costs of investment.  Tobin's $q$ defines the marginal change in firm value for a dollar of investment. It is the shadow price of additional capital.  The FOC for investment says that the firm invests until the marginal benefit (the LHS of Equation \ref{eqn:foc_i}) is equal to the marginal cost of investment (the RHS of Equation \ref{eqn:foc_i}).  The cost of investment in the absence of taxes and frictions is equal to the price of capital (the first term on the RHS of Equation \ref{eqn:foc_i}).  The second term reflects the reduction in the cost of capital due to debt financing.  The third term on the RHS of Equation \ref{eqn:foc_i} is the change in the cost of capital due to debt being included or excluded from business entity-level income taxes.  The fourth term reflects the reduction in the cost of capital due to depreciation deductions.  The last term reflects the component of the cost of capital that is due to adjustment costs (net of the expensing of adjustment costs for tax purposes).

With respect to one-period ahead bond holdings:
 \begin{equation}
\label{eqn:foc_b}
\begin{split}
 \frac{\partial \mathcal{L}_{t}}{\partial B_{u+1}}  &=  \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)\left(1-\frac{\partial c(B_{u+1},K_{u}}{\partial B_{u+1}}-\frac{\partial TE_{u}}{\partial B_{u+1}}\right) ... \right. \\
 & \left. +  \lambda^{d}_{u}\left(1-\frac{\partial c(B_{u+1},K_{u})}{\partial B_{u+1}}-\frac{\partial TE_{u}}{\partial B_{u+1}}\right) \right] ... \\
 & -  \prod_{\nu=t}^{u+1}\left(\frac{1}{1+\theta{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}}\right)\left((1+r_{b,u+1})+\frac{\partial TE_{u+1}}{\partial B_{u+1}}\right)... \right. \\
 & \left. + \lambda^{d}_{u+1}\left((1+r_{b,u+1})+\frac{\partial TE_{u+1}}{\partial B_{u+1}}\right)\right] = 0 \\
& \implies \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}} + \lambda^{d}_{u} \right)\left(1-\frac{\partial c(B_{u+1},K_{u})}{\partial B_{u+1}}-\frac{\partial TE_{u}}{\partial B_{u+1}}\right)= \\
&  \left(\frac{1}{1+\theta_{u+1}}\right) \left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u} \right) \left((1+r_{b,u+1})+\frac{\partial TE_{u+1}}{\partial B_{u+1}}\right)
 \end{split}
\end{equation}

With respect to new equity issues:
 \begin{equation}
\label{eqn:foc_vn}
\begin{split}
 \frac{\partial \mathcal{L}_{t}}{\partial VN_{u}}  &=  \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)\left(1-\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\right) - 1 + \lambda^{v}_{u} + \lambda^{d}_{u}\left(1-\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\right) \right] = 0 \\
 & \implies 1 = \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}} + \lambda^{d}_{u}\right)\left(1-\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\right) + \lambda^{v}_{u}
 \end{split}
\end{equation}

With respect to the one-period ahead fiscal capital stock:
 \begin{equation}
\label{eqn:foc_ktau}
\begin{split}
 \frac{\partial \mathcal{L}_{t}}{\partial K^{\tau}_{u+1}}  &=  - \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta{\nu}}\right)\lambda^{\tau}_{u} -  \\
 & \prod_{\nu=t}^{u+1}\left(\frac{1}{1+\theta{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}}\right)\frac{\partial TE_{u+1}}{\partial K^{\tau}_{u+1}} - \lambda^{\tau}_{u+1}(1-\delta^{\tau}_{u+1}) + \lambda^{d}_{u+1}\frac{\partial TE_{u+1}}{\partial K^{\tau}_{u+1}} \right] = 0 \\
& \implies \lambda^{\tau}_{u} = \left(\frac{1}{1+\theta_{u+1}}\right)\left[\left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u+1} \right)\frac{- \partial TE_{u+1}}{\partial K^{\tau}_{u+1}} + \lambda^{\tau}_{u+1}(1-\delta^{\tau}_{u+1})\right]
 \end{split}
\end{equation}

The final endogenous variable to solve for is the value of the firm at any point in time, $V_{u}$.  As \citet{Hayashi1982} shows, with a constant returns to scale production function and quadratic adjustment costs, there is an equivalence between marginal $q$ and average $q$.  \textcolor{red}{Is it ok that we have a production function that is CRS, but DRS with respect to capital and labor???}  Note that in our case, we must make an adjustment for the value of depreciation deductions on the tax basis of the capital stock already in place at time $u$.  The relation between marginal $q$, given by $q_{u}$, and average $q$, given by $Q_{u}$ is:
 \begin{equation}
\label{eqn:avg_q}
\begin{split}
q_{u}=\frac{[V_{u}-f_{d}Z_{u}K^{\tau}_{u-1}]}{K_{u}} \text{ and } Q_{u}=\frac{V_{u}}{K_{u}},
\end{split}
\end{equation}

\noindent\noindent where $Z_{u}$ is the net present value of depreciation deductions on the existing capital stock.  This relationship thus allows use to determine the value of the firm as:

 \begin{equation}
\label{eqn:solve_firmvalue}
\begin{split}
 V_{u}=q_{u}K_{u}+f_{d}Z_{u}K^{\tau}_{u-1}
\end{split}
\end{equation}

\textcolor{red}{Note that price is endogenous, but there is no first order condition for this choice that makes sense here since we don't have a demand function.  To pin down this endogenous variable we'll use the condition that with free entry, the equilibrium price will equal the firm's marginal cost. To do this, we need to write the marginal cost of producing a unit of output.  And for price to be determined, we need this to be constant over all amounts of output (which is not the case with a DRS production function).  Or, can we set price equal to marginal cost then solve for the output price as a function of the factor prices (r,w)? }

We can write the derivatives of the tax function with respect to the endogenous variables as:

\begin{equation}
\label{eqn:d_te_l}
\frac{\partial TE_{u}}{\partial EL_{u}}= \tau^{b}_{u}\left(p_{u}MPL_{u}- w_{u} \right)
\end{equation}

\begin{equation}
\label{eqn:d_te_i}
\frac{\partial TE_{u}}{\partial I_{u}}= -\tau^{b}_{u}\left(f_{e,u}p^{k}_{u} + p^{k}_{u}\left(\frac{\partial \Phi_{u}}{\partial I_{u}} + \Phi_{u}\right)\right) + \tau^{ic}_{t}p^{k}_{t}
\end{equation}

\begin{equation}
\label{eqn:d_te_kp1}
\frac{\partial TE_{u}}{\partial K_{u+1}}= 0
\end{equation}

\begin{equation}
\label{eqn:d_te_k}
\frac{\partial TE_{u}}{\partial K_{u}}= \tau^{b}_{u}\left( p_{u}MPK_{u} - p^{k}_{u}\frac{\partial \Phi_{u}}{\partial K_{u}}I_{u} - f_{c,u}\frac{\partial c(B_{u+1},K_{u})}{\partial K_{u}}- \tau^{p}_{u}p^{k}_{u}\right)
\end{equation}

\begin{equation}
\label{eqn:d_te_bp1}
\frac{\partial TE_{u}}{\partial B_{u+1}}= -\tau^{b}_{u}\left( f_{c,u}\frac{\partial c(B_{u+1},K_{u})}{\partial B_{u+1}} + f_{b,u}\right)
\end{equation}

\begin{equation}
\label{eqn:d_te_b}
\frac{\partial TE_{u}}{\partial B_{u}}= -\tau^{b}_{u}\left(f_{i,u}r_{b,u} + f_{p,u} \right)
\end{equation}

\begin{equation}
\label{eqn:d_te_b}
\frac{\partial TE_{u}}{\partial K^{\tau}_{u}}= -\tau^{b}_{u}\left(f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)
\end{equation}

Using these partial derivatives of the tax function with respect to the endogenous variables, we can rewrite the FOCs as:

\begin{equation}
\label{eqn:foc_l_tax}
\begin{split}
 p_{u}MPL_{u} = w_{u}
 \end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_i_tax}
\begin{split}
 & q_{u} + \lambda^{\tau}_{u}(1-\delta^{\tau}_{u})(1-f_{e,u})p^{k}_{u} =  \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}} + \lambda^{d}_{u}\right)\left[(1-f_{e,u}\tau^{b}_{u} - \tau^{ic}_{t})p^{k}_{u}+ (1-\tau^{b}_{u})p^{k}_{u}\left(\frac{\partial \Phi_{u}}{\partial I_{u}} + \Phi_{u}\right) \right]
\end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_k_tax}
\begin{split}
 q_{u} & = \left(\frac{1}{1+\theta_{u+1}}\right)\left[(1-\delta)q_{u+1} ... \right. \\
& \left. +  \left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u+1} \right)\left[(1-\tau^{b}_{u+1})\left(p_{u+1}MPK_{u+1}- p^{k}_{u+1}\frac{\partial \Phi_{u+1}}{\partial K_{u+1}}I_{u+1}\right)  ... \right.\right. \\
& \left.\left.-(1-f_{c,u+1}\tau^{b}_{u+1}) \frac{\partial c(B_{u+2},K_{u+1})}{\partial K_{u+1}} \right] \right]
\end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_b_tax}
\begin{split}
&  \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}} + \lambda^{d}_{u} \right)\left((1-\tau^{b}_{u}f_{b,u})-(1-\tau^{b}_{u}f_{c,u})\frac{\partial c(B_{u+1},K_{u})}{\partial B_{u+1}}\right)= \\
&  \left(\frac{1}{1+\theta_{u+1}}\right) \left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u} \right) \left((1+\tau^{b}_{u+1}f_{p,u+1})+(1-\tau^{b}_{u+1}f_{i,u+1})r_{b,u+1}\right)
 \end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_vn_tax}
\begin{split}
1 = \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}} + \lambda^{d}_{u}\right)\left(1-\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\right) + \lambda^{v}_{u}
 \end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_ktau_tax}
\begin{split}
 \lambda^{\tau}_{u} = \left(\frac{1}{1+\theta_{u+1}}\right)\left[\left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u+1} \right)\left(f_{d,u+1}\delta^{\tau}_{u+1}+f_{ace,u+1}r_{ace,u+1}\right)\tau^{b}_{u+1} + \lambda^{\tau}_{u+1}(1-\delta^{\tau}_{u+1})\right]
 \end{split}
\end{equation}

\subsubsection{Optimal Investment Policy}

\ \\
\noindent\noindent \emph{User cost of capital}

Let $ucc_{t}$ denote the user cost of capital of the firm in period $t$.  We define $ucc_{t}$ such that it is equal to the entity-level-tax marginal cash flow from an additional dollar of investment:

\begin{equation}
ucc_{t} = (1-\tau^{b}_{t+1})\left(p_{t+1}MPK_{t+1}-\tau^{p}_{t+1}p^{k}_{t+1}\right)- (1-\tau^{b}_{t+1}) \frac{\partial c(B_{t+2},K_{t+1})}{\partial K_{t+1}}
\end{equation}

We can use Equation \ref{eqn:foc_k_tax} to rewrite the LHS:

\begin{equation}
ucc_{t} =  \left[\left({1+\theta_{u+1}}\right)q_{t} - (1-\delta)q_{u+1}\right] \left(\frac{1-\tau^{d}_{u+1}}{1-\tau^{g}_{u+1}} + \lambda^{d}_{u+1} \right)^{-1}
\end{equation}

Using Equation \ref{eqn:foc_i_tax} we have:

\begin{equation}
\begin{split}
ucc_{t} &=  \left[\left({1+\theta_{u+1}}\right)\left[\left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}} + \lambda^{d}_{t}\right)\left[(1-f_{e,t}\tau^{b}_{t}-\tau^{ic}_{t})p^{k}_{t}+ (1-\tau^{b}_{t})p^{k}_{t}\left(\frac{\partial \Phi_{t}}{\partial I_{t}} + \Phi_{t}\right)\right]... \right.\right. \\
& \left.\left. -\lambda^{\tau}_{t}(1-\delta^{\tau}_{t})(1-f_{e,t})p^{k}_{t}\right] - (1-\delta)\left[\left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1}\right)... \right.\right. \\
& \left.\left. \times \left[(1-f_{e,t+1}\tau^{b}_{t+1}-\tau^{ic}_{t+1})p^{k}_{t+1}+ (1-\tau^{b}_{t+1})p^{k}_{t+1}\left(\frac{\partial \Phi_{t+1}}{\partial I_{t+1}} + \Phi_{t}\right)\right]... \right.\right. \\
& \left.\left. -\lambda^{\tau}_{t+1}(1-\delta^{\tau}_{t+1})(1-f_{e,t})p^{k}_{t+1}\right]\right] \left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1} \right)^{-1}
\end{split}
\end{equation}

Using Equation \ref{eqn:foc_ktau_tax} and iterating forward, we can find the value of $\lambda^{\tau}$ as:
\begin{equation}
\begin{split}
& \lambda^{\tau}_{t}=\underbrace{\prod_{\nu=t+!}^{\infty}\left(\frac{1}{1+\theta_{\nu}}\right)\lambda^{\tau}_{\infty}}_{=0 \text{ by transversality condition}} + \sum_{u=t+1}^{\infty} \prod_{\nu=t+1}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]\\
&\implies  \lambda^{\tau}_{t}= \sum_{u=t+1}^{\infty} \prod_{\nu=t+1}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]
\end{split}
\end{equation}

Substituting in for $\lambda^{\tau}$ and multiplying through we have:

\begin{equation}
\begin{split}
ucc_{t} &=  \left({1+\theta_{u+1}}\right)\left[\left(\frac{\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}} + \lambda^{d}_{t}}{\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1}}\right)\left[(1-f_{e,t}\tau^{b}_{t}-\tau^{ic}_{t})p^{k}_{t}+ (1-\tau^{b}_{t})p^{k}_{t}\left(\frac{\partial \Phi_{t}}{\partial I_{t}} + \Phi_{t}\right)\right]... \right. \\
& \left. -  \left( \sum_{u=t+1}^{\infty} \prod_{\nu=t+1}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]\right) (1-\delta^{\tau}_{t})(1-f_{e,t})p^{k}_{t}\right] ...   \\
& - (1-\delta)\left[ \left((1-f_{e,t+1}\tau^{b}_{t+1}-\tau^{ic}_{t+1})p^{k}_{t+1}+ (1-\tau^{b}_{t+1})p^{k}_{t+1}\left(\frac{\partial \Phi_{t+1}}{\partial I_{t+1}} + \Phi_{t}\right)\right] ... \right. \\
& \left. - \left(  \sum_{u=t+2}^{\infty} \prod_{\nu=t+2}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right] \right)(1-\delta^{\tau}_{t+1})(1-f_{e,t})p^{k}_{t+1}\right]
\end{split}
\end{equation}

If taxes are equal to zero, adjustment costs are zero, and the dividend constraint is not binding then this simplifies to:

\begin{equation}
ucc_{t}= (r_{e,t}+ \delta)p^{k}_{t} - (p^{k}_{t}-p^{k}_{t})
\end{equation}

Which is the familiar user cost of capital in models without taxes and frictions affecting investment.  Where the cost of capital is equal to the market rental rate for capital  plus the rate of depreciation, less capital gains from holding capital.\\

\ \\
\noindent\noindent \emph{Optimality Condition for Investment}

We can use Equations \ref{eqn:foc_i_tax}, \ref{eqn:foc_k_tax}, and \ref{eqn:foc_b_tax} to find the optimality condition for investment as:

\begin{equation}
\begin{split}
&\underbrace{ \left[(1-\tau^{b}_{t}f_{e,t}-\tau^{ic}_{t})p^{k}_{t} + \left(\frac{\partial \Phi_{t}}{\partial I_{t}} + \Phi_{t}\right)(1-\tau^{b}_{t})\right]\left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}} + \lambda^{d}_{t}\right)}_{\text{MC of investment}} = \\
& \left(\frac{1}{1+\theta_{t+1}}\right)\left[(1-\delta)q_{t+1}  +  \left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1} \right)\left[(1-\tau^{b}_{t+1})\left(p_{t+1}MPK_{t+1}- p^{k}_{t+1}\frac{\partial \Phi_{t+1}}{\partial K_{t+1}}I_{t+1}\right)  ... \right.\right. \\
& \left.\left.-(1-f_{c,t+1}\tau^{b}_{t+1}) \frac{\partial c(B_{t+2},K_{t+1})}{\partial K_{t+1}} \right] \right] ...\\
&  + (1-\delta^{\tau}_{t})(1-f_{e,t})p^{k}_{t}\left(\sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]\right)
\end{split}
\end{equation}

We can solve for $q_{t}$ using Equation \ref{eqn:foc_i_tax} and repeated iteration of Equation \ref{eqn:foc_ktau_tax} to find $\lambda^{\tau}_{t}$:

\begin{equation}
\begin{split}
q_{t+1} & =  \left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1}\right)\left[(1-f_{e,t+1}\tau^{b}_{t+1}-\tau^{ic}_{t+1})p^{k}_{t+1}+ (1-\tau^{b}_{t+1})p^{k}_{t+1}\left(\frac{\partial \Phi_{t+1}}{\partial I_{t+1}} + \Phi_{t+1}\right)\right]... \\
&  -  (1-\delta^{\tau}_{t+1})(1-f_{e,t+1})p^{k}_{t+1}\left(\sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]\right)
\end{split}
\end{equation}

With this, we rewrite the condition for optimal investment as:

\begin{equation}
\begin{split}
&\underbrace{ \left[(1-\tau^{b}_{t}f_{e,t}-\tau^{ic}_{t})p^{k}_{t} + \left(\frac{\partial \Phi_{t}}{\partial I_{t}} + \Phi_{t}\right)(1-\tau^{b}_{t})\right]\left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}} + \lambda^{d}_{t}\right)}_{\text{MC of investment}} = \\
& \left(\frac{1}{1+\theta_{t+1}}\right)\left[(1-\delta)\left[\left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1}\right)\left[(1-f_{e,t+1}\tau^{b}_{t+1}-\tau^{ic}_{t+1})p^{k}_{t+1}+ (1-\tau^{b}_{t+1})p^{k}_{t+1}\left(\frac{\partial \Phi_{t+1}}{\partial I_{t+1}} + \Phi_{t+1}\right)\right]...\right.\right. \\
& \left.\left.  -  (1-\delta^{\tau}_{t+1})(1-f_{e,t+1})p^{k}_{t+1}\left(\sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]\right)\right]... \right. \\
& \left. +  \left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1} \right)\left[(1-\tau^{b}_{t+1})\left(p_{t+1}MPK_{t+1}- p^{k}_{t+1}\frac{\partial \Phi_{t+1}}{\partial K_{t+1}}I_{t+1}\right)  ... \right.\right. \\
& \left.\left.-(1-f_{c,t+1}\tau^{b}_{t+1}) \frac{\partial c(B_{t+2},K_{t+1})}{\partial K_{t+1}} \right] \right] ...\\
&  + (1-\delta^{\tau}_{t})(1-f_{e,t})p^{k}_{t}\left(\sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+\theta_{\nu}}\right)\left[\left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}+\lambda^{d}_{u}\right)\left( f_{d,u}\delta^{\tau}_{u}+f_{ace,u}r_{ace,u} \right)\tau^{b}_{u}\right]\right)
\end{split}
\end{equation}

A few notes about this condition.  First, if dividend policy does not change from one period to the next (i.e., $\lambda^{d}_{t}=\lambda^{d}_{t+1}$ for all $t$), and if the ratio of the net of tax rates for dividend and capital gains income does not change (i.e., $\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}}=\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}}$ for all $t$), then dividend taxes have no impact on investment.  This corresponds to the ``new view" of dividend taxation.  In this case, dividend taxes have no effect on investment decisions whether that investment is financed by retained earnings or not.  The key is that the marginal source of finance is constant (i.e., $\lambda^{d}_{t}=\lambda^{d}_{t+1}$, for all $t$) .  Instead, dividend taxes are capitalized into the value of the firm, but has no effect on marginal investment decisions.  The second thing to note is that in the absence of taxes and investment frictions and with the prices of capital and output normalized to one, we get the familiar optimal condition for investment  $r=MPK-\delta$.

\subsubsection{Optimal Financial Policy}

\begin{proposition}
\label{prop:vn_div}
New equity issues and dividend distributions will not both be positive if the capital gains tax rate is less than the dividends tax rate (i.e., if $\tau^{g}_{u}<\tau^{d}_{u}$).
\end{proposition}

\begin{proof}
Suppose that $DIV_{u}>0$ and $VN_{u}>0$, then Equation \ref{eqn:foc_vn} simplifies to:
 \begin{equation}
\label{eqn:foc_vn_pos}
 1 = \left(\frac{1-\tau^{d}_{u}}{1-\tau^{g}_{u}}\right)\left(1-\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\right)
 \end{equation}

Which implies that :
  \begin{equation}
  \label{eqn:foc_vn_pos2}
 1-\tau^{g}_{u} = (1-\tau^{d}_{u})\left(1-\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\right)
 \end{equation}

But Equation \ref{eqn:foc_vn_pos2} can't hold if $\tau^{g}_{u}<\tau^{d}_{u}$, because so long as $\frac{\partial \Psi(VN_{u})}{\partial VN_{u}}\geq0$, then the left hand side of the equality exceeds the right hand side.  Thus, firms will never both issue equity and distribute dividends in the same period.
\end{proof}

In fact, we do observe firms in the data do both, and the behavior has been terms the ``dividend puzzle".  To model this, you need to suppose some capital market imperfections that our model abstracts from.

Note that if $\tau^{g}_{u}>\tau^{d}_{u}$, firms may issue new equity and distribute dividends.  If the marginal costs of new equity issues is increase, firms will issue new equity up to the point that the marginal cost of new equity (through dilution of after-tax capital gains to current share holders) is equal to the marginal benefit (the after-tax dividend income to current shareholders).  If marginal costs to new equity issues are flat or constant, we are in one of two cases.  The first is where costs are relatively high (relative to the differential in capital gains and dividend taxes) and firms never issues dividends and new equity in the same period.  The second is where costs are relatively low and no equilibrium exists.  In this case, the marginal benefits of new equity issues always exceed the marginal costs and so they firm issues infinite amounts of new equity to finance dividend distributions.\\

\ \\

\noindent\noindent \emph{The Marginal Cost of Finance}

\textcolor{red}{Is there a way to write the marginal cost of finance?  Is it always the same?  I see it changing as the source of financing changes between debt, equity, and retained earnings.}

If the firm's marginal source of finance is debt, then the marginal cost of finance is given by:

\begin{equation}
\begin{split}
mcf_{b,t} & = \left(\frac{1}{1+\theta_{t+1}}\right)\left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1}\right)\left((1-\tau^{b}_{t+1}f_{i,t+1})r_{b,t+1}+(1-\tau^{b}_{t+1}f_{p,t+1})\right)... \\
& + \left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}} + \lambda^{d}_{t}\right)(1-\tau^{b}_{t})\frac{\partial c(B_{t+1},K_{t})}{\partial B_{t+1}}
\end{split}
\end{equation}

\textcolor{red}{Can we determine when/if a firm will raise debt and distribute dividends?  It's a bit harder here since the firm can lend (i.e., hold negative debt), but there should be some condition on the benefits to a dollar inside of the firm versus a dollar of debt.  For example, if $mcf_{b,t}>1$, then the firm does not both issue debt and distribute dividends.}

\textcolor{red}{Since the opportunity cost of using retained earnings for investment is that it can't be lent out (where it earns a rate of return $r_{b,t}$), isn't the marginal cost of finance from retained earnings similar to the above?  Or at least something like the following (which explicitly shows that the cost of debt is asymmetric (i.e., the cost is zero when lending):}

\begin{equation}
mcf_{re,t} =  \left(\frac{1}{1+\theta_{t+1}}\right)\left(\frac{1-\tau^{d}_{t+1}}{1-\tau^{g}_{t+1}} + \lambda^{d}_{t+1}\right)(1-\tau^{b}_{t+1}r_{b,t+1}
\end{equation}

The marginal cost of equity finance is given by the dilution of shareholder value plus the costs due to financial frictions that lower the amount raised that can be used for investment:

\begin{equation}
mcf_{e,t} =  1+ \left(\frac{1-\tau^{d}_{t}}{1-\tau^{g}_{t}} + \lambda^{d}_{t}\right)\frac{\partial \Psi(VN_{t})}{\partial VN_{t}}
\end{equation}

If use external finance, the firm may use both debt and equity. If this is the case, then their marginal costs must be equivalent in equilibrium.

\textcolor{red}{HOW DOES THIS FINANCIAL POLICY FIT WITH INVESTMENT POLICY?  I think that the FOCs for investment and labor demand determine the amount of labor and capital.  Then financing is determined by what is needed finance the purchase of these factors of production. Where the firm using the cheaper source until it is exhausted or it's marginal cost equals that of the other sources.  However, it seems like there marginal costs of finance would be important in determining the investment policy (e.g., if financing is cheaper, then you invest more...).  Is that all contained in $\lambda^{d}_{t}$?}

\subsection{Firm Policy in the Steady State}

In the steady state, the first order conditions of the firm look like the following:

\begin{equation}
\label{eqn:foc_l_ss}
 \bar{p}\overline{MPL} - \frac{\partial \overline{TE}}{\partial \overline{EL}}= \bar{w}
\end{equation}

 \begin{equation}
\label{eqn:foc_i_ss}
\bar{q} + \bar{\lambda}^{\tau}(1-\bar{\delta}^{\tau})(1-\bar{f}_{e})\bar{p}^{k} =  \left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d}\right)\left[\bar{p}^{k}(1 + \frac{\partial \overline{TE}}{\partial \bar{I}}\right]
\end{equation}

 \begin{equation}
\label{eqn:foc_k_ss}
\bar{q}_{u} = \left(\frac{1}{\bar{\theta}+\delta}\right) \left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d} \right)\left[\bar{p}\overline{MPK} - \frac{\partial c(\bar{B},\bar{K})}{\partial \bar{K}}-\bar{\tau}^{p}\bar{p}^{k}-\frac{\partial \overline{TE}}{\partial \bar{K}} \right]
\end{equation}

 \begin{equation}
\label{eqn:foc_b_ss}
\left(1-\frac{\partial c(\bar{B},\bar{K})}{\partial \bar{B}}-\frac{\partial \overline{TE}}{\partial \bar{B}}\right)=   \left(\frac{1}{1+\bar{\theta}}\right) \left((1+\bar{r}_{b})+\frac{\partial \overline{TE}}{\partial \bar{B}}\right)
\end{equation}

 \begin{equation}
\label{eqn:foc_vn_ss}
 1 = \left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d}\right)\left(1-\frac{\partial \Psi(\overline{VN})}{\partial \overline{VN}}\right) + \bar{\lambda}^{v}
\end{equation}

 \begin{equation}
\label{eqn:foc_ktau_ss}
 \bar{\lambda}^{\tau} = -  \left(\frac{1}{\bar{\theta}+\bar{\delta}^{\tau}}\right)\left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d} \right)\frac{\partial \overline{TE}}{\partial \bar{K}^{\tau}}
\end{equation}

Using these partial derivatives of the tax function with respect to the endogenous variables in the SS, we can rewrite the FOCs as:

\begin{equation}
\label{eqn:foc_l_tax_ss}
\begin{split}
 \bar{p}\overline{MPL} = \bar{w}
 \end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_i_tax_ss}
\begin{split}
 & \bar{q} + \bar{\lambda}^{\tau}(1-\bar{\delta}^{\tau})(1-\bar{f}_{e})\bar{p}^{k} =  \left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d}\right)\left[(1-\bar{f}_{e}\bar{\tau}^{b}-\bar{\tau}^{ic})\bar{p}^{k}\right]
\end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_k_tax_ss}
\begin{split}
\bar{q}_{u} = \left(\frac{1}{\bar{\theta}+\delta}\right) \left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d} \right)\left[(1-\bar{\tau}^{b})\left(\bar{p}\overline{MPK}\right)-(1-\bar{f}_{c}\bar{\tau}^{b}) \frac{\partial c(\bar{B},\bar{K})}{\partial \bar{K}} \right]
\end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_b_tax}
\begin{split}
 \left((1-\bar{\tau}^{b}\bar{f}_{b})-(1-\bar{\tau}^{b}\bar{f}_{c})\frac{\partial c(\bar{B}_{u},\bar{K})}{\partial \bar{B}}\right)=  \left(\frac{1}{1+\bar{\theta}}\right) \left((1+\bar{\tau}^{b}\bar{f}_{p})+(1-\bar{\tau}^{b}\bar{f}_{i})\bar{r}_{b}\right)
 \end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_vn_tax_ss}
\begin{split}
 1 = \left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d}\right)\left(1-\frac{\partial \Psi(\overline{VN})}{\partial \overline{VN}}\right) + \bar{\lambda}^{v}
 \end{split}
\end{equation}

 \begin{equation}
\label{eqn:foc_ktau_tax_ss}
\begin{split}
 \bar{\lambda}^{\tau} =  \left(\frac{1}{\bar{\theta}+\bar{\delta}^{\tau}}\right)\left(\frac{1-\bar{\tau}^{d}}{1-\bar{\tau}^{g}} + \bar{\lambda}^{d} \right)\bar{\tau}^{b}\left(\bar{f}_{d}\bar{\delta}^{\tau}+\bar{f}_{ace}\bar{r}_{ace}\right)
 \end{split}
\end{equation}

We also can write the laws of motion for the physical and fiscal capital stocks in the steady state as:

\begin{equation}
\label{eqn:lom_k_ss}
\bar{I}=\delta\bar{K}
\end{equation}

\begin{equation}
\label{eqn:lom_ktau_ss}
\bar{K}^{\tau}=(1-\bar{f}_{e})\bar{p}^{k}\bar{K}
\end{equation}

In equilibrium, firm value must be positive.  This implies that $\overline{DIV}>\overline{VN}$.  As shown in Proposition \ref{prop:vn_div}, if $\bar{\tau}^{g}<\bar{\tau}^{d}$, the firm will not both issue new equity and distribute dividends.  Therefore, if $\bar{\tau}^{g}<\bar{\tau}^{d}$ we know that $\overline{DIV}>0$ and $\overline{VN}=0$.  The means that $\bar{\lambda}^{v}>0$ and $\bar{\lambda}^{d}=0$.

\subsubsection{Solving for the Steady State}

By the above argument, we know that $\overline{DIV}>0$ and $\overline{VN}=0$.  Therefore $\bar{\lambda}^{d}=0$ .  We can thus solve for $\bar{\lambda}^{v}$ by Equation \ref{eqn:foc_vn_tax_ss} and $\bar{\lambda}^{\tau}$ by Equation \ref{eqn:foc_ktau_tax_ss}.  With these in hand, we can then solve for $\bar{q}(\bar{p}^{k})$ from Equation \ref{eqn:foc_i_tax_ss}.  Equations \ref{eqn:foc_l_tax_ss}, \ref{eqn:foc_k_tax_ss}, and \ref{eqn:foc_b_tax_ss} then imply $\bar{EL}$, $\bar{K}$, $\bar{B}$ as functions of $\bar{p}^{k}$ and $\bar{p}$.    We can then use the laws of motion (Equations \ref{eqn:lom_k_ss} and \ref{eqn:lom_ktau_ss}) to get $\bar{I}$ and $\bar{K}^{\tau}$ as functions of the input and output prices.  \textcolor{red}{The key is then to solve for the output prices as a function of the parameters and factor input prices ($\bar{r}_{b}$, $\bar{r}_{e}$ and $\bar{w}$).  To do this, we need to use the assumption of free entry and that prices equals marginal cost in equilibrium???}.  With the output price in hand, we use the fixed coefficient matrix relating industry outputs to industry inputs to find $\bar{p}^{k}$.  We are then able so solve the system of equations for given factor prices.

\section{The Problem of the Multinational Parent Corporation}

The problem of the multinational parent corporation will be defined similarly to that of the domestic corporation.  In particular, the functional forms for the production function and financial frictions will remain the same, though parameter values may differ.  What differs for the multinational parent is it's relations with foreign subsidiaries.  The parent provides intermediate inputs to the foreign subsidiaries and can choose the price at which these transactions occur.  This ability to engage in transfer pricing allows the multinational to lower it's worldwide tax liability by shifting net income to low tax jurisdictions.  Second, the parent can engage in more general income shifting by moving profits to tax havens.  The ability to shift income in this way captures the ability of corporations to shift income through other mechanisms that we do not explicitly model.  Finally, multinational corporations face a discrete location choice with respect to a firm-specific fixed factor of production.

\subsection{Firm Production}

Firm's combine capital, $K$, and effective labor, $EL$, with a location-specific fixed factor of production, $A$, and firm-specific fixed-factor of production, $H$, to produce output, $X$.  We can think of the location-specific fixed factor of production as ``location specific capital".  It is fixed in the sense that its supply is perfectly inelastic.  It is location specific in the sense that it is proportional to the size of the population in the firm's home country at time $t$. \textcolor{red}{CORTAX documentation at first suggests this factor is chosen optimally by the firm, but there is not first order condition for this choice shown.  The documentation does state that this factor is paid its marginal product.  So there are only economic profits before you account for the return to this factor of production.  I'm also not sure if we need this fixed factor of production to be proportional to the population.  CORTAX says yes so that you don't have productivity differential arising from differences in country size.  They consider multi-country model, but only steady state.  Do we need something similar so productivity doesn't depend upon population at time $t$?}  The firm-specific fixed factor of production can be thought of as intangibles, such as patents or trade secrets the firms has.  These intangibles earn economic rents and can easily be transfered to different tax jurisdictions (\textcolor{red}{Is this what we want to think of it as?  Then you'd think it could affect productivity not just in the country is is located.  Also, we need to be very careful about how to enter this into the model.  In particular, we don't want to have to keep track of the capital and labor entering into production functions in other counties as CORTAX does.}).  We write the amount of output produced in the home country as a function of this fixed factor and the value added, $VA$, from the input of capital and labor:

\begin{equation}
X_{t} = A_{t}H_{t}^{\alpha_{H}}(VA_{t})^{\alpha_{v}},
\end{equation}

\noindent\noindent where $\alpha_{v}$ is the share of output attributable to the firm's value added and $\alpha_{H}$ is the share of output attributable to the firm-specific capital. The location-specific fixed factor of production is given by:

\begin{equation}
A_{t} = (A_{0,t}\omega_{t}N_{t})^{1-\alpha_{H}-\alpha_{v}}
\end{equation}

\noindent\noindent Thus the input from fixed factor of production used by the firm is given by the level of total factor productivity (TFP), $A_{0,t}$, and a exogenous share of the population, $N_{t}$ where the share is given by the parameter $\omega_{t}$ (\textcolor{red}{Not sure if we want this to vary by time, or just across production industry.}).  The share parameters must sum to one.  That is, $\sum_{m=1}^{M} \omega_{m,t} = 1$.     We assume that TFP grows at the same rate across industry, with the growth rate given by $g_{a}$.  The value added is given by a CES function:

\begin{equation}
\label{eqn:prod_fun}
F(A_{0,t},K_{t},EL_{t})=VA_{t} =A_{0,t} \left[(\gamma_{})^{1/\epsilon_{}}(K_{t})^{(\epsilon-1)/\epsilon_{}}+(1-\gamma_{})^{1/\epsilon_{}}(e^{g_{y}t}EL_{t})^{(\epsilon_{}-1)/\epsilon_{}}\right]^{(\epsilon_{}/(\epsilon_{}-1))},
\end{equation}

\subsection{Firm Accounting}

The multinational corporation is going to maximize firm value, which is determined by its worldwide after-tax profit.  Thus we' will need to define domestic and foreign profits.

\subsubsection{Domestic Profits}

After-tax US profits from a financial accounting perspective are:

\begin{equation}
\label{eqn:profit_book_mnc_us}
\begin{split}
\Pi^{US,book}_{t} = & p_{t}X_{t}+\underbrace{(p_{row,t}-1)Q_{row,t}-c^{q}(Q_{row,t})}_{\text{Transfer pricing}}-w_{t}EL_{t}-\delta K_{t} -\Phi_{t}p^{k}_{t}I_{t}-(1+r_{b,t})B_{t}- c(B_{t+1},K_{t})...\\
& -\tau^{p}_{t}K_{t}-TE(\tilde{\Pi}^{US, tax}_{t})
\end{split}
\end{equation}

Transfer pricing operates through the multinational charging its subsidiaries in the rest of the world a price $p_{row,t}$ for one dollar of intermediate good.  The variable $Q_{row,t}$ denotes the quantity of intermediate goods (in dollars) that the firm sells/buys from its subsidiaries in the rest of the world.  There is a cost to transfer pricing, given by the function $c^{q}(Q_{row,t})$.

Note that total taxes, $TE$ are a function of taxable income after profit shifting, $\tilde{\Pi}^{US, tax}_{t}$. We define the firm's US profits from a tax accounting perspective as:
\begin{equation}
\label{eqn:profit_tax}
\begin{split}
\Pi^{US, tax}_{t}= & p_{t}X_{t}+\underbrace{(p_{row,t}-1)Q_{row,t}-c^{q}(Q_{row,t})}_{\text{Transfer pricing}}-w_{t}EL_{t}-f_{e,t}p^{K}_{t}I_{t}-\Phi_{t}I_{t}-f_{i,t}r_{b,t}B_{t}...\\
& -f_{c,t}c(B_{t+1},K_{t})+f_{p,t}\delta B_{t}+ f_{b,t}B_{t+1}-f_{d,t}\delta^{\tau}_{t}K^{\tau}_{t}-f_{ace,t}r_{ace,t}K^{\tau}_{t}-\tau^{p}_{t}p^{k}_{t}K_{t}
\end{split}
\end{equation}

We let $\theta$ be the amount of profits shifted overseas.  Thus, $\tilde{\Pi}^{US, tax}_{t}=\theta \Pi^{US, tax}_{t}$.  Shifting profits comes a a cost, $c^{ps}(\theta)$.  This cost function is a convex function so that the marginal cost of shifting income is increasing and will make it infinitely expensive to shift 100\% of profits.

\subsubsection{Foreign Profits}

Our model does not capture the the rich detail of production in each country.  Instead, we take the component of foreign profits due to foreign economic activity as exogenous.  We define two foreign jurisdictions.  The ``rest of the world" refers to non-tax haven countries.  Thus we bifurcate foreign economies into tax havens and non-tax havens.  We assume that transfer pricing activities tax place with corporate subsidiaries in the ``rest of the world", which we think of as trading partners.  Profit shifting activities represent interactions with tax havens.  We let pre-tax foreign earnings in period $t$ be defined as $EARN^{row}_{t}$ and $EARN^{h}_{t}$ for the rest of the world and tax haven jurisdictions, repsectively.  Foreign after-tax profits from an accounting perspective are thus defined as:

\begin{equation}
\label{eqn:profit_book_mnc_row}
\begin{split}
&\Pi^{row,book}_{t} =EARN^{row}_{t} - (p_{row,t}-1)Q_{row,t} - TE^{row}_{t}(\Pi^{row, tax}_{t})\\
&\text{and} \\
&\Pi^{h,book}_{t} EARN^{h}_{t} +  \theta\Pi^{US,book}_{t} - TE^{h}_{t}(\tilde{\Pi}^{h, tax}_{t}),
\end{split}
\end{equation}

where
\begin{equation}
\label{eqn:profit_tax_mnc_row}
\begin{split}
&\Pi^{row, tax}_{t} = EARN^{row}_{t} - (p_{row,t}-1)Q_{row,t}\\
&\text{and} \\
&\Pi^{h, tax}_{t} = EARN^{h}_{t} \\
&\text{and} \\
&\tilde{\Pi}^{h, tax}_{t}=   EARN^{h}_{t} + (1-\theta)\Pi^{US,tax}_{t},
\end{split}
\end{equation}

\subsubsection{Multinational Cash Flow}

The multinational's cash flow is defined by the sum of its profits at home and abroad:

\begin{equation}
\label{eqn:cash_flow_mnc}
\begin{split}
DIV_{t} = &  \underbrace{(1-\theta)\Pi^{US,book}_{t}}_{\text{After tax domestic profits}} + \underbrace{\Pi^{row,book}_{t}  + \Pi^{h,book}_{t}}_{\text{After tax foreign profits}} + B_{t+1} + VN_{t}
\end{split}
\end{equation}

Note that the above formulation makes some implicit assumptions about accounting rules.  The most relevant of which is that a dollar of taxable income shifted from the US equals one dollar of taxable income abroad.

The foreign tax functions are:

\begin{equation}
\label{eqn:foreign_tax_row}
TE^{row}_{t}(EARN^{row}_{t}- (p_{row,t}-1)Q_{row,t}) = \tau^{b,row}_{t}(EARN^{row}_{t} -  (p_{row,t}-1)Q_{row,t}),
\end{equation}

\begin{equation}
\label{eqn:foreign_tax_h}
TE^{h}_{t}(EARN^{h}_{t} + \theta\Pi^{US,tax}_{t}) = \tau^{b,h}_{t}(EARN^{h}_{t}  + \theta\Pi^{US,tax}_{t}),
\end{equation}

\noindent\noindent where $\tau^{b,row}_{t}$ and $\tau^{b,h}_{t}$ is the marginal effective tax rate on foreign profits in the non-tax haven and tax haven jurisdictions.  \textcolor{red}{Note about calibration: We likely calculate these as a weighted average of the corporate income tax rate on trading partners for firms in a given industry (for the rest of world) and to a rate amongst tax havens (probably zero).}

Letting $\Pi^{x,pre}_{t}$ denote pre-tax (and pre-transfer pricing) accounting profits in jurisdiction $x$ in period $t$, we can rewrite the firm's cash flow constraint as:

\begin{equation}
\label{eqn:cash_flow_mnc2}
\begin{split}
DIV_{t} = &  (1-\theta)\Pi^{US,pre}_{t} + (p_{row,t}-1)Q_{row,t}  - \tau^{b,US}_{t}((1-\theta)\Pi^{US,tax}_{t}) + \tau^{ic}_{t}p^{k}_{t}I_{t} ... \\
& + \Pi^{row,pre}_{t}- (p_{row,t}-1)Q_{row,t} - \tau^{b,row}_{t}\Pi^{row,tax}_{t} ...\\
& + \Pi^{h,pre}_{t}- \tau^{b,row}_{t}(\Pi^{h,tax}_{t} + \theta\Pi^{US,tax}_{t}) + B_{t+1} + VN_{t} \\
     = & \Pi^{US,pre}_{t} + EARN^{row}_{t} + EARN^{h}_{t} - ((1-\theta)\tau^{b,US}_{t} + \theta\tau^{b,h}_{t})\Pi^{US,tax}_{t} ...\\
     & + \tau^{b,row}(p_{row,t}-1)Q_{row,t} + \tau^{ic}_{t}p^{k}_{t}I_{t}   - \tau^{b,row}_{t}(EARN^{row}_{t}) - \tau^{b,h}_{t}(EARN^{h}_{t})  + B_{t+1} + VN_{t}
\end{split}
\end{equation}

\textcolor{red}{What about repatriation?  Do we need to wall off foreign profits from domestic dividends (or for use for domestic investment) unless they are subjected to the US tax?  Or should we assume they are freely available since the firm can use intracompany debt to move them?  If the latter, there should be some cost of this - a cost which is affected by policies on intracompany debt.  If the former, we'll need to keep track of the stock of foreign earnings.}

\textcolor{red}{Also, should we think about foreign tax credits in the above?  If repatriation, yes.  Then need to think about stock of earnings in tax havens and not...}

\subsubsection{Discrete Location Choice}

Recall the production function:

\begin{equation}
X_{i,t} = (A_{0,i,t}\omega_{i,t}N_{i,t})^{1-\alpha_{v}-\alpha_{H}}H_{i,t}^{\alpha_{H}}VA_{i,t}^{\alpha_{v}},
\end{equation}

\noindent\noindent where $i$ denotes the country and $H$ is the firm-specific capital that is mobile across countries.  We will assume that there are no adjustment costs associated with moving $H$.  This is helpful so that we do not need to keep track on the amount of firm-specific capital in the various tax jurisdictions.  It may therefore be best to think of this capital as firm-specific intangible capital like patents, brandnames, and managerial talent that may be relocated at relatively low cost. \textcolor{red}{One problem with this interpretation is that it would seem that the effect of $H$ could affect the firm's subsidiaries in all countries - regardless of where is was located.}

\textcolor{red}{\citet{DD2009} separate this decision from all others by showing that $H$ will be distributed in a way that is proportional to the tax rates and amount of capital and labor employed across countries.  Can we do this?  Seems like you need to choose $H$ jointly with $K$, and $EL$ since $H$ affects marginal productivities of these... But can you separate given the functional form of the production function?}

Note that we don't want to have to track the capital and labor employed abroad.  But with the functional form of this production function, we don't have to.  Consider:

\begin{equation}
\begin{split}
 EARN_{i,t}=p_{i,t}X_{i,t} = p_{i,t}(A_{0,i,t}\omega_{i,t}N_{i,t})^{1-\alpha_{v}-\alpha_{H}}H_{i,t}^{\alpha_{H}}VA_{i,t}^{\alpha_{v}} \\
\end{split}
\end{equation}

If we increase $H$ by a factor of $\lambda$ we increase earnings by $\lambda^{\alpha_{H}}$:
\begin{equation}
\begin{split}
X2_{i,t} = (A_{0,i,t}\omega_{i,t}N_{i,t})^{1-\alpha_{v}-\alpha_{H}}(\lambda H_{i,t})^{\alpha_{H}}VA_{i,t}^{\alpha_{v}} \\
X2_{i,t} = (A_{0,i,t}\omega_{i,t}N_{i,t})^{1-\alpha_{v}-\alpha_{H}}\lambda^{\alpha_{H}} H_{i,t}^{\alpha_{H}}VA_{i,t}^{\alpha_{v}} \\
X2_{i,t} = \lambda^{\alpha_{H}}(A_{0,i,t}\omega_{i,t}N_{i,t})^{1-\alpha_{v}-\alpha_{H}} H_{i,t}^{\alpha_{H}}VA_{i,t}^{\alpha_{v}} \\
X2_{i,t} = \lambda^{\alpha_{H}}X_{i,t}
\end{split}
\end{equation}

Thus, we can just increase foreign pre-tax earnings by the amount that $H$ is shifted to that jurisdiction.

\subsubsection{Why 3 ways to shift profits?}

There are three ways that multinational firms can shift income across tax jurisdictions:
\begin{enumerate}
\item Transfer pricing
\item Shifting of profits
\item Location of firm-specific capital
\end{enumerate}

There three all differ in how they affect the firm.  Transfer pricing and profit shifting affect firm profits in very similar ways.  The fundamental difference between the two in the model is the effective tax rate the shifted income faces.  We assume that transfer pricing is done with trading partners and therefore faces the tax rate $\tau^{b,row}$.  On the other hand, profit shifting is doing to a particularly low tax jurisdiction and faces a rate that applies to tax havens, $\tau^{b,h}$.  If the US corporate rate would drop, this relieves pressure on transfer pricing to a greater degree than profit shifting because of the differences in rates between tax haven and non-tax haven countries (the tax haven's having very low rates).

The third channel through which firms can shift profits is by locating firm-specific capital abroad.  The movement of this capital not only affects income, but affects firm productivity in domestic and foreign jurisdictions.  That is to say that this form of profit shifting will have direct equilibrium effects on the pre-tax returns to labor and capital.  It should also be the cast that this discrete locational choice is based on average tax rates, rather than marginal tax rates.  \textcolor{red}{Not sure if the model has is set up this way.}

\section{Multinational Subsidiaries}

I think we can get away with the exogenous foreign pre-tax earnings as noted above and we do not need to model foreign subs.  We can also probably get away with just one firm per production industry with a level of exogenous foreign activity that varies across industry.  We can also have the parameters of income shifting vary across industry to match observed income shifting activity across sectors.

    \section{Relating Firm Investment and Production Goods}\label{sec:prod_invest_map}

    Our model contains $M$ production industries, each of which chooses investment that is a composite good from these production processes.  We denote the quantity of production good $m$ in period $t$ as $X_{m,t}$.  We relate the output of the production sectors to their inputs using a fixed coefficient model. That is, each investment good is made up of a mix of the outputs of different production sectors.  This means that the composition of these investment goods do not respond to prices.  The weights that determine the mix for each consumption goods are given in the matrix $\Xi$.  Element $\xi_{j,m}$ of the matrix $\Xi$ corresponds to the percentage contribute of the output of industry $m$ in the production of the investment good for industry $j$.  The total supply of investment good $j$ in the economy at time $t$ is thus given by:

             \begin{equation} \label{eqn:mix_cons}
             I_{j,t} = \sum_{m=1}^{M}\xi_{j,m}X_{m,t}
    	\end{equation}

	And thus the price of a unit of investment good for industry $m$ at time $t$ is:

             \begin{equation} \label{eqn:mix_cons_price}
             p^{K}_{j,t} = \sum_{m=1}^{M}\xi_{j,m}p_{m,t},
    	\end{equation}

    Where $p_{m}$ is the price of output of production sector $m$ at time $t$.


\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{cite}
\usepackage[margin=1.2in]{geometry}

\providecommand{\eqn}[1]{eqn.~(\ref{eqn:#1})}
\providecommand{\tab}[1]{Table~\ref{tab:#1}}
\providecommand{\fig}[1]{Figure~\ref{fig:#1}}

\providecommand{\vecsymbol}[1]{\ensuremath{\boldsymbol{#1}}}
%\providecommand{\pv}{\vecsymbol{p}}
%\providecommand{\deltav}{\vecsymbol{\delta}}

\title{Observing Hour Angle Assignments\\
for the DESI Survey\\
\vspace{5mm}{\large\bf DESI-doc-3060-v1}}
\author{David Kirkby, Kyle Dawson}

\begin{document}
\maketitle

\section{Introduction}

This note briefly describes the algorithm used to assign a near-optimal observing hour angle (HA) to each tile in the DESI footprint~\cite{desi-717} and documents the result for the current baseline survey strategy~\cite{desi-1767, desi-1770}.

The algorithm is implemented in python code in the {\tt desisurvey} package\footnote{\url{https://github.com/desihub/desisurvey}} and the reader is referred there for implementation details. A jupyter notebook to create the plots in this note is provided under {\tt desisurvey/doc/nb/}. The LaTeX source for this note is maintained under {\tt desimodel/doc/tex/desi3060/}.

\section{Algorithm Description}

The algorithm is run separately for each program (DARK, GRAY, BRIGHT) and has two main inputs:
\begin{itemize}
    \item the date range to optimize the program for, and
    \item a list of tiles remaining to observe in the program.
\end{itemize}
The date range determines the available hours at each apparent local sidereal time (LST) for the specified program, taking into account planned shutdowns (during the annual monsoon and full-moon), expected weather outages each month, and the solar and lunar ephemerides that determine the time available to the program during each night. The list of tiles determines the required exposure time at each LST, given HA assignments and an exposure-time calculator.

The basic idea of the algorithm is to iteratively adjust the HA assignments of each tile to minimize a score function that accounts for two metrics:
\begin{itemize}
    \item the matching of available and planned LST usage, and
    \item the total required exposure time.
\end{itemize}
We run the algorithm in two different modes:
\begin{itemize}
    \item Start of survey: optimize all tiles over the nominal five-year survey dates.
    \item Afternoon planning: optimize all tiles not yet observed for the remainder of the survey.
\end{itemize}
The first mode is only used before the survey starts and then only needs to be rerun after a change in the definition of the tiles, programs, or nominal observing schedule. The second mode is run regularly during the survey and adjusts HA assignments to reflect actual observing progress and any schedule changes.

Most of the assumptions used in the survey planning and program definitions are listed in a text configuration parameter file\footnote{\url{https://github.com/desihub/desisurvey/blob/master/py/desisurvey/data/config.yaml}}. One parameter, in particular, limits the HA solution space by requiring that all tiles are observed above a minimum altitude angle of $30^\circ$.  In order to allow some leeway for exposure duration, we calculate a maximum $|\text{HA}|$ for each tile corresponding to its declination and a minimum altitude of $35^\circ$.

\subsection{Initialization}

The initial HA assignments that are subsequently optimized can be set in three different ways:
\begin{itemize}
    \item Read HAs from a file.
    \item Set all HAs to zero.
    \item Assign HAs to approximately match the cummulative distribution functions of available and planned LST usage.
\end{itemize}
The first method is used during afternoon planning, while the last two methods bootstrap the optimization at the start of the survey.

Assigning zero initial HAs minimizes the total exposure time required, but generally leads to a large mismatch between the available and planned LST usage. While conceptually simple, this approach is inefficient since it requires a large number of iterations to converge to a near-optimal solution. \fig{LST_zero0} compares the available and planned LST usage after initializing
all HAs to zero.

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{LST_zero0}
\caption{Available (red) and planned (blue) LST usage for the HA=0 initialization method.  The blue outline histogram shows the planned usage rescaled to the area of the available LST histogram.  The LST axis starts at $-60^\circ$ and the gaps in the planned usage correspond to the breaks between the southern and northern galactic caps in the DESI footprint.}
\label{fig:LST_zero0}
\end{center}
\end{figure}

An alternative bootstrap initialization, which we refer to as the ``flat'' method, is to approximately match the cummulative distribution of available LST to planned LST usage. We first tabulate the available survey time $a_j$ in $n$ LST bins
$$
\theta_j \le \theta < \theta_{j+1} \quad , \quad \theta_j = (j/n) 360^\circ \; ,
$$
where $j$ ranges from $0$ to $n-1$, then calculate its cummulative distribution function (CDF) in $n+1$ steps as
$$
A_0 = 0 \quad , \quad
A_{j+1} = \frac{\sum_{k=0}^{j} a_k}{\sum_{k=0}^{n-1} a_k} \; .
$$
Next, we approximate the CDF of planned LST usage of $i = 0, 1, \ldots, N-1$ tiles with all HAs equal zero as:
$$
P_i = \frac{\sum_{k=0}^{i} \Delta t_k}{\sum_{k=0}^N \Delta t_k} \; ,
$$
where $\Delta t_k$ is the expected exposure time for tile $k$ at HA=0 and tiles are ordered in increasing right ascension (RA). Finally, we match the available and planned CDFs by adjusting each tile's LST $\tilde{\theta}_i$ using linear interpolation of the inverse mapping $A_j \rightarrow \theta_j$ evaluated at each $P_i$.  We then select
$$
\text{HA}_i = \tilde{\theta}_i - \text{RA}_i
$$
as the initial HA for tile $i$.

Since LST and RA are periodic, the initial HAs obtained with this method depend on an arbitrary choice of starting angle, which corresponds to an LST where all tiles will have HA=0. In practice, we repeat this initialization on a grid of possible starting angles and select the one with the minimum score function (defined below). \fig{LST_flat0} compares the available and planned LST usage after initializing all HAs with this method. \fig{HA_flat0} shows the distribution of initial HAs over the sky for each pass of each program.

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{LST_flat0}
\caption{Available (red) and planned (blue) LST usage for the flat initialization method.  The blue outline histogram shows the planned usage rescaled to the area of the available LST histogram.  The LST axis starts at $-60^\circ$.}
\label{fig:LST_flat0}
\end{center}
\end{figure}

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{HA_flat0}
\caption{All-sky maps of the tiles in each pass (0-7) color coded by their initial HA assignment using the ``flat'' initialization method.  Passes 0-1 (top row), 2-4 (middle row) and 5-7 (bottom row) correspond to the DARK (0-3), GRAY (4) and BRIGHT (5-7) programs.  Histograms show the HA distribution in each pass, color coded by the pass program: black (DARK), gray (GRAY) and orange (BRIGHT).}
\label{fig:HA_flat0}
\end{center}
\end{figure}

This CDF-matching ``flat'' method does a good job of matching the available and planned LST usage, but generally increases the total exposure time required more than necessary. The approximations in this method are that:
\begin{itemize}
    \item Exposure times are calculated for HA=0 and then used to estimate non-zero HAs for each tile.
    \item The contribution from each exposure is assumed to contribute at a single LST rather than being spread of LST in proportion to the length of the exposure.
    \item The CDF matching procedure enforces that the ordering of tile LSTs matches the ordering of tile RAs, but this may not be optimal.
\end{itemize}
The iterative improvement scheme described below does not have any of these limitations.

\subsection{Exposure Times}

Exposure times for observing during the DARK program are estimated as:
$$
\Delta t = \Delta t_{\text{nom}}\, f_{\text{dust}}\, f_{\text{airmass}}\,
f_{\text{seeing}}\, f_{\text{transp}} \; ,
$$
where the nominal exposure time $\Delta t_{\text{nom}}$ is specified by the program (1000 seconds for DARK and GRAY, and 300s for BRIGHT) and the remaining dimensionless factors correct for the actual versus nominal observing conditions: dust extinction, airmass, seeing, and atmospheric transparency.

The dust factor is fixed by the median value of $E_{B-V}(\text{RA}, \text{DEC})$ over the tile and given by:
$$
f_{\text{dust}} = 10^{\alpha E_{B-V}}
\quad, \quad \alpha = 2.6424 \; .
$$
The airmass factor is a function of the airmass $X(\text{DEC}, \text{RA})$ and given by:
$$
f_{\text{airmass}} = X^{1.25} \; .
$$

The remaining DARK program exposure factors are due to atmospheric seeing and transparency, which vary stochastically during actual observing. For the purposes of HA optimization, we only need to account for their mean time-integrated effects, $F_x = \langle f_x\rangle$.  Our assumptions for seeing and transparency are detailed in~\cite{desi-3087} and summarized in \tab{expfac}. The combined effect seeing and transparency, which we assume to be uncorrelated, is a $\simeq 9$\% increase in exposure time which we
round up to 10\%.

\begin{table}[htb]
\begin{center}
\begin{tabular}{lcccccccc}
Condition & Nominal & Median & Mean & $F_x$ \\
\hline
      Seeing & $1.1$" & $1.10$" & $1.17$" & $1.03$ \\
Transparency & $1.0$  & $0.98$  & $0.94$  & $1.06$ \\
\hline
\end{tabular}
\caption{Summary of atmospheric seeing and transparency assumptions, and estimated time-integrated exposure-time factors. See~\cite{desi-3087} for details.}
\label{tab:expfac}
\end{center}
\end{table}

Exposure times during the GRAY and BRIGHT programs have an additional factor due to scattered moonlight, but further study is needed to accurately estimate its impact.  We therefore assign average exposure time factors to account for seeing, transparency and moon of: 1.10 (DARK), ?? (GRAY) and ?? (BRIGHT). These factors multiply the exposure times derived from dust and airmass in our HA optimization algorithm, but are expected to have a negligible impact on the assigned HAs.

\subsection{Iteration}

For details on the iteration scheme, refer to the {\tt optimize.Optimizer.improve} method of the {\tt desisurvey} package. Here we just provide a high-level sketch of the algorithm.

Each iteration is governed by an HA adjustment size parameter, $\delta\text{HA}$, which we gradually decrease in an outer loop as described in the next section. Given an adjustment size, we select a single tile to adjust then recompute the planned LST usage using its new HA and exposure time (due to its change of airmass with HA). The total number of iterations (single-tile adjustments) required to obtain near-optimal HA assignments starting from HA=0 is typically 20--30 times the total number of tiles. The algorithm has several stochastic elements in order to avoid getting stuck in a local minimum, but uses a single source of pseudo-random numbers to ensure reproducibility.

The score function that each iteration attempts to improve combines two figures of merit which we refer to as RSME and LOSS.

RMSE measures the fractional deviation between the available ($A_i$) and planned ($P_i$) LST usage histograms using
$$
\text{RMSE} \equiv \frac{1}{\sum_i^n P_i}
\left( n \sum_i^n (s A_i - P_i)^2 \right)^{1/2}
$$
where the scale factor
$$
s = (\sum_i^n P_i) / (\sum_i^n A_i)
$$
normalizes the total available LST to the total planned usage so that RMSE measures deviations in shape only.  LOSS compares the total exposure time required with the current plan ($T_P$) with the minimum possible total time ($T_0$) when all tiles are observed with HA=0, using
$$
\text{LOSS} \equiv (T_P - T_0) / T_0 \; .
$$
After some experimentation, we combine these dimensionless metrics with equal weight,
$$
\text{SCORE} = \text{RMSE} + \text{LOSS} \; ,
$$
so that RMSE typically dominates during the first phase of optimization, then LOSS dominates towards the end.  Typical final values after optimization are RMS $\simeq 1$\% and LOSS $\simeq 3$\%.

We automatically switch between two algorithms to select the set of candidate tiles to adjust during each iteration: a fast algorithm that is typically selected when RMSE dominates the score, and a slower brute-force algorithm that is typically selected when LOSS dominates.  The fast algorithm first identifies which LST bin would maximally improve RMSE when tiles are shifted away from it, and then only considers tiles whose exposures overlap that bin.  The slow algorithm considers a 20\% random subset of all tiles.  We next rank all tiles in the candidate set according to how much they improve the SCORE when adjusted. We usually pick the tile with the best improvement but will sometimes randomly pick a lower-ranked tile. The size of the HA adjustment is randomly generated from a Rayleigh distribution with mean fixed to the input adjustment-size parameter $\delta\text{HA}$.

\subsection{Annealing and Termination}

The {\tt surveyinit} script uses the {\tt optimize.Optimizer} class to coordinate the overall HA assignment task. Optimization proceeds in ``cycles'' of $n$ adjustments with fixed parameters, where $n$ equals the number of tiles to optimize. After each cycle, the distribution of HAs is smoothed over the sky,
$$
\text{HA}_j = (1 - \alpha)\,\text{HA}_j + \alpha\,\overline{\text{HA}}_j
$$
where $\overline{\text{HA}}_j$ is the weighted average of neighboring HAs,
$$
\overline{\text{HA}}_j = \sum_{k\ne j} \omega_{jk}\,\text{HA}_k \; ,
$$
and $\alpha$ controls the amount of smoothing.  Smoothing weights are Gaussian in the separation angle $\theta_{jk}$ between pairs of tiles,
$$
\omega_{jk} = \exp\left( -0.5(\theta_{jk} / \sigma_S)^2 \right) \; ,
$$
with a smoothing length $\sigma_S \simeq 10^\circ$.

After each complete cycle, the adjustment size $\delta\text{HA}$ and amount of smoothing $\alpha$ are annealed according to:
$$
\delta\text{HA} \rightarrow a \delta\text{HA} \quad, \quad
\alpha\rightarrow a \alpha \; ,
$$
with an annealing factor $a \simeq 0.95$.

Cycles are terminated once both of the following conditions are met:
\begin{itemize}
    \item RMSE below a preset threshold $\simeq 2$\%, and
    \item fractional change in SCORE larger than a preset threshold $\simeq -1\%$.
\end{itemize}
Cycles also terminate after a preset maximum number of cycles.  All of these presets can be modified via {\tt surveyinit} command-line arguments.

\section{Results}

\fig{LST_zero} and \fig{LST_flat} show the LST distributions obtained after optimizing initial HAs set to be zero or ``flat''.  \fig{HA_zero} and \fig{HA_flat} show the corresponding all-sky distributions of HAs for each tile.  Both methods match the available and planned LST usage to high accuracy and predict similar total exposure times and corresponding safety margins. However, they use qualitatively different HA distributions to achieve similar results, indicating that the HA-assignment optimization problem has many comparable local minima.  In the following, we select the ``flat'' initialization method since it has slightly better performance and more closely matches the algorithm used for BOSS and eBOSS.  \tab{summary} summarizes the planned LST usage in each program using ``flat'' initialization.  There is some safety margin for all programs with our assumed exposure-time model and survey schedule.

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{LST_zero}
\caption{Available (red) and planned (blue) LST usage after optimizing initial HA=0 assignments.  The blue outline histogram shows the planned usage rescaled to the area of the available LST histogram.  The LST axis starts at $-60^\circ$.}
\label{fig:LST_zero}
\end{center}
\end{figure}

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{LST_flat}
\caption{Available (red) and planned (blue) LST usage after optimizing initial HAs obtained with the ``flat'' method.  The blue outline histogram shows the planned usage rescaled to the area of the available LST histogram.  The LST axis starts at $-60^\circ$.}
\label{fig:LST_flat}
\end{center}
\end{figure}

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{HA_zero}
\caption{All-sky maps of the tiles in each pass (0-7) color coded by their initial HA assignment after optimizing initial HA=0 assignments.}
\label{fig:HA_zero}
\end{center}
\end{figure}

\begin{figure}[htb]
\begin{center}
\includegraphics[width=6in]{HA_flat}
\caption{All-sky maps of the tiles in each pass (0-7) color coded by their initial HA assignment after optimizing initial HA=0 assignments.}
\label{fig:HA_flat}
\end{center}
\end{figure}

\begin{table}[htb]
\begin{center}
\begin{tabular}{lcccc}
Program & Available & Planned & Stretch & Margin \\
\hline
DARK   & 5319.0h & 4784.9h & 1.4 & 11.2\% \\
GRAY   & 1357.8h & 1284.4h & 1.5 &  5.7\% \\
BRIGHT & 1899.8h & 1553.0h & 2.0 & 22.3\% \\
\hline
\end{tabular}
\caption{Summary of observing plan for each program based on the observing hour angle assignments obtained with the ``flat'' initialization method.}
\label{tab:summary}
\end{center}
\end{table}

\def\apjl{ApJL} %Astrophysical Journal Letters
\def\aj{AJ} %Astronomical Journal
\def\apj{ApJ} %Astrophysical Journal
\def\pasp{PASP} %Publications of the Astronomical Society of the Pacific
\def\spie{SPIE} %
\def\apjs{ApJS} %Astrophysical Journal Supplement
\def\araa{ARAA} %Annual Review of Astronomy and Astrophysics
\def\aap{A\&A} %Astronomy and Astrophysics
\def\aaps{A\&A~Supl.} %Astronomy and Astrophysics Supplement
\def\nat{Nature} %Nature
\def\nar{New Astron. Rev.} %New Astronomy Review
\def\mnras{MNRAS} %Monthly Notices of the Royal Astronomical Society
\def\jcap{JCAP} %Journal of Cosmology and Astroparticle physics
\def\prd{{Phys.~Rev.~D}}        % Physical Review D
\def\physrep{{Phys.~Reports}} % Physics Reports

\bibliographystyle{unsrt}
\bibliography{design_ha}

\end{document}