Skip to content

Instantly share code, notes, and snippets.

@harlanhaskins
Created September 3, 2015 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harlanhaskins/7c98d3eb0e0d5c87c6a0 to your computer and use it in GitHub Desktop.
Save harlanhaskins/7c98d3eb0e0d5c87c6a0 to your computer and use it in GitHub Desktop.
\documentclass{article}
% Change "article" to "report" to get rid of page number on title page
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{extramarks}
\usepackage{chngpage}
\usepackage{soul}
\usepackage[usenames,dvipsnames]{color}
\usepackage{graphicx,float,wrapfig}
\usepackage{ifthen}
\usepackage{listings}
\usepackage{courier}
% Homework Specific Information
\newcommand{\hmwkTitle}{Homework 1}
\newcommand{\hmwkSubTitle}{}
\newcommand{\hmwkDueDate}{\today}
\newcommand{\hmwkClass}{CSCI 262}
\newcommand{\hmwkClassTime}{2:00}
\newcommand{\hmwkClassInstructor}{Kazemian}
\newcommand{\hmwkAuthorName}{Harlan Haskins}
% In case you need to adjust margins:
\topmargin=-0.45in %
\evensidemargin=0in %
\oddsidemargin=0in %
\textwidth=6.5in %
\textheight=9.0in %
\headsep=0.25in %
% Setup the header and footer
\pagestyle{fancy} %
\lhead{\hmwkAuthorName} %
\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle} %
\rhead{\firstxmark} %
\lfoot{\lastxmark} %
\cfoot{} %
\rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}} %
\renewcommand\headrulewidth{0.4pt} %
\renewcommand\footrulewidth{0.4pt} %
% This is used to trace down (pin point) problems
% in latexing a document:
%\tracingall
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Some tools
\newcommand{\enterProblemHeader}[1]{\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak%
\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak}%
\newcommand{\exitProblemHeader}[1]{\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak%
\nobreak\extramarks{#1}{}\nobreak}%
\newlength{\labelLength}
\newcommand{\labelAnswer}[2]
{\settowidth{\labelLength}{#1}%
\addtolength{\labelLength}{0.25in}%
\changetext{}{-\labelLength}{}{}{}%
\noindent\fbox{\begin{minipage}[c]{\columnwidth}#2\end{minipage}}%
\marginpar{\fbox{#1}}%
% We put the blank space above in order to make sure this
% \marginpar gets correctly placed.
\changetext{}{+\labelLength}{}{}{}}%
\setcounter{secnumdepth}{0}
\newcommand{\homeworkProblemName}{}%
\newcounter{homeworkProblemCounter}%
\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]%
{\stepcounter{homeworkProblemCounter}%
\renewcommand{\homeworkProblemName}{#1}%
\section{\homeworkProblemName}%
\enterProblemHeader{\homeworkProblemName}}%
{\exitProblemHeader{\homeworkProblemName}}%
\newcommand{\problemAnswer}[1]
{\noindent\fbox{\begin{minipage}[c]{\columnwidth}#1\end{minipage}}}%
\newcommand{\problemLAnswer}[1]
{\labelAnswer{\homeworkProblemName}{#1}}
\newcommand{\homeworkSectionName}{}%
\newlength{\homeworkSectionLabelLength}{}%
\newenvironment{homeworkSection}[1]%
{% We put this space here to make sure we're not connected to the above.
% Otherwise the changetext can do funny things to the other margin
\renewcommand{\homeworkSectionName}{#1}%
\settowidth{\homeworkSectionLabelLength}{\homeworkSectionName}%
\addtolength{\homeworkSectionLabelLength}{0.25in}%
\changetext{}{-\homeworkSectionLabelLength}{}{}{}%
\subsection{\homeworkSectionName}%
\enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]}}%
{\enterProblemHeader{\homeworkProblemName}%
% We put the blank space above in order to make sure this margin
% change doesn't happen too soon (otherwise \sectionAnswer's can
% get ugly about their \marginpar placement.
\changetext{}{+\homeworkSectionLabelLength}{}{}{}}%
\newcommand{\sectionAnswer}[1]
{% We put this space here to make sure we're disconnected from the previous
% passage
\noindent\fbox{\begin{minipage}[c]{\columnwidth}#1\end{minipage}}%
\enterProblemHeader{\homeworkProblemName}\exitProblemHeader{\homeworkProblemName}%
\marginpar{\fbox{\homeworkSectionName}}%
% We put the blank space above in order to make sure this
% \marginpar gets correctly placed.
}%
%%% I think \captionwidth (commented out below) can go away
%%%
%% Edits the caption width
%\newcommand{\captionwidth}[1]{%
% \dimen0=\columnwidth \advance\dimen0 by-#1\relax
% \divide\dimen0 by2
% \advance\leftskip by\dimen0
% \advance\rightskip by\dimen0
%}
% Includes a figure
% The first parameter is the label, which is also the name of the figure
% with or without the extension (e.g., .eps, .fig, .png, .gif, etc.)
% IF NO EXTENSION IS GIVEN, LaTeX will look for the most appropriate one.
% This means that if a DVI (or PS) is being produced, it will look for
% an eps. If a PDF is being produced, it will look for nearly anything
% else (gif, jpg, png, et cetera). Because of this, when I generate figures
% I typically generate an eps and a png to allow me the most flexibility
% when rendering my document.
% The second parameter is the width of the figure normalized to column width
% (e.g. 0.5 for half a column, 0.75 for 75% of the column)
% The third parameter is the caption.
\newcommand{\scalefig}[3]{
\begin{figure}[ht!]
% Requires \usepackage{graphicx}
\centering
\includegraphics[width=#2\columnwidth]{#1}
%%% I think \captionwidth (see above) can go away as long as
%%% \centering is above
%\captionwidth{#2\columnwidth}%
\caption{#3}
\label{#1}
\end{figure}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make title
\title{\vspace{2in}\textmd{\textbf{\hmwkClass:\ \hmwkTitle\ifthenelse{\equal{\hmwkSubTitle}{}}{}{\\\hmwkSubTitle}}}\\\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\\vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}}\vspace{3in}}
\date{}
\author{\textbf{\hmwkAuthorName}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{spacing}{1.1}
\maketitle
% Uncomment the \tableofcontents and \newpage lines to get a Contents page
% Uncomment the \setcounter line as well if you do NOT want subsections
% listed in Contents
%\setcounter{tocdepth}{1}
\newpage
% When problems are long, it may be desirable to put a \newpage or a
% \clearpage before each homeworkProblem environment
\clearpage
\begin{homeworkProblem}[Problem 2]
\begin{proof}
Assume $\exists S1 \land \exists S2$ \\
Given $|S1 \cup S2| = |S1| + |S2| - |S1 \cap S2|$, due to the definition of union. \\
Given $|S1 \cap S2| \ge 0$, due to the definition of intersection. \\
Given $x - y \le x$ when $y \ge 0$, due to the definition of subtraction. \\
$
n = |S1| \\
m = |S2| \\
z = |S1 \cap S2| \\
|S1 \cup S2| = n + m - z \\
(n + m) - z \le n + m \\
\therefore
|S1 \cup S2| \le n + m
$
\end{proof}
\end{homeworkProblem}
\begin{homeworkProblem}[Problem 3]
\begin{proof}
Assume $ \exists S1 \land \exists S2$ \\
Given $ |S1 \times S2| = \left\{ {(x,y)|x \in S1, y \in S2}\right\}
$
\end{proof}
\end{homeworkProblem}
\newcommand{\eqseven}{}
\begin{homeworkProblem}[Problem 7]
\begin{proof}
\end{proof}
\end{homeworkProblem}
\begin{homeworkProblem}[Problem 25]
\begin{proof}
Assume $n=1$ \\
\begin{align*}
\sum\limits_{i=1}^n 1^2 &= \frac{1(1+1)(2(1)+1)}{6} \\
1 &= \frac{1(6)}{6} \\
1 &= \frac{6}{6} \\
\end{align*}
$\therefore$ the proposition holds for $1$\\
\\
Assume $P(k)$ is true.
\begin{align*}
P(k) = \sum\limits_{i=1}^k i^2 &= \frac{k(k+1)(2k+1)}{6}
\end{align*}
Prove $P(k+1)$ is true.
\begin{align*}
P(k+1) = \sum\limits_{i=1}^k+1 i^2 &= \frac{(k+1)((k+1)+1)(2(k+1)+1)}{6} \\
P(k+1) = \sum\limits_{i=1}^k+1 i^2 &= \frac{(k+1)(k+2)((2k+2)+1)}{6} \\
P(k+1) = \sum\limits_{i=1}^k+1 i^2 &= \frac{(k+1)(2k^2 + 7k + 6)}{6} \\
P(k+1) = \sum\limits_{i=1}^k+1 i^2 &= \frac{(k+1)(2k(k+1) + 6(k+1))}{6} \\
P(k+1) = \sum\limits_{i=1}^k+1 i^2 &= \frac{k(k+1)(2k+1) + 6(k+1)^2)}{6} \\
P(k+1) = \sum\limits_{i=1}^k+1 i^2 &= \frac{k(k+1)(2k+1))}{6}+(k+1)^2 \\
P(k+1) = \sum\limits_{i=1}^k i^2+(k+1)^2 &= \frac{k(k+1)(2k+1))}{6}+(k+1)^2 \\
P(k+1) = \sum\limits_{i=1}^k i^2 &= \frac{k(k+1)(2k+1))}{6} \\
\end{align*}
$\therefore$ the proposition holds for all $n \ge 1$
\end{proof}
\end{homeworkProblem}
\begin{homeworkProblem}[Problem 27]
\begin{proof}
Assume $n=4$ \\
$2^n=16$ \\
$n!=24$ \\
$\therefore$ the proposition holds for $n$ \\
$2^{n+1} = 2^n * 2$ \\
$(n+1)! = n! * (n+1)$ \\
because $n \ge 4$, $n \ge 2$ \\
$\therefore$ the proposition holds for $n+1$ \\
$\therefore$ the proposition holds for all $n \ge 4$
\end{proof}
\end{homeworkProblem}
\begin{homeworkProblem}[Bob and Alice]
\begin{proof}
Assume Bob is telling the truth and Alice is lying. \\
If Alice is lying, then Bob must be lying. \\
$\therefore$ This case is false. \\
\\
Assume Bob is lying and Alice is telling the truth. \\
If Alice is telling the truth, then Bob must be telling the truth. \\
$\therefore$ This case is false.\\
\\
Assume both Bob and Alice are telling the truth. \\
If both are telling the truth, then Bob must be lying. \\
$\therefore$ This case is false. \\
\\
Assume both Bob and Alice are lying. \\
If Bob is lying, then both Alice and Bob must be lying. \\
If Alice is lying, then Bob must be lying. \\
$\therefore$ This case is true.
\end{proof}
\end{homeworkProblem}
\end{spacing}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------%
% The following is copyright and licensing information for
% redistribution of this LaTeX source code; it also includes a liability
% statement. If this source code is not being redistributed to others,
% it may be omitted. It has no effect on the function of the above code.
%----------------------------------------------------------------------%
% Copyright (c) 2007, 2008, 2009, 2010, 2011 by Theodore P. Pavlic
%
% Unless otherwise expressly stated, this work is licensed under the
% Creative Commons Attribution-Noncommercial 3.0 United States License. To
% view a copy of this license, visit
% http://creativecommons.org/licenses/by-nc/3.0/us/ or send a letter to
% Creative Commons, 171 Second Street, Suite 300, San Francisco,
% California, 94105, USA.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
% OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
% IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
% CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
% TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
% SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%----------------------------------------------------------------------%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment