\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{framed}

\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}
\rhead{\firstxmark}
\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\ \#9}
\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
%

% 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}
    Draw these affine spaces
    $$
    \begin{align*}
        \begin{bmatrix} 2\\-1 \end{bmatrix} \cdot x + 1.5 &= 0\\
        \begin{bmatrix} -5\\-1 \end{bmatrix} \cdot x + 6 &= 0\\
        \begin{bmatrix} -5\\-1 \end{bmatrix} \cdot x - 6 &= 0\\
    \end{align*}
    $$

    \solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}

    Find two non-parallel vectors $x$ solving
    $$
    \begin{align*}
        &w \cdot x= 3\\
        w &= \begin{bmatrix} 1\\-2\\4 \end{bmatrix}
    \end{align*}
    $$
    
    \solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}

    Show that the line given by
    $$
    \begin{align*}
        f(t) &= \begin{bmatrix} 2\\3\\1 \end{bmatrix} + t \begin{bmatrix} -1\\4\\2 \end{bmatrix}
    \end{align*}
    $$
    does not intersect the plane given by
    $$
    2x+z=9
    $$
    Note:
    $$
    f(t) = \begin{bmatrix} x(t)\\y(t)\\z(t) \end{bmatrix}
    $$

    \solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}

    Show that the line given by
    $$
    \begin{align*}
        f(t) &= \begin{bmatrix} 1\\-3\\2 \end{bmatrix} + t \begin{bmatrix} 2\\3\\-5 \end{bmatrix}
    \end{align*}
    $$
    does not intersect the plane given by
    $$
    3x-2y+2z = 18
    $$
    Note:
    $$
    f(t) = \begin{bmatrix} x(t)\\y(t)\\z(t) \end{bmatrix}
    $$

    \solution
\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Check whether the plane given by
    $$
    f(s,t) = \begin{bmatrix} 0\\1\\-3 \end{bmatrix} + t \begin{bmatrix} -2\\0\\1 \end{bmatrix} + s \begin{bmatrix} 1\\2\\-1 \end{bmatrix}
    $$
    has an intersection with the line given by
    $$
    \begin{align*}
        x+2y-z &= 3\\
        2x-y+z &= 6
    \end{align*}
    $$
    Note:
    $$
    f(s,t) = \begin{bmatrix} x(s,t)\\y(s,t)\\z(s,t) \end{bmatrix}
    $$

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Convert the plane equation into the form $Ax=b$ for
    $$
    \begin{bmatrix}x_0\\y_0\\z_0 \end{bmatrix} = \begin{bmatrix} 5\\-2\\-3 \end{bmatrix}
    + s \begin{bmatrix} 1\\2\\3 \end{bmatrix} + t \begin{bmatrix} 2\\-1\\2 \end{bmatrix}
    $$\\
    Steps:
    \begin{itemize}
        \item What is the dimensionality of the whole vector space in which these equations are defined?
        \item What is the dimensionality of the affine space spanned by the plane equation?
        \item How does the matrix B look like for which we seek solutions $x$ such that $Bx = 0$ ?
        \item Conclude based on the dimensionality of the whole vector space and the dimensionality of the plane, what is the dimensionality of solutions $x$ which we are searching for ?
        \item Find a basis for these solutions. Turn it into a matrix $A$
        \item Get the correct bias vector $b$ based the $A$ which you found
    \end{itemize}

    \solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Convert the plane equation into the form $Ax=b$ for
    $$
    \begin{bmatrix}x_0\\y_0\\z_0 \end{bmatrix} = \begin{bmatrix} -1\\0\\1 \end{bmatrix}
    + s \begin{bmatrix} -3\\1\\6 \end{bmatrix} + t \begin{bmatrix} 2\\-4\\-4 \end{bmatrix}
    $$\\

    \solution

\end{homeworkProblem}

\pagebreak

\begin{homeworkProblem}
    Plot 2d plandes in a 3d space using e.g. matplotlib

    \solution

\end{homeworkProblem}

\pagebreak

\end{document}
