\documentclass[11pt]{article}
\usepackage{amsmath, amsfonts, amsthm, amssymb}  % Some math symbols
\usepackage{enumerate}
\usepackage{fullpage}

\usepackage[x11names, rgb]{xcolor}
\usepackage{tikz}
\usepackage[colorlinks=true, urlcolor=blue]{hyperref}
\usepackage{graphicx}
\usepackage{gensymb}

\usetikzlibrary{snakes,arrows,shapes}

\usepackage{listings}
\usepackage{array}
\usepackage{mathtools}
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\pagestyle{empty}

\def\indented#1{\list{}{}\item[]}
\let\indented=\endlist

\newcounter{questionCounter}
\newenvironment{question}[2][\arabic{questionCounter}]{%
    \addtocounter{questionCounter}{1}%
    \setcounter{partCounter}{0}%
    \vspace{.25in} \hrule \vspace{0.5em}%
        \noindent{\bf #2}%
    \vspace{0.8em} \hrule \vspace{.10in}%
}{}

\newcounter{partCounter}[questionCounter]
\renewenvironment{part}[1][\alph{partCounter}]{%
    \addtocounter{partCounter}{1}%
    \vspace{.10in}%
    \begin{indented}%
       {\bf (#1)} %
}{\end{indented}}

%%%%%%%%%%%%%%%%% Identifying Information %%%%%%%%%%%%%%%%%
%% This is here, so that you can make your homework look %%
%% pretty when you compile it.                           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\myhwname}{Homework 5}
\newcommand{\mysection}{CS Fundamentals: Pong Review: Math! [due Tuesday]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{center}
    {\Large \myhwname} \\
    \mysection \\
    \today
\end{center}

%%%%%%%%%%%%%%%%% PROBLEM 1: Probability Review %%%%%%%%%%%%%%%%%%%%%%%%%
\section{Review: Pong Game [Expected Duration: 15 - 20 min]}
\textbf{If you have any questions about the directions or any blocks you have not used before, let me know via email or text!}\\\\
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}\\
In the last lesson, we built together a very cool pong game together.
We built this cool calculator by using many things we learned previously and MATH.
For homework, I want you to do some math with angles. Math is quite important in programming! Have fun!\\\\
I want you to use the \textbf{word} bank below to complete this assignment.
Note that \textbf{the words in the word bank is used exactly once... all words are used}.\\\\
If you have any questions, \textbf{please} let me know!\\\\
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}\\
\textbf{Instructions/Notes:}\\
$0\degree = 360\degree = -360\degree$ is Up.\\
$90\degree = -270 \degree$ is East.\\
$-90\degree = 270 \degree$ is West.\\
$180\degree = -180\degree$ is South.\\\\
This homework is hard! You will need to know how to do reflection over x and y-axis. Do as best as you can! It is okay to not finish. Looking at the code for the pong game can help!
\\
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
\begin{enumerate}
\item \textbf{Bouncing off of the top wall}\\
The only walls the ball in pong can bounce off of are the ones on the bottom and at the top. Drawing pictures may help solve the problems below.
 % $\rule{2.5cm}{0.15mm}$
\begin{enumerate}[a.]
\item Let's say a ball was approaching the top wall at a $-45\degree$ (NorthWest) angle. To simulate bouncing off of the wall, we send the ball going at a $-135\degree$ (SouthWest) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\
\item If the ball was approaching the top wall at a $50 \degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection.)\\\\\\
\item Generally, if the ball was approaching the top wall at a $x \degree$ angle, what direction $y \degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\\\\\\\\\\\\
\end{enumerate}
\end{enumerate}
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
\begin{enumerate}
\item \textbf{Bouncing off of the bottom wall}\\
The only walls the ball in pong can bounce off of are the ones on the bottom and at the top. Drawing pictures may help solve the problems below.
 % $\rule{2.5cm}{0.15mm}$
\begin{enumerate}[a.]
\item Let's say a ball was approaching the bottom wall at a $135\degree$ (Southeast) angle. To simulate bouncing off of the wall, we send the ball going at a $45\degree$ (Northeast) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\
\item If the ball was approaching the bottom wall at a $-100 \degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection.)\\\\\\
\item Generally, if the ball was approaching the bottom wall at a $x \degree$ angle, what direction $y \degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\\\\\\\\\\\\\\\\\\\\\\
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item \textbf{Bouncing off of the right player's paddle}\\
There are 2 players in pongs. Each has a paddle. The balls can bounce off these paddles. Drawing pictures may help solve the problems below.
 % $\rule{2.5cm}{0.15mm}$
\begin{enumerate}[a.]
\item Let's say a ball was approaching the right player's paddle  at a $135\degree$ (Southeast) angle. To simulate bouncing off of the paddle, we send the ball going at a $-135 \degree$ (Southwest) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\
\item If the ball was approaching the right player's paddle at a $100 \degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection again.)\\\\\\
\item Generally, if the ball was approaching the right player's paddle at a $x \degree$ angle, what direction $y \degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\end{enumerate}
\end{enumerate}
\begin{enumerate}
\item \textbf{Bouncing off of the left player's paddle}\\
There are 2 players in pongs. Each has a paddle. The balls can bounce off these paddles. Drawing pictures may help solve the problems below.
 % $\rule{2.5cm}{0.15mm}$
\begin{enumerate}[a.]
\item Let's say a ball was approaching the left player's paddle  at a $-45\degree$ (NorthWest) angle. To simulate bouncing off of the paddle, we send the ball going at a $45 \degree$ (NorthEast) angle. Was this a reflection over the x-axis or the y-axis (think 2D coordinate! if you don't know what this means, email me!)?\\\\\\
\item If the ball was approaching the right player's paddle at a $120 \degree$ angle, what direction (degree) should the ball be traveling once the ball bounces? (Think reflection again.)\\\\\\
\item Generally, if the ball was approaching the right player's paddle at a $x \degree$ angle, what direction $y \degree$ shoudld the ball be traveling once the ball bounces? Write an equation for $y$ in terms of $x$. (note: this is hard! try your best! the code can help!)
\end{enumerate}
\end{enumerate}
\end{document}


\chapter{Government}
\index{Government%
@\emph{Government}}%

%\pagestyle{empty}

\section{Overview of government in the model}

The government has four functions in the model.  First, it runs the tax and social security systems as described in the households' and firms' problems.  That is, it collects revenues and makes payments in accordance with the parameterized tax and social security policy functions.  The tax functions are user determined, but will default to a current law baseline if the user does not specify a policy proposal in affecting the relevant tax function.  Second, the government makes direct transfers to households outside of the social security system.  Third, the government produces a non-excludable public good.  Finally, the government contributes to the production of a private consumption good.  We discuss each of these function in more detail below after first defining the government's budget constraint.
Government will have four functions in our model:

\section{Government budgeting}

The government's per-period budget constraint is given by:

      \begin{equation}
      \label{eqn:gbc}
      D_{t+1} + T^{\tau}_{t} = (1+r_{t})D_{t} + T^{H}_{t} + G^{subs}_{t} + w_{t}EL^{G}_{t} + p^{K}_{g}I^{G}_{t},
      \end{equation}

where $D_t$ denotes the government's outstanding debt, $T_t$ is total tax revenue across all tax sources and net of social security transfers, $T^H_t$ is total direct transfers to households, $G^{subs}_t$ are government subsides to the production private goods, $EL_t$ is are effective labor units employed by government in the production of the public good, and $I_t$ is government investment in capital used to produce the government provided public good.  The price of capital for the government sector is given by $p^{K}_{g}$ and the price of an effective labor unit is $w_{t}$.  Note that we do not impose a balanced budget.  In any particular period, the government may run a surplus or deficit.  The government finances any gaps using debt, $D_{t}$.

    \subsection{Rule for long-term fiscal stability}

      While the government can use debt to finance temporary budget shortfalls, the government cannot finance infinite amounts of debt.  For example, it cannot be the case that the debt level grows to such an extent that interest payments on the debt exceed GDP.  To ensure that the government budget is sustainable in the long run, we impose a rule that returns the debt-to-GDP ratio to some predetermined value after a set amount of time.  In particular, the user will select (or the model will default to) a particular steady-state debt-to-GDP ratio, $\bar{d}=\frac{\bar{D}}{\bar{Y}}$.  The model will then specify some period, $T$, such that after this time, the government budget adjusts to return to $\bar{d}$.  In particular, if the debt-to-GDP ratio exceeds $\bar{d}$, then government provision of the public good, $G_{t}$ is reduced.  This government debt rule takes the form:

%      \begin{equation}
%        D_{t+1} = D_t(1+r_t) - T_t + T^H_t + G_t + L_t + S_t
%      \end{equation}
%
%      Letting a carat denote the ratio of a variable to GDP, we can rewrite this as follows:
%
%      \begin{equation} \label{EqDhatlom}
%        (1+g_{Yt}) \hat D_{t+1} = \hat D_t(1+r_t) - \hat T_t + \hat T^H_t + \hat G_t + \hat L_t + \hat S_t
%      \end{equation}
%
%      We need to adopt a government fiscal rule that determines how our residual expenditure $\hat G_t$ evolves over time.
%
%      One way is to adopt a balanced budget rule which keeps the debt-to-GDP ratio constant at it's initial value of $\hat D_0$.
%
%      \begin{align}
%        (1+g_{Yt}) \hat D_0 & = \hat D_0(1+r_t) - \hat T_t + \hat T^H_t + \hat G_t + \hat L_t + \hat S_t \nonumber \\
%        \hat G_t & = \hat D_0(g_{Yt}-r_t) + \hat T_t - \hat T^H_t -\hat L_t - \hat S_t \label{EqBalBudRule}
%      \end{align}
%
%      Another rule is to hold govenrment spending constant and let debt evolve as it will for several period.  Then in period $T$ impose fiscal austerity which forces $\hat G_t$ to adjust over time so that $\hat D_t$ goes to a steady value.

      \begin{equation}
         G_{t} - \bar{G} = \rho_t (\hat{d}_t - \bar{d});\quad \rho_t<0,
        \label{EqAdjRule}
      \end{equation}

\noindent\noindent where $\hat{G}$ is the steady state level of public good (given steady-state debt-to-GDP ratio $\bar{d}$) and $\rho$ is a parameter that determines how quickly government debt returns to its steady-state value.  The parameter $\rho$ will be estimated from historical data on the response of government spending to debt.  This calibration is discussed in the calibration chapters to be added to this document.
%
%      Substituting this into \eqref{EqDhatlom} gives:
%      \begin{align}
%        (1+g_{Yt}) \hat D_{t+1} & = \hat D_t(1+r_t) - \hat T_t + \hat T^H_t + \rho_t (\hat D_t - \bar D) + \bar G + \hat L_t + \hat S_t \nonumber \\
%        \hat D_{t+1} & = \frac{\hat D_t(1+r_t) - \hat T_t + \hat T^H_t + \rho_t (\hat D_t - \bar D) + \bar G + \hat L_t + \hat S_t }{1+g_{Yt}} \label{EqDhatlom2}
%      \end{align}
%
%      Consider the steady state version of this.
%      \begin{align}
%        (1+\bar g_{Y}) \bar D & = \bar D(1+\bar r) + \bar T - \bar T^H + \rho_t (\bar D - \bar D) + \bar G + \bar L + \bar S_t  \nonumber \\
%        \bar G & = \bar D(\bar g_{Y} -\bar r) + \bar T - \bar T^H - \bar L - \bar S  \label{EqGbardef}
%      \end{align}
%
%      This tells us the long-run value of government spending to GDP that will maintain the debt to GDP target.
%
%      In order for \eqref{EqDhatlom2} to be a contraction mapping over $\hat D$ and thus converge to a steady state, we must put bounds on $\rho_t$.  Rearranging \eqref{EqDhatlom2} and using \eqref{EqGbardef}:
%
%      \begin{align}
%        \begin{split}
%        (1+g_{Yt}) \hat D_{t+1} & = \hat D_t (1+r_t) - \hat T_t + \hat T^H_t + \rho_t (\hat D_t - \bar D) + \hat L_t + \hat S_t \\
%        & + \bar D(\bar g_{Y} - \bar r) + \bar T - \bar T^H - \bar L - \bar S
%        \end{split} \nonumber \\
%        \begin{split}
%        (1+g_{Yt}) \hat D_{t+1} & = \hat D_t (1+r_t) - \hat T_t + \hat T^H_t + \rho_t \hat D_t - \rho_t \bar D + \hat L_t + \hat S_t \\
%        & + \bar g_Y \bar D - \bar r \bar D + \bar T - \bar T^H - \bar L - \bar S
%        \end{split} \nonumber \\
%        \begin{split}
%        (1+g_{Yt}) \hat D_{t+1} & =  \hat D_t (1+r_t) + \rho_t (\hat D_t -\bar D) + (\bar g_Y - \bar r ) \bar D \\
%        & - (\hat T_t - \bar T) + (\hat T^H_t -\bar T^H) + (\hat L_t -\bar L) + (\hat S_t -\bar S)
%        \end{split} \nonumber \\
%        \begin{split}
%        \hat D_{t+1} - \bar D & = \hat D_t \frac{1+r_t}{1+g_{Yt}} + \frac{\rho_t}{1+g_{Yt}} (\hat D_t -\bar D) + \left( \frac{\bar g_Y - \bar r}{1+g_{Yt}} - 1 \right) \bar D \\
%        & + \frac{-(\hat T_t - \bar T) + (\hat T^H_t -\bar T^H) + (\hat L_t -\bar L) + (\hat S_t -\bar S)}{1+g_{Yt}}
%        \end{split}  \nonumber \\
%        \begin{split}
%        \hat D_{t+1} - \bar D & = \frac{1+r_t+\rho_t}{1+g_{Yt}} (\hat D_t -\bar D) \\
%        & + \frac{-(\hat T_t - \bar T) + (\hat T^H_t -\bar T^H) + (\hat L_t -\bar L) + (\hat S_t -\bar S)}{1+g_{Yt}}
%        \end{split}
%        \label{EqStab}
%      \end{align}
%
%      We need $\frac{\hat D_{t+1} - \bar D}{\hat D_{t} - \bar D} < 1$ for stability.  Equation \eqref{EqStab} gives:
%      \begin{align}
%        \frac{\hat D_{t+1} - \bar D}{\hat D_t -\bar D} & = \frac{1+r_t+\rho_t}{1+g_{Yt}}  + \frac{-(\hat T_t - \bar T) + (\hat T^H_t -\bar T^H) + (\hat L_t -\bar L) + (\hat S_t -\bar S)}{(1+g_{Yt})(\hat D_t -\bar D)} < 1 \nonumber \\
%        & \frac{1+r_t+\rho_t}{1+g_{Yt}}  < \frac{(\hat T_t - \bar T) - (\hat T^H_t -\bar T^H) - (\hat L_t -\bar L) - (\hat S_t -\bar S)}{(1+g_{Yt})(\hat D_t -\bar D)} \nonumber \\
%        & \rho_t  < (1+r_t)\frac{(\hat T_t - \bar T) - (\hat T^H_t -\bar T^H) - (\hat L_t -\bar L) - (\hat S_t -\bar S)}{\hat D_t -\bar D}
%      \end{align}

 \section{Direct transfers}
      Direct transfers to individuals, $T^{H}_{t}$, will be modeled as a polynomial function of age and income.  In that sense, this function will be similar to those used to determine individual income taxes.  This function will be estimated from data on government transfers by age and income....

\section{Government production of public goods}

The government engages in the production of a non-excludable public good.  Utility from the public good enters the individuals' utility functions in an additively separable way, and thus is excluded from the description above since it does not impact consumer decisions.  To produce the public good, the government uses a capital and labor in a constant returns to scale Cobb-Douglas production function.  In particular, the total quantity of the public good is given by:

\begin{equation}
\label{eqn:pub_good}
G_{t} = (K^{G}_{t})^{\alpha}(EL^{G}_{t})^{1-\alpha}
\end{equation}

\noindent\noindent The parameter $\alpha$ thus represents capital's share of output of the public good.  The government's capital stock follows the standard law of motion: $K^{G}_{t+1} = (1-\delta^{G})K^{G}_{t} + I^{G}_{t}$.

We determine $G_{0}$ as the the total amount of spending on government goods and services less the purchase of inputs for government production of private goods in the model's base year.  We then set $G_{t}=G_{0}$ for all $t<T$.  At period $T$, the government budget may need to adjust $G_{t}$ to make debt sustainable.  Thus the government supply of the public good is exogenous in periods 0 to $T$ and determined by the steady state value of debt there after.  We use this to solve for the expenditures on labor and capital to produce this public good.  The government solves:

%\begin{equation}
%\label{eqn:pub_good_prob}
\begin{align}
\min_{\{EL^{G}_{u},I^{G}_{u}\}^{\infty}_{u=t}} \sum_{u=t}^{\infty} \prod_{\nu=t}^{u}\left(\frac{1}{1+r_{\nu}}\right) w_{u}EL^{G}_{u} + p^{K}_{g,u}I^{G}_{u} & \\
\text{subject to:} \ & G_{t} = (K^{G}_{t})^{\alpha}(EL^{G}_{t})^{1-\alpha} \ \text{and} \\
	& K^{G}_{t+1} = (1-\delta^{G})K^{G}_{t} + I^{G}_{t}, \forall  \ t
\end{align}
%\end{equation}

The equation above can be solved for government's demand for capital and labor as a function of the model parameters, factor prices, and government supply of public goods.  In particular, we can find the demand for capital as:

\begin{equation}
K^{G}_{t+1} = \frac{\alpha}{1-\alpha}\frac{w_{t}}{p^{K}_{g,t}}(1+r_{t})L_{t}\frac{G_{t+1}}{G_{t}}
\end{equation}

\section{Government production of private goods}

The government is one of the $M$ production sectors.  Its problem is thus described in Chapter \ref{chap:firms}.  However, the government firm differs from the private firms in that the gross-of-tax output price, $p_{g,t}$, includes a subsidy.  This means that the government sells output at a price that is below the cost of production. Instead of the zero-profit condition, the condition for government firms is:

\begin{equation}
G^{subs}_{t} = p_{g,t}X_{g,t} - w_{t}EL_{g,t} - r_{t}K_{g,t}
\end{equation}

\noindent\noindent  Thus the government subsidy towards the production of private goods is the difference between government revenues at the subsidized price and the costs of inputs to production.