\documentclass[a4paper]{article}

\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage[plain]{algorithm}
\usepackage{algpseudocode}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{varwidth}

\graphicspath{ {./images/} }

\usetikzlibrary{automata,positioning}

%
% Basic Document Settings
%

\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in

\linespread{1.1}

\pagestyle{fancy}
\lhead{\hmwkAuthorName}
\chead{\hmwkClass\ : \hmwkTitle}
\lfoot{\lastxmark}
\cfoot{\thepage}

\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\setlength\parindent{0pt}

%
% Create Problem Sections
%

\newcommand{\enterProblemHeader}[1]{
    \nobreak\extramarks{}{Question \arabic{#1} continued on next page\ldots}\nobreak{}
    \nobreak\extramarks{Question \arabic{#1} (continued)}{Question \arabic{#1} continued on next page\ldots}\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
    \nobreak\extramarks{Question \arabic{#1} (continued)}{Question \arabic{#1} continued on next page\ldots}\nobreak{}
    \stepcounter{#1}
    \nobreak\extramarks{Question \arabic{#1}}{}\nobreak{}
}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Question \arabic{homeworkProblemCounter}}{}\nobreak{}

\newenvironment{homeworkProblem}[1][-1]{
    \ifnum#1>0
        \setcounter{homeworkProblemCounter}{#1}
    \fi
    \section{Question \arabic{homeworkProblemCounter}}
    \setcounter{partCounter}{1}
    \enterProblemHeader{homeworkProblemCounter}
}{
    \exitProblemHeader{homeworkProblemCounter}
}

\newcommand{\hmwkClass}{INF 1004 Mathematics 2}
\newcommand{\hmwkTitle}{Tutorial\ \#7}
\newcommand{\hmwkAuthorName}{\textbf{Woon Jun Wei}}
\newcommand{\hmwkStudentID}{\textbf{2200624}}

\title{
    \vspace{2in}
    \textmd{\textbf{\hmwkClass \\ \hmwkTitle}}\\
    \vspace{3in}
}

\author{\hmwkAuthorName \\ \hmwkStudentID}
\date{\today}

\renewcommand{\part}[1]{\textbf{\large Part \arabic{partCounter}}\stepcounter{partCounter}\\}

%
% Various Helper Commands
%

% For multi-column lists
\newlist{multienum}{enumerate}{1}
\setlist[multienum]{
    label=(\alph*),
    before=\begin{multicols}{3},
    after=\end{multicols}
}

% Useful for algorithms
\newcommand{\alg}[1]{\textsc{\bfseries \footnotesize #1}}

% For derivatives
\newcommand{\deriv}[1]{\frac{\mathrm{d}}{\mathrm{d}x} (#1)}

% For partial derivatives
\newcommand{\pderiv}[2]{\frac{\partial}{\partial #1} (#2)}

% Integral dx
\newcommand{\dx}{\mathrm{d}x}

% Alias for the Solution section header
\newcommand{\solution}{\textbf{\large My Solution\\}}
\newcommand{\answer}{\textbf{\large Sample Solutions\\}}

% Probability commands: Expectation, Variance, Covariance, Bias
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\Bias}{\mathrm{Bias}}

\begin{document}

\maketitle
\pagebreak

\begin{homeworkProblem}
Let
$$
A = \begin{pmatrix}
    2&1\\1&7
\end{pmatrix}
\quad
B=
\begin{pmatrix}
    -2&5\\0&8
\end{pmatrix}
\quad
C=
\begin{pmatrix}
    6&0&3\\1&0&-5
\end{pmatrix}
\quad
D=
\begin{pmatrix}
    4&0&-4\\-3&4&9
\end{pmatrix}
$$
Compute, if possible

\begin{center}
\begin{minipage}{0.8\textwidth}
    \begin{multienum}
    \item $A+B$
    \item $B+A$
    \item $A+B+C$
    \item $A+C$
    \item $(C^T)^T$
    \item $C+C^T$
    \item $5D-3C$
    \item $5D^T-3C^T$
    \item $(B^T-A^T)^T$
    \end{multienum}
\end{minipage}
\end{center}
\qquad
\begin{center}
    \boxed{
\begin{minipage}{0.8\textwidth}
% \setlength{\itemsep}{0pt}
% \setlength{\parskip}{0pt}
    \textbf{Solution:}
\begin{multienum}
    \item $\begin{pmatrix} 0&6\\1&15 \end{pmatrix}$
    \item $\begin{pmatrix} 0&6\\1&15 \end{pmatrix}$
    \item not possible
    \item not possible
    \item C
    \item not possible
    \item $\begin{pmatrix}2&0&-29\\-18&20&60\end{pmatrix}$
    \item $\begin{pmatrix}2&-18\\0&20\\-29&60\end{pmatrix}$
    \item $\begin{pmatrix}-4&4\\-1&1\end{pmatrix}$
\end{multienum}
\end{minipage}
}
\end{center}

\solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
Determine the constants $a,b,c$ and $d$, such that the following equation holds.
$$
\begin{align*}
    \begin{pmatrix} 0&a&3\\b&2&2 \end{pmatrix}   +
    \begin{pmatrix} c&1&2\\1&1&d \end{pmatrix} =
    \begin{pmatrix} 4&3&5\\7&3&5 \end{pmatrix}.
\end{align*}
$$

\noindent\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}

\textbf{Solution:}
$a=2,b=6,c=4,d=3$
\end{minipage}}

\solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
Given the matrices A and B, compute the products $AB$ and $BA$.
$$
A=
\begin{pmatrix} 1&2\\0&-1\\4&1 \end{pmatrix},
\quad
B=
\begin{pmatrix} 1&2&1\\-1&1&0 \end{pmatrix}
$$

\noindent\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
\textbf{Solution:}
$$
AB=
\begin{pmatrix} -1&4&1\\1&-1&0\\3&9&4 \end{pmatrix},
\quad
BA=
\begin{pmatrix} 5&1\\-1&-3\end{pmatrix}
$$
\end{minipage}}
\solution

\end{homeworkProblem}

\pagebreak
\begin{homeworkProblem}
If A and B are invertible $n\times n$ matrices, use the definition of the inverse,
to prove that
$$(AB)^{-1}=B^{-1}A^{-1}.$$
\solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
Solve for the matrix A,

$$
\left[ 5A^T +
\begin{pmatrix}
    1&0\\2&5
\end{pmatrix}
\right ]^T
=
3A +
\begin{pmatrix}
1&-2\\-1&3
\end{pmatrix}^T.
$$

\noindent\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
\textbf{Solution:}
$$
A = \frac{1}{2}
\begin{pmatrix}
    2&0\\1&4
\end{pmatrix}
$$
\end{minipage}}

\solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
In 2010, the average salary for all accountants in San Diego and Salt Lake City, was
\$45, 091.50. The average salary in San Diego alone, however, was \$5231 greater than the
average salary in Salt Lake City alone. What is the average salary of an accountant in
each city, assuming that there are the same number of accountants in each city?

\boxed{
    \text{
\textbf{Solution:}
The average salary in San Diego and Salt Lake City is \$47,707 and \$42,476, respectively.
}
}
\\\\
\solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
A chemist has prepared two acid solutions, one of which is 2\% by volume, the other 7\%.
How many cubic centimeters of each should the chemist mix together, to obtain $40 cm^3$ of a $3.2\%$ acid solution?

\boxed{
    \text{
\textbf{Solution:}
For the 2\% solution is $30.4 cm^3$ and for the 7\% solution is $9.6 cm^3$.
}
}
\\\\
\solution
\end{homeworkProblem}
\end{document}
