% % % % % % % %
% % % % % % % %
%IMPORTANT
%compiles with
%pdflatex -shell-escape
%IMPORTANT
% % % % % % % %
% % % % % % % %
\documentclass%
%[handout]%
{beamer}
%IMPORTANT: the following line selects the current lecture. Change number to select a different lecture.
\newcommand{\currentLecture}{11}

\mode<presentation>
{
\useinnertheme{rounded}
\useoutertheme{infolines}
\usecolortheme{orchid}
\usecolortheme{whale}
}
%\setbeamertemplate{footline}{%
%  \raisebox{5pt}{\makebox[\paperwidth]{\hfill\makebox[10pt]{\scriptsize\insertframenumber}}}}

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\input{../example-templates}
\input{../system-specific-config-Ubuntu-texlive}
\input{../pstricks-commands}
\mode<handout>{\pgfpagesuselayout{1 on A4}[a4paper,landscape]}

\newcommand{\currentSemester}{2017}

\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.

\graphicspath{{../../modules/}}

\newcommand{\lect}[4]{
\ifnum#3=\currentLecture
  \date{#1}
  \lecture[#1]{#2}{#3}
#4
\else
%include nothing
\fi
}

\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}
  \end{beamercolorbox}}%
  \vskip0pt%
}

\setbeamertemplate{navigation symbols}{}

\renewcommand{\Arcsin}{\arcsin}
\renewcommand{\Arccos}{\arccos}
\renewcommand{\Arctan}{\arctan}
\renewcommand{\Arccot}{\text{arccot\hspace{0.03cm}}}
\renewcommand{\Arcsec}{\text{arcsec\hspace{0.03cm}}}
\renewcommand{\Arccsc}{\text{arccsc\hspace{0.03cm}}}

% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:

%\pgfdeclareimage[height=0.8cm]{logo}{bluelogo}
%\logo{\pgfuseimage{logo}}

\begin{document}

\AtBeginLecture{%

\title[\insertlecture]{Math 242}
\subtitle{\insertlecture}
\author[The freecalc team]{\Large The freecalc project team \\~\\
\normalsize Reference Lectures\\~\\
\url{https://github.com/tmilev/freecalc}
}
\date{2016}
\begin{frame}
  \titlepage
\end{frame}

\begin{frame}{Outline}
  \tableofcontents[pausesections]
\end{frame}
}%

% begin lecture
\lect{\currentSemester}{Lecture  1}{-1}{

\input{../../modules/course-outline/course-outline-multivariable-calculus-UMB-242-Catalin-Zara}
}

% begin lecture
\lect{\currentSemester}{Lecture  1}{1}{
%DesiredLectureName: Space_Cartesian_Coordinates
\fcLicense
\section{Space}
%\input{../../modules/coordinate-systems/space-intro}<-needs rewrite from ground up.
\input{../../modules/coordinate-systems/space-configurations-pairs-lines-or-planes}
\input{../../modules/coordinate-systems/distances-and-angles}
\input{../../modules/coordinate-systems/line-plane-configurations-vs-distances-and-angles}
\input{../../modules/coordinate-systems/cartesian-coordinates}
\input{../../modules/coordinate-systems/distance-in-cartesian-coordinates}
\input{../../modules/coordinate-systems/distance-in-cartesian-coordinates-example-1}
\input{../../modules/coordinate-systems/distance-in-cartesian-coordinates-example-2}
\input{../../modules/coordinate-systems/sets-in-space}
\input{../../modules/coordinate-systems/sets-in-space-equations}
\input{../../modules/coordinate-systems/sets-in-space-sphere-equations}
}

% begin lecture
\lect{\currentSemester}{Lecture  2}{2}{
%DesiredLectureName: Vector_Basics_Dot_Product
\fcLicense
\section{Vectors}
%\input{../../modules/vectors/vectors-outline} %<-needs rewrite from ground up.
\input{../../modules/vectors/vectors-definition}
\input{../../modules/vectors/displacement-vectors}
\input{../../modules/vectors/displacement-vector-equality}
\input{../../modules/vectors/position-and-displacement-vectors}
\input{../../modules/vectors/vector-addition-triangle-rule}
\input{../../modules/vectors/vector-addition-commutativity-associativity}
\input{../../modules/vectors/vector-difference}
\input{../../modules/vectors/linear-combinations}
%\input{../../modules/vectors/vector-decomposition-along-directions} %<-slide needs rewrite from ground up.
\input{../../modules/vectors/vectors-in-coordinates}
\input{../../modules/vectors/vectors-operations-in-coordinates}
%\input{../../modules/vectors/work-constant-force} %<-needs a ground-up rewrite

\section{Dot product of vectors}
\input{../../modules/vectors/dot-product-def}
\input{../../modules/vectors/dot-product-properties}
\input{../../modules/vectors/dot-product-computation-in-coordinates}
\input{../../modules/vectors/dot-product-computations-examples}
\input{../../modules/vectors/projections-in-coordinates}
\input{../../modules/vectors/projections-in-coordinates-examples}
\input{../../modules/vectors/angles}
\input{../../modules/vectors/direction-angles}
%\input{../../modules/vectors/rotational-effect} %<-needs to be rewritten from ground up
%\input{../../modules/vectors/torque} %<-needs to be rewritten from ground up
}

\lect{\currentSemester}{Lecture 3}{3}{
%DesiredLectureName: Cross_Product_Determinants
\fcLicense
\section{Cross product of vectors}
\input{../../modules/vectors/torque-wrench-example}
\input{../../modules/vectors/cross-product}
\input{../../modules/vectors/cross-product-properties}
\input{../../modules/vectors/orth-is-linear}
\input{../../modules/vectors/cross-product-linearity-proof}
\subsection{Determinants}
\input{../../modules/determinants/permutations-def}
\input{../../modules/determinants/permutation-sign}
\input{../../modules/determinants/permutation-rook-placements}

\input{../../modules/determinants/determinants-def}
\input{../../modules/determinants/two-by-two}
\input{../../modules/determinants/three-by-three}
\subsection{Cross product in coordinates}
\input{../../modules/vectors/cross-product-in-coordinates}
\input{../../modules/vectors/cross-product-example}
\input{../../modules/vectors/cross-product-find-orthogonal-vector-to-two-vectors-1}
\input{../../modules/vectors/cross-product-to-find-area-triangle}
\input{../../modules/vectors/cross-product-to-find-area-triangle-example-1}
\input{../../modules/vectors/scalar-triple-product}
\input{../../modules/vectors/scalar-triple-product-volume-slanted-box-example-1}
\input{../../modules/vectors/scalar-triple-product-volume-tetrahedron-example-1}
\input{../../modules/vectors/scalar-triple-product-four-points-coplanar-example-1}
\input{../../modules/vectors/space-orientation}
} %end lecture

% begin lecture
\lect{\currentSemester}{Lecture 4}{4}{
%DesiredLectureName: Distances_Angles_Between_Points_Lines_Planes
\fcLicense
\input{../../modules/vectors/incidence-questions-intro}
\section{Equations of Lines}
\subsection{Line from point and direction}
\input{../../modules/vectors/line-from-point-and-direction}
\input{../../modules/vectors/line-from-point-and-direction-example}

\subsection{Line from two points}
\input{../../modules/vectors/line-from-two-points}
\input{../../modules/vectors/line-from-two-points-example}

\section{Equations of planes}
\subsection{Plane from point and normal}
\input{../../modules/vectors/plane-from-point-and-normal}
\input{../../modules/vectors/plane-from-point-and-normal-example}

\subsection{Plane from two directions}
\input{../../modules/vectors/plane-from-point-and-two-directions}
\input{../../modules/vectors/plane-from-point-and-two-directions-example}

\subsection{Plane from three points}
\input{../../modules/vectors/plane-from-three-points}
\input{../../modules/vectors/plane-from-three-points-example}

\section{Distances, Angles, Parallelism, Incidence}
\input{../../modules/vectors/angles-distances-questions-intro}
\subsection{Distance Between Point and Line}
\input{../../modules/vectors/distance-point-and-line}
\input{../../modules/vectors/distance-point-and-plane}

\subsection{Parallel Lines}
\input{../../modules/vectors/parallel-lines}
\subsection{Angle Between Lines}
\input{../../modules/vectors/angle-between-lines}
\subsection{Distance Between Skew Lines}
\input{../../modules/vectors/distance-between-lines}
\subsection{Distance Between Plane and Parallel Line}
\input{../../modules/vectors/distance-parallel-plane-and-line}
\subsection{Angle Between Plane and Line}
\input{../../modules/vectors/angle-between-plane-and-line}
\input{../../modules/vectors/intersection-plane-and-line}
\subsection{Parallel Planes}
\input{../../modules/vectors/parallel-planes}
\subsection{Angle Between Planes}
\input{../../modules/vectors/angle-between-planes}
} %end lecture

% begin lecture
\lect{\currentSemester}{Lecture  5}{5}{
%DesiredLectureName: Polar_Cylindrical_Spherical_Coordinates
\fcLicense
\section{Polar Coordinates}
\input{../../modules/polar-coordinates/polar-intro}
\input{../../modules/polar-coordinates/polar-questions}
\input{../../modules/polar-coordinates/polar-many-representations}
\input{../../modules/polar-coordinates/polar-two-points-coincide-iff}
\input{../../modules/polar-coordinates/polar-to-cartesian}
\input{../../modules/polar-coordinates/polar-to-cartesian-ex2}
\input{../../modules/polar-coordinates/polar-to-cartesian-ex3}
%\input{../../modules/polar-coordinates/polar-intersection-ex3}

\section{Cylindrical Coordinates}
\input{../../modules/cylindrical-coordinates/cylindrical-coordinates-def}
\input{../../modules/cylindrical-coordinates/cylindrical-coordinates-to-rectangular}
\input{../../modules/cylindrical-coordinates/cylindrical-coordinates-constant-coordinate-sets}
\section{Spherical Coordinates}
\input{../../modules/spherical-coordinates/spherical-coordinates}
\input{../../modules/spherical-coordinates/spherical-coordinates-to-cartesian}
\input{../../modules/spherical-coordinates/spherical-coordinates-constant-coordinate-sets}

\section{Curvilinear boxes}
\input{../../modules/coordinate-systems/curvilinear-boxes-polar}
\input{../../modules/coordinate-systems/curvilinear-boxes-cylindrical}
\input{../../modules/coordinate-systems/curvilinear-boxes-spherical}
}% end lecture

\lect{\currentSemester}{Lecture 6}{6}{
%DesiredLectureName: Curves_in_Space
\fcLicense
\section{Curves in space}
\input{../../modules/coordinate-systems/r-two-r-n}
\input{../../modules/parametric-curves/parametric-equation-line-segment}
\input{../../modules/parametric-curves/parametric-equation-line-segment-example}
\input{../../modules/parametric-curves/parametrized-curves-def}
\input{../../modules/parametric-curves/lines-as-parametric-curves-example}
\input{../../modules/parametric-curves/parametric-curve-example-tornado}
\input{../../modules/parametric-curves/limits}
\input{../../modules/parametric-curves/continuity}
\section{Tangent vectors, tangents}
\input{../../modules/parametric-curves/derivatives}
\input{../../modules/parametric-curves/tangent-lines}
\input{../../modules/parametric-curves/tangent-examples}
\input{../../modules/parametric-curves/differentiation-rules}
\input{../../modules/parametric-curves/acceleration}
\input{../../modules/parametric-curves/acceleration-example-loxodrome}
\section{Line integrals}
\input{../../modules/parametric-curves/line-integrals}
\input{../../modules/parametric-curves/line-integral-properties}
\input{../../modules/parametric-curves/line-integral-applications}
\input{../../modules/parametric-curves/parametric-arc-length-formula-3d}
\input{../../modules/parametric-curves/arc-length-function}
\input{../../modules/parametric-curves/arc-length-example-helix}
\input{../../modules/parametric-curves/parametrization-by-arc-length}
\input{../../modules/parametric-curves/curve-reparametrizations}
\input{../../modules/parametric-curves/curve-reparametrization-example}
\section{Curvature}
\input{../../modules/parametric-curves/curvature}
\input{../../modules/parametric-curves/curvature-formula-proof}
\input{../../modules/parametric-curves/curvature-example-helix}
\input{../../modules/parametric-curves/curvature-example-torus-curve}
\input{../../modules/parametric-curves/curvature-example-loxodrome}

\input{../../modules/parametric-curves/components-of-acceleration}
}

% begin lecture
\lect{\currentSemester}{Lecture 7}{7}{
%DesiredLectureName: Multivariable_Functions
\fcLicense
\section{Functions of Several Variables}
\input{../../modules/multivariable-functions/multivariable-functions-intro}
\subsection{Verbal description}
\input{../../modules/multivariable-functions/multivariable-functions-verbal-description}
\subsection{Numerical description}
\input{../../modules/multivariable-functions/multivariable-functions-numerical-description}
\subsection{Analytical description}
\input{../../modules/multivariable-functions/multivariable-functions-analytical-description}
\section{Graphical descriptions}
\subsection{Functions of two variables}
\input{../../modules/multivariable-functions/multivariable-functions-graphical-description}
\subsection{Slices and level curves}
\input{../../modules/multivariable-functions/multivariable-functions-slices-and-level-curves}
\subsection{Level sets}
\input{../../modules/multivariable-functions/level-sets}
\subsection{Vector Fields}
\input{../../modules/multivariable-functions/vector-fields}
%\input{../../modules/multivariable-functions/vector-fields-decomposition-wrt-other-vector-fields} %<- needs rewrite.
}

\lect{\currentSemester}{Lecture 8}{8}{
%DesiredLectureName: Multivariable_Limits_and_Continuity
\fcLicense
\section{Limits of Functions of Several Variables}
\input{../../modules/continuity-multivariable/limits-intro}
\input{../../modules/continuity-multivariable/limit-example}
\input{../../modules/continuity-multivariable/limit-definition}
\input{../../modules/continuity-multivariable/infinite-limits-example}
\input{../../modules/continuity-multivariable/directional-limits-def}
\input{../../modules/continuity-multivariable/limit-non-existence-example}
\input{../../modules/continuity-multivariable/directional-limits-and-one-variable-limits}
\input{../../modules/continuity-multivariable/directional-limits-example}
\input{../../modules/continuity-multivariable/limits-along-paths}
\section{Continuity of Functions of Several Variables}
\input{../../modules/continuity-multivariable/continuity}
\input{../../modules/continuity-multivariable/continuity-vector-fields}
\input{../../modules/continuity-multivariable/continuity-vector-fields-example}
}

\lect{\currentSemester}{Lecture 9}{9}{
%DesiredLectureName: Partial_Derivatives_Differentiability_Differentials
\fcLicense
\section{Partial Derivatives}
\input{../../modules/partial-derivatives/rate-of-change-example}
\input{../../modules/partial-derivatives/rate-of-change-along-lines}
\input{../../modules/partial-derivatives/directional-derivatives}
\input{../../modules/partial-derivatives/partial-derivatives}
\input{../../modules/partial-derivatives/partial-derivatives-notation}
\input{../../modules/partial-derivatives/partial-derivatives-example}
\input{../../modules/partial-derivatives/partial-derivatives-graphical-interpretation}
\input{../../modules/partial-derivatives/partial-derivatives-higher-order}
\input{../../modules/partial-derivatives/partial-derivatives-higher-order-example}
\section{Linearizations}
\input{../../modules/partial-derivatives/multivariable-function-linearizations}
\section{Differentiability}
\input{../../modules/partial-derivatives/differentiability-intro}
\input{../../modules/partial-derivatives/differentiable-function-def}
\section{Differentials}
\input{../../modules/partial-derivatives/total-differential}
\input{../../modules/partial-derivatives/total-differential-and-linearization-example}
}

\lect{\currentSemester}{Lecture 10}{10}{
%DesiredLectureName: Multivariable_Chain_Rule_Differential_Operators
\fcLicense

\section{Multivariable Chain Rule}
\input{../../modules/chain-rule-multivariable/multivariable-chain-rule-motivation}
\input{../../modules/chain-rule-multivariable/multivariable-chain-rule}
\input{../../modules/chain-rule-multivariable/multivariable-chain-tree-diagrams}
\input{../../modules/chain-rule-multivariable/multivariable-3-2-chain-rule}
\input{../../modules/chain-rule-multivariable/multivariable-3-2-chain-rule-example-power-exponential}
\section{Directional Derivatives via the Chain Rule }
\input{../../modules/chain-rule-multivariable/directional-derivatives-via-chain-rule}
\input{../../modules/chain-rule-multivariable/directional-derivatives-via-chain-rule-example}
\section{Gradient}
\input{../../modules/optimization-multivariable/gradient}
\input{../../modules/optimization-multivariable/gradient-in-coordinates}
\input{../../modules/chain-rule-multivariable/covariant-derivative}
\input{../../modules/optimization-multivariable/gradient-in-polar}
\input{../../modules/optimization-multivariable/gradient-in-polar-application}
\input{../../modules/optimization-multivariable/gradient-and-gravity}
\section{Differential Operators}
\input{../../modules/chain-rule-multivariable/differential-operator-definition}
\input{../../modules/chain-rule-multivariable/differential-operator-notation}
\subsection{Differential Operators Variable Changes}
\input{../../modules/chain-rule-multivariable/multivariable-3-2-chain-rule-example-derivatives-polar-coordinates}
\input{../../modules/chain-rule-multivariable/partial-derivatives-in-polar-coordinates-part1}
\input{../../modules/chain-rule-multivariable/partial-derivatives-in-polar-coordinates-part2}

\input{../../modules/harmonic-functions/laplace-operator}
\input{../../modules/harmonic-functions/harmonic-functions-definition}
}

\lect{\currentSemester}{Lecture 11}{11}{
%DesiredLectureName: Surfaces_Quadratic_Surfaces_Tangent_Planes
\begin{frame}
\begin{center}
\Large Please view this lecture in full screen mode.

Scroll down the slides (in full screen mode) to see a demo of the freecalc graphics and presentation.
\end{center}
\end{frame}
\fcLicense
\section{Surfaces}
% % % % %\input{../../modules/surfaces/surfaces-intro} %<-needs a rewrite
% % % % %\input{../../modules/surfaces/surfaces-parametrizations}<-needs a rewrite
\input{../../modules/surfaces/implicit-equation-vs-explicit-parametrization}
% % % % %\input{../../modules/surfaces/parametrized-surfaces}
% % % % %\input{../../modules/surfaces/surfaces-example-plane-parametric-equation}
% % % % %\input{../../modules/surfaces/surfaces-example-sphere-open-chart}
% % % % %\input{../../modules/surfaces/level-surfaces-as-parametrized-surfaces}
\subsection{Quadric Surfaces}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-intro}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-imaginary-spheres}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-ellipsoids-spheres}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-cone}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-hyperboloid-one-sheet}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-hyperboloid-two-sheets}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-paraboloid}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-hyperbolic-paraboloid}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-summary-form1}
\input{../../modules/quadratic-surfaces/quadratic-surfaces-summary-form2}
\section{Tangent Planes}
\input{../../modules/surfaces/tangent-plane-intro}
% % % % %\input{../../modules/surfaces/tangent-plane-definition}
% % % % %\input{../../modules/surfaces/tangent-plane-example-1}
\input{../../modules/surfaces/tangent-plane-to-graph-surface}
%\input{../../modules/surfaces/tangent-plane-to-level-surface}
% % % % % %WARNING
% % % % % %the following slides need serious editing, are not ready for lecturing at the moment
% % % % %\input{../../modules/surfaces/surfaces-of-revolution}
% % % % %\input{../../modules/surfaces/surfaces-of-revolution-example-torus}
% % % % %\input{../../modules/surfaces/tangent-plane-definition}
\input{../../modules/chain-rule-multivariable/directional-derivatives-tangent-plane-def-justification}
% % % % %\input{../../modules/surfaces/tangent-plane-example-1}
% % % % %\input{../../modules/surfaces/regular-points-level-surface}
% % % % %\input{../../modules/surfaces/tangent-plane-equation}
% % % % %\input{../../modules/surfaces/tangent-plane-to-level-surface-example-1}
% % % % %\input{../../modules/surfaces/tangent-planes-to-quadratic-surfaces}
% % % % %\input{../../modules/surfaces/graph-and-level-surfaces}
\input{../../modules/surfaces/is-level-surface-graph-of-function}
% % %\input{../../modules/surfaces/is-level-surface-graph-of-function-example} % % % % %<-needs rewrite
% % % % %\input{../../modules/surfaces/implicit-functions}
% % % % %\input{../../modules/surfaces/implicit-functions-example-sphere}
% % % % %\input{../../modules/surfaces/implicit-function-theorem}
% % % % %\input{../../modules/surfaces/implicit-function-theorem-and-graph-surfaces}
% % % % %\input{../../modules/surfaces/implicit-differentiation}
% % % % %\input{../../modules/surfaces/implicit-differentiation-example-1}
% % % % %\input{../../modules/surfaces/implicit-differentiation-and-tangent-plane-example-1}
}

\lect{\currentSemester}{Lecture 12}{12}{
%DesiredLectureName: Maxima_Minima_Lagrange_Multipliers
\section{Minima, Maxima}
\input{../../modules/optimization-multivariable/maxima-minima-definitions}
\input{../../modules/optimization-multivariable/critical-points}
\input{../../modules/optimization-multivariable/critical-points-example}
\input{../../modules/optimization-multivariable/second-derivative-test}
\input{../../modules/optimization-multivariable/second-derivative-test-example}
\input{../../modules/optimization-multivariable/second-derivative-test-example-distance-point-to-plane}
\input{../../modules/optimization-multivariable/extreme-value-theorem}
\input{../../modules/optimization-multivariable/second-derivative-test-example-box-no-lid-volume}
\section{Lagrange Multipliers}
% % % % %\input{../../modules/optimization-multivariable/lagrange-multipliers-intro-via-Cobb-Douglas-Function}<-needs rewrite
% % % % %\input{../../modules/optimization-multivariable/lagrange-multipliers-intro-via-Cobb-Douglas-Function-part-2}
% % % %<-needs rewrite %\input{../../modules/optimization-multivariable/lagrange-multipliers-intro-via-Cobb-Douglas-Function-part-3}<-needs rewrite
\input{../../modules/optimization-multivariable/gradient-normal-to-level-curve}
\input{../../modules/optimization-multivariable/lagrange-multipliers}
% % % % %\input{../../modules/optimization-multivariable/lagrange-multipliers-remarks}<-needs rewrite
\input{../../modules/optimization-multivariable/lagrange-multipliers-example-1}
\input{../../modules/optimization-multivariable/lagrange-multipliers-example-box-no-lid-volume}
%\input{../../modules/optimization-multivariable/lagrange-multipliers-least-squares-method} <-only a stub, needs to be written properly.
\input{../../modules/optimization-multivariable/lagrange-multipliers-multiple-constraints}
\input{../../modules/optimization-multivariable/lagrange-multipliers-multiple-constraints-example-1}
}

% begin lecture
\lect{\currentSemester}{Lecture 13}{13}{
%DesiredLectureName: Double_Integrals
\section{Double Integrals}
\subsection{Riemann Sums, Double Integral Definition}
\input{../../modules/integration-multivariable/integral-motivation-census-example}
\input{../../modules/integration-multivariable/Riemann-sum-two-variables}
\input{../../modules/integration-multivariable/double-integral-definitions}
\input{../../modules/integration-multivariable/double-integral-midpoint-rule}
\input{../../modules/integration-multivariable/double-integral-midpoint-rule-example}
\subsection{Double integral properties}
\input{../../modules/integration-multivariable/double-integral-theoretical-example-1}
\input{../../modules/integration-multivariable/double-integral-properties}
\input{../../modules/integration-multivariable/double-integral-applications-1}
\input{../../modules/integration-multivariable/double-integral-mvt-area-limit}
\input{../../modules/integration-multivariable/double-integral-vector-valued}
\input{../../modules/integration-multivariable/double-integral-vector-valued-example-theoretical-1}
\subsection{Iterated integrals}
\input{../../modules/integration-multivariable/double-iterated-integrals}
\input{../../modules/integration-multivariable/Fubini-theorem-double-integrals}
\input{../../modules/integration-multivariable/double-iterated-integrals-example}
\input{../../modules/integration-multivariable/double-integrals-regions-intro}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-base-vertical}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-base-horizontal}
\input{../../modules/integration-multivariable/double-integrals-strategy}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-example-1}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-example-2}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-example-3}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-example-4}
\input{../../modules/integration-multivariable/double-integrals-curvilinear-trapezoids-example-5}
}

\lect{\currentSemester}{Lecture 14}{14}{
%DesiredLectureName: Triple_Integrals
\section{Triple Integrals}
\input{../../modules/integration-multivariable/triple-integrals-intro-density-mass}
\input{../../modules/integration-multivariable/triple-integrals-def}
\input{../../modules/integration-multivariable/triple-integrals-examples-theoretical-1}
\input{../../modules/integration-multivariable/triple-iterated-integrals}
\input{../../modules/integration-multivariable/triple-integrals-example-moment-rectangular-box}
\input{../../modules/integration-multivariable/triple-integrals-example-volume-1-slices}
\input{../../modules/integration-multivariable/triple-integrals-example-volume-1-rods}
}

\lect{\currentSemester}{Lecture 15}{15}{
%DesiredLectureName: Parallelotopes_Variable_Changes_In_Multivariable_Integrals
\section{Parallelotopes}
\input{../../modules/integration-multivariable-variable-change/parallelotope-definition}
\input{../../modules/integration-multivariable-variable-change/k-volume-parallelotope-in-n-space-definition}
\input{../../modules/integration-multivariable-variable-change/k-volume-naming-conventions}
\input{../../modules/integration-multivariable-variable-change/volume-parallelotope-equals-integral-one}
\input{../../modules/integration-multivariable-variable-change/volume-parallelotope}
\input{../../modules/determinants/multiply-determinant-column-by-number}
\input{../../modules/integration-multivariable-variable-change/segment-in-3-space-length-example-1}
\input{../../modules/integration-multivariable-variable-change/segment-in-3-space-length-formula}
\input{../../modules/integration-multivariable-variable-change/parallelogram-in-2-space-area-example-1}
\input{../../modules/integration-multivariable-variable-change/parallelogram-in-2-space-area-formula}
\input{../../modules/integration-multivariable-variable-change/parallelogram-in-3-space-area-example-1}
\input{../../modules/integration-multivariable-variable-change/parallelogram-in-3-space-area-formula}
\input{../../modules/integration-multivariable-variable-change/parallelepiped-volume-example-1}
\input{../../modules/integration-multivariable-variable-change/parallelepiped-volume-formula}
\section{Variable Changes in Multivariable Integrals}
\input{../../modules/integration-multivariable-variable-change/variable-change-terminology}
\input{../../modules/integration-multivariable-variable-change/variable-change-notation}
\input{../../modules/integration-multivariable-variable-change/jacobian}
\input{../../modules/integration-multivariable-variable-change/variable-change-motivation-part-1}
\input{../../modules/integration-multivariable-variable-change/variable-change-motivation-part-2}
\input{../../modules/integration-multivariable-variable-change/variable-change-motivation-part-3}
\input{../../modules/integration-multivariable-variable-change/variable-change-motivation-part-4}
\input{../../modules/integration-multivariable-variable-change/integral-variable-change}
\input{../../modules/integration-multivariable-variable-change/volume-of-ball}
\input{../../modules/integration-multivariable-variable-change/volume-of-spherical-curvilinear-box}
\input{../../modules/integration-multivariable-variable-change/volume-of-ellipsoid}
\input{../../modules/integration-multivariable-variable-change/volume-of-toroid-part1}
\input{../../modules/integration-multivariable-variable-change/volume-of-toroid-part2}
\input{../../modules/integration-multivariable-variable-change/volume-of-toroid-part3}
\input{../../modules/integration-multivariable-variable-change/volume-of-toroid-part4}
\input{../../modules/integration-multivariable-variable-change/volume-of-raised-horn}

\input{../../modules/integration-multivariable-variable-change/integral-variable-change-positivity-jacobian}
%\input{../../modules/integration-multivariable-variable-change/area-of-ellipse}
}

\lect{\currentSemester}{Lecture 16}{16}{%
%DesiredLectureName: Double_Integrals_Polar_Coordinates
\section{Double Integrals in Polar Coordinates}
\input{../../modules/integration-multivariable-variable-change/double-integrals-in-polar-coordinates}
\input{../../modules/integration-multivariable-variable-change/moment-inertia-2d-object-axis-in-same-plane}
\input{../../modules/integration-multivariable-variable-change/moment-inertia-annulus-axis-in-same-plane}
\input{../../modules/integration-multivariable-variable-change/use-of-polar-coordinates-in-double-integrals}
\input{../../modules/integration-multivariable-variable-change/polar-coordinates-double-integral-example-1}
\input{../../modules/integration-multivariable-variable-change/polar-coordinates-double-integral-improper-example-1}
\section{Triple Integrals in Cylindrical Coordinates}
\input{../../modules/integration-multivariable-variable-change/triple-integrals-in-cylindrical-coordinates}
\input{../../modules/integration-multivariable-variable-change/moment-inertia-cylindrical-coordinates}
\input{../../modules/integration-multivariable-variable-change/moment-inertia-cylindrical-shell}
\input{../../modules/integration-multivariable-variable-change/mass-center-regular-circular-cone}
\section{Triple Integrals in Spherical Coordinates}
\input{../../modules/integration-multivariable-variable-change/triple-integrals-in-spherical-coordinates}
\input{../../modules/integration-multivariable-variable-change/triple-integrals-in-spherical-coordinates-example-centroid-half-ball}
}

\lect{\currentSemester}{Lecture 17}{17}{%
%DesiredLectureName: Line_Integrals
\section{Line integrals}
\input{../../modules/integration-line-integrals/line-surface-integrals-intro}
%%%%%\input{../../modules/integration-line-integrals/line-integral-intro} %<- needs a rewrite
\input{../../modules/integration-line-integrals/line-integrals-Riemann-sums}
\input{../../modules/integration-line-integrals/line-integral-definition}
\input{../../modules/integration-line-integrals/line-integral-parametrization-and-computation}
\input{../../modules/integration-line-integrals/line-integral-example-1}
\subsection{Line Integral from Vector Field}
\input{../../modules/integration-line-integrals/line-integral-from-vector-field}
\input{../../modules/integration-line-integrals/line-integral-from-vector-field-parametrization-and-computation}
\input{../../modules/integration-line-integrals/line-integral-from-vector-field-example-1}
\subsection{Differential 1-forms}
\input{../../modules/integration-line-integrals/differential-1-forms}
\input{../../modules/integration-line-integrals/integrals-of-1-forms}
\input{../../modules/integration-line-integrals/line-integrals-over-closed-path-notation}
\input{../../modules/integration-line-integrals/integral-of-1-form-example-1-darctanydivx}
\input{../../modules/integration-line-integrals/integral-of-1-form-example-1-dlnr}
\input{../../modules/integration-line-integrals/integral-of-1-form-example-1-darctanydivx-in-polar}
\input{../../modules/integration-line-integrals/integral-of-1-form-example-1-dlnr-in-polar}

\input{../../modules/integration-line-integrals/integral-of-1-form-inverse-square-distance-fields}
\input{../../modules/integration-line-integrals/integral-of-1-form-independence-of-path-intro}
\input{../../modules/integration-line-integrals/conservative-fields}
\input{../../modules/integration-line-integrals/conservative-field-is-gradient-field}
\input{../../modules/integration-line-integrals/conservative-field-criterion}
\input{../../modules/integration-line-integrals/conservative-fields-simply-connected-regions}

\input{../../modules/integration-line-integrals/conservative-field-find-potential-example-1}
\input{../../modules/integration-line-integrals/exact-1-forms}
}

\lect{\currentSemester}{Lecture 18}{18}{%
%DesiredLectureName: 2d_orientation_Greens_Theorem
% % % % % %\input{../../modules/integration-line-integrals/conservation-of-energy}<-needs a rewrite
% % % % % %\input{../../modules/integration-line-integrals/vector-fields-2d-tangents-normals-intro}<-needs a rewrite

% % % %\input{../../modules/integration-line-integrals/flux-and-divergence-2d}<-needs companion slides to be used

% % % %\input{../../modules/integration-line-integrals/circulation-and-curl-2d}<-needs companion slides to be used

% % % % % % % %\input{../../modules/integration-line-integrals/curl-and-divergence-2d-in-coordinates} %<-needs a rewrite
\section{Orientation in 2D}
\input{../../modules/integration-line-integrals/curve-orientation}
\input{../../modules/integration-line-integrals/orientation-of-2d-space}
\input{../../modules/integration-line-integrals/orientation-of-2d-space-and-clock-direction}
\input{../../modules/integration-line-integrals/closed-curve-orientation-2d}
\section{Green's Theorem}
\input{../../modules/integration-line-integrals/greens-theorem}
\input{../../modules/integration-line-integrals/greens-theorem-proof-part1}
\input{../../modules/integration-line-integrals/greens-theorem-proof-part2}
\input{../../modules/integration-line-integrals/greens-theorem-proof-part3}
\input{../../modules/integration-line-integrals/areas-and-greens-theorem}
\input{../../modules/integration-line-integrals/areas-and-greens-theorem-example-1}
% % %\input{../../modules/integration-line-integrals/line-integrals-via-double-integrals-example1}<-needs a rewrite
\input{../../modules/integration-line-integrals/line-integrals-via-double-integrals-example2}
\input{../../modules/integration-line-integrals/greens-theorem-to-integrate-darctanydivx-part1}
\input{../../modules/integration-line-integrals/greens-theorem-to-integrate-darctanydivx-part2}
% % % % % %%\input{../../modules/integration-line-integrals/divergence-and-curl-2d}
% % % % % %%%\input{../../modules/integration-line-integrals/divergence-2d-interpretation}
% % % % % %%\input{../../modules/integration-line-integrals/curl-2d-interpretation}
% % % % % %%\input{../../modules/integration-line-integrals/curl-divergence-2d-polar}
% % % % % %%\input{../../modules/integration-line-integrals/curl-2d-example-rotational-field}
% % % % % %%\input{../../modules/integration-line-integrals/curl-2d-example-inverse-distance-square-field}
% % % % % %%\input{../../modules/integration-line-integrals/average-value-over-2d-region}
% % % % % %%\input{../../modules/integration-line-integrals/centroids-mass-centers-2d-regions}
}

\lect{\currentSemester}{Lecture 19}{19}{
%DesiredLectureName: Surface_Integrals
\section{Surface Integrals}
\input{../../modules/integration-surface-integrals/surface-integrals-intro}
\input{../../modules/vectors/magnitude-cross-product-and-gramm-determinants}
\subsection{Surface area}
\input{../../modules/integration-surface-integrals/surface-area}
\input{../../modules/integration-surface-integrals/surface-area-graph-surface}
\input{../../modules/integration-surface-integrals/surface-area-surface-of-revolution}
\input{../../modules/integration-surface-integrals/pappus-first-centroid-theorem}
\input{../../modules/integration-surface-integrals/surface-area-surface-of-revolution-example-torus}
\input{../../modules/integration-surface-integrals/surface-area-surface-of-revolution-example-sphere}
\input{../../modules/integration-surface-integrals/surface-integral-definition}
\input{../../modules/integration-surface-integrals/surface-integral-example-hemisphere-centroid}

%\input{../../modules/integration-surface-integrals/vector-valued-surface-integrals}<-needs rewrite
%\input{../../modules/integration-surface-integrals/vector-fields-in-space-geometric-intro}<-needs rewrite
\input{../../modules/integration-surface-integrals/surface-orientation}

\subsection{Flux and Divergence}
\input{../../modules/integration-surface-integrals/flux}
\input{../../modules/integration-surface-integrals/divergence}
\input{../../modules/integration-surface-integrals/flux-and-divergence}
\input{../../modules/integration-surface-integrals/flux-computation}
\input{../../modules/integration-surface-integrals/flux-example-1}
\input{../../modules/integration-surface-integrals/flux-example-2}
}

\lect{\currentSemester}{Lecture 20}{20}{
%DesiredLectureName: Divergence_Theorem_Stokes_Theorem
\section{Divergence Theorem}
\input{../../modules/integration-surface-integrals/divergence-theorem}
\input{../../modules/integration-surface-integrals/divergence-theorem-example-1}
\input{../../modules/integration-surface-integrals/divergence-theorem-application-balloon-pressure}
\input{../../modules/integration-surface-integrals/divergence-theorem-archimedes-law}
%\input{../../modules/integration-surface-integrals/rotational-effect}<-needs a rewrite
%\input{../../modules/integration-surface-integrals/vector-field-components} %<-needs a rewrite
%\input{../../modules/integration-surface-integrals/induced-orientation-and-curl}
%<-needs a rewrite
\input{../../modules/integration-surface-integrals/curl-definition-in-coordinate-form}

\input{../../modules/integration-surface-integrals/induced-orientation-boundary-curve}
\input{../../modules/integration-surface-integrals/induced-orientation-boundary-curve-example-hemisphere}
%\input{../../modules/integration-surface-integrals/coordinate-computation-of-curl-from-coordinate-free-definition}
%<-needs a rewrite
\input{../../modules/integration-surface-integrals/stokes-theorem}
%\input{../../modules/integration-surface-integrals/stokes-theorem-corollaries}<-needs a rewrite
\input{../../modules/integration-surface-integrals/stokes-theorem-applications}
\input{../../modules/integration-surface-integrals/stokes-theorem-example-line-via-surface-integral-1}
\input{../../modules/integration-surface-integrals/vector-potential}
\input{../../modules/integration-surface-integrals/stokes-theorem-example-surface-via-line-integral-1}
\input{../../modules/integration-surface-integrals/div-curl-grad}
%\input{../../modules/integration-surface-integrals/unifying-theme-rough-draft}<-needs a rewrite
}

\end{document}


\documentclass[11pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{vietnam}
\usepackage[margin=2cm]{geometry}
\usepackage[unicode]{hyperref}
\usepackage{color}
\usepackage{array}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{Operating Systems Course}
\lhead{Lab 7}
\rfoot{Page \thepage}
\lfoot{\leftmark}

\begin{document}

\begin{flushleft}
    \begin{tabular}{c}
        \\ \\ \hline \\
        \multicolumn{1}{l}{\textbf{{\Huge Lab 7 Scheduling}}}
        \\ \\
        \textbf{{\Huge Course: Operating Systems}}
        \\ \\ \hline \\
    \end{tabular}
\end{flushleft}

\selectlanguage{english}

\vspace{1cm}

\subsection*{Exercise 1 : Suppose that the following
processes arrive for execution at the times indicated.
Each process will run for the amount of time listed. In
answering the questions, use non-preemptive scheduling,
and base all decisions on the information you have at
the time the decision must be made.}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|c||c|c|}
    \hline
    Process & Arrival time & Burst time \\ \hline
    P1      & 0.0          & 8          \\ \hline
    P2      & 0.4          & 4          \\ \hline
    P3      & 1.0          & 1          \\ \hline
    \end{tabular}
\end{table}

\subsubsection*{a) What is the average turnaround time for these
processes with the FCFS scheduling algorithm?}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|m{8cm}|m{4cm}|m{1cm}|}
        \hline
        P1 & P2 & P3 \\
        \hline
    \end{tabular}

    \begin{tabular}{m{8cm} m{4cm} m{1cm} l }
        0 & 8 & 12 & 13 \\
    \end{tabular}

    \caption{Gantt chart - FCFS}
\end{table}

\begin{itemize}
    \item Turnaround time of process one is $T_{TT1} = 8 - 0 = 8$
    \item Turnaround time of process two is $T_{TT2} = 12 - 0.4 = 11.6$
    \item Turnaround time of process three is $T_{TT3} = 13 - 1 = 12$
\end{itemize}

The average turnaround time is $\overline T = (8 + 11.6 + 12) \div 3 $

\newpage
\subsubsection*{b) What is the average turnaround time
for these processes with the SJF scheduling algorithm?}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|m{8cm}|m{1cm}|m{4cm}|}
        \hline
        P1 & P3 & P2 \\
        \hline
    \end{tabular}

    \begin{tabular}{m{8cm} m{1cm} m{4cm} l }
        0 & 8 & 9 & 13 \\
    \end{tabular}

    \caption{Gantt chart - SJF - V1}
\end{table}

\begin{itemize}
    \item Turnaround time of process one is $T_{TT1} = 8 - 0 = 8$
    \item Turnaround time of process three is $T_{TT3} = 9 - 1 = 8$
    \item Turnaround time of process two is $T_{TT2} = 13 - 0.4 = 12.6$
\end{itemize}

The average turnaround time is $\overline T = (8 + 8 + 12.6) \div 3 $

\subsubsection*{c) The SJF algorithm is supposed to
improve performance, but notice that we chose to run process P1
at time 0 because we did not know that two shorter processes
would arrive soon. Compute what the average turnaround time will
be if the CPU is left idle for the first 1 unit and then SJF
scheduling is used. Remember that processes P1 and P2 are
waiting during this idle time, so their waiting time may
increase. This algorithm could be called future-knowledge
scheduling.}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|m{1cm}|m{1cm}|m{4cm}|m{8cm}|}
        \hline
        \O & P3 & P2 & P1 \\
        \hline
    \end{tabular}

    \begin{tabular}{m{1cm} m{1cm} m{4cm} m{8cm} l }
        0 & 1 & 2 & 6 & 14 \\
    \end{tabular}

    \caption{Gantt chart - SJF - V2}
\end{table}

\begin{itemize}
    \item Turnaround time of process three is $T_{TT3} = 2 - 1 = 1$
    \item Turnaround time of process two is $T_{TT2} = 6 - 0.4 = 5.6$
    \item Turnaround time of process one is $T_{TT1} = 14 - 0 = 14$
\end{itemize}

The average turnaround time is $\overline T = (1 + 5.6 + 14) \div 3 $

\newpage

\subsection*{Exercise 2 : The processes are assumed to have
arrived in the order P1, P2, P3, P4, P5, all at time 0. Draw
four Gantt charts that illustrate the execution of these
processes using the following scheduling algorithms: FCFS, SJF,
non-preemptive priority (a larger priority number implies a
higher priority), and RR (quantum = 1). Calculate the average
waiting time and turnaround time of each scheduling algorithm.}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|c||c|c|}
    \hline
    Process & Burst time & Priority \\ \hline
    P1      & 8          & 4        \\ \hline
    P2      & 6          & 1        \\ \hline
    P3      & 1          & 2        \\ \hline
    P4      & 9          & 2        \\ \hline
    P5      & 3          & 3        \\ \hline
    \end{tabular}
\end{table}

\subsubsection*{a) The First-Come, First-Served Scheduling (FCFS)}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|m{4cm}|m{3cm}|m{0.5cm}|m{4.5cm}|m{1.5cm}|}
        \hline
        P1 & P2 & P3 & P4 & P5 \\
        \hline
    \end{tabular}

    \begin{tabular}{m{4cm} m{3cm} m{0.5cm} m{4.5cm} m{1.5cm} l}
        0 & 8 & 14 & 15 & 24 & 27 \\
    \end{tabular}

    \caption{Gantt chart - FCFS}
\end{table}

\begin{itemize}
    \item The average turnaround time is $\overline T = (8 + 14 + 15 + 24 + 27) \div 5 $
    \item The average waiting time is $\overline T = (0 + 8 + 14 + 15 + 24) \div 5 $
\end{itemize}

\subsubsection*{b) Shortest Job First Scheduling (SJF)}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|m{0.5cm}|m{1.5cm}|m{3cm}|m{4cm}|m{4.5cm}|}
        \hline
        P3 & P5 & P2 & P4 & P1 \\
        \hline
    \end{tabular}

    \begin{tabular}{m{0.5cm} m{1.5cm} m{3cm} m{4cm} m{4.5cm} l}
        0 & 1 & 4 & 10 & 18 & 27 \\
    \end{tabular}

    \caption{Gantt chart - SJF}
\end{table}

\begin{itemize}
    \item The average turnaround time is $\overline T = (1 + 4 + 10 + 18 + 27) \div 5 $
    \item The average waiting time is $\overline T = (0 + 1 + 4 + 10 + 18) \div 5 $
\end{itemize}

\newpage

\subsubsection*{c) Non-preemptive Priority Scheduling}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|m{4cm}|m{1.5cm}|m{4.5cm}|m{0.5cm}|m{3cm}|}
        \hline
        P1 & P5 & P4 & P3 & P2 \\
        \hline
    \end{tabular}

    \begin{tabular}{m{4cm}m{1.5cm}m{4.5cm}m{0.5cm}m{3cm} l}
        0 & 8 & 11 & 20 & 21 & 27 \\
    \end{tabular}

    \caption{Gantt chart - non-preemptive priority}
\end{table}

\begin{itemize}
    \item The average turnaround time is $\overline T = (8 + 11 + 20 + 21 + 27) \div 5 $
    \item The average waiting time is $\overline T = (0 + 8 + 11 + 20 + 21) \div 5 $
\end{itemize}

\subsubsection*{d) Round Robin (RR)}

\begin{table}[!htp]
    \centering            %Center Table%
    \def\arraystretch{2}  %Margin Table%

    \begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|}
        \hline
        1&2&\textcolor{red}{3}&4&5&
        1&2&4&5&
        1&2&4&\textcolor{red}{5}&
        1&2&4&
        1&2&4&
        1&\textcolor{red}{2}&4&
        1&4&
        \textcolor{red}{1}&4&
        \textcolor{red}{4} \\
        \hline
    \end{tabular}

    \caption{Gantt chart - non-preemptive priority}
\end{table}
\begin{itemize}
    \item The average turnaround time is $\overline T = (3 + 13 + 21 + 25 + 27) \div 5 $
    \item The average waiting time is $\overline T = (17 + 15 + 2 + 18 + 10) \div 5 $
    \begin{itemize}
        \item The waiting time of P1 is $\overline T = 0 + 4 + 3 + 3 + 2 + 2 + 2 + 1 = 17$
        \item The waiting time of P2 is $\overline T = 1 + 4 + 3 + 3 + 2 + 2 = 15$
        \item The waiting time of P3 is $\overline T = 2$
        \item The waiting time of P4 is $\overline T = 3 + 3 + 3 + 3 + 2 + 2 + 1 + 1 = 18$
        \item The waiting time of P5 is $\overline T = 4 + 3 + 3 = 10$
    \end{itemize}
\end{itemize}

\newpage

\begin{thebibliography}{80}
    \bibitem{http://wikipedia:2019} Wikipedia. http://en.wikipedia.org, last access: 10/04/2019.
    \bibitem{osc}  Silberschatz, Galvin, and Gagne, Operating System Concepts.
    \bibitem{mos} Tanenbaum, Modern Operating Systems.
\end{thebibliography}

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Wenneker Assignment
% LaTeX Template
% Version 2.0 (12/1/2019)
%
% This template originates from:
% http://www.LaTeXTemplates.com
%
% Authors:
% Vel (vel@LaTeXTemplates.com)
% Frits Wenneker
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
%	PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[11pt]{scrartcl} % Font size

\input{structure.tex} % Include the file specifying the document structure and custom commands

%----------------------------------------------------------------------------------------
%	TITLE SECTION
%----------------------------------------------------------------------------------------

\title{
	\normalfont\normalsize
	\textsc{Gofinge's Notes}\\ % Your university, school and/or department name(s)
	\vspace{25pt} % Whitespace
	\rule{\linewidth}{0.5pt}\\ % Thin top horizontal rule
	\vspace{20pt} % Whitespace
	{\huge Expectation-Maximization Algorithm}\\ % The assignment title
	\vspace{12pt} % Whitespace
	\rule{\linewidth}{2pt}\\ % Thick bottom horizontal rule
}

\date{\normalsize February 21, 2019} % Today's date (\today) or a custom date

\begin{document}

\maketitle % Print the title

%----------------------------------------------------------------------------------------
%	 INTRODUCTION
%----------------------------------------------------------------------------------------

\section{Introduction to expectation-maximization(EM)  algorithm}

\subsection{An example of EM algorithm}

Let's start with an example from Chuong B Do \& Serafim Batzoglou‘s tutorial paper \textit{What is the expectation maximization algorithm?}, and I have saved the .pdf file of this paper in the \textit{material} folder.

\begin{figure}[h] % [h] forces the figure to be output where it is defined in the code (it suppresses floating)
	\centering
	\includegraphics[width=0.5\columnwidth]{example.png} % Example image
	\caption{Example: As an example, consider a simple coin-flipping experiment in which we are given a pair of coins A and B of unknown biases, $\theta_A$ and $\theta_B$, respectively. Our goal is to estimate $\theta = (\theta_A, \theta_B)$ by repeating the following procedure five times: randomly choose one of the two coins (with equal probability), and perform ten independent coin tosses with the selected coin. Thus, the entire procedure involves a total of 50 coin tosses'}
\end{figure}

If we can figure out whether the coin we flipped is A or B, we can estimate $\theta_A$ and $\theta_B$ through one of our most familiar friends, \textbf{MLE}.(Figure 1.1a) But actually, since we can not figure it out, MLE will not work in this situation. Then EM algorithm come on the stage. EM algorithm is simple because it just contain two steps in the Iteration and EM algorithm is complex is complex for its mathematical proof and further stretch in theory and application (Figure 1.1b) andI will explain the two steps in the following section.

\subsection{Two steps in iteration of EM}

 Given the statistical model which generates a set X of observed data(5 samples in coin-flipping experiment, and $x_i$ = \# of heads using the $1^{st}$ coin), a set of unobserved latent data or missing values Z(the coin is A or B), and a vector of unknown parameters $\theta$, along with a likelihood function $L(\theta; X, Z) = p(X, Z| \theta)$,  and the marginal likelihood function of the observed data is given by:

$$L(\theta; X) = p(X| \theta) = \int p(X, Z| \theta)dZ$$

However, this quantity is often intractable (we don't know the coin we tossed is A or B).

Then the EM algorithm seeks to find the MLE of the marginal likelihood by iteratively applying the following two steps.

\textbf{(a) Expectation Step:} Define $Q(\theta| \theta^{(t})$ as the expected value of the log likelihood function of $\theta$, with respect to the current conditional distribution of Z given X and the current estimates of the parametrers $\theta^{(t)}$:

$$Q(\theta|\theta^{(t)}) = E_{Z|X,\theta^{(t)}}[logL(\theta; X, Z)] = \int P(Z|X, \theta^{(t)}) ln P(X, Z| \theta)dz $$

\textit{note:} In discrete situation, we replace $\int$ by $\sum$.  In the coin-flipping experiment, we assume $\theta^{(0)} = (\theta_A^{(0)}, \theta_B^{(0)}) = (0.60, 0.50)$. Since the results of the first ten independent tosses is $x_1$ = 5 (\{H: 5, T: 5\}), we have $P(Z = A, X=x_1, \theta^{(0)}) = 0.6^5 \cdot 0.4^5$ and $P(Z = B, X=x_1, \theta^{(0)}) = 0.5^{10}$. Further,

$$P(Z = A|X = x_1, \theta^{(0)}) = \frac{P(Z = A, X=5, \theta^{(0)})}{P(Z = A, X=5, \theta^{(0)}) + P(Z = A, X=5, \theta^{(0)})} \approx 0.45,$$

$$P(Z = B|X = x_1, \theta^{(0)}) = \frac{P(Z = B, X=5, \theta^{(0)})}{P(Z = B, X=5, \theta^{(0)}) + P(Z = A, X=5, \theta^{(0)})} \approx 0.55$$

%----------------------------------------------------------------------------------------

\end{document}


\documentclass[letterpaper,9pt,twoside,printwatermark=false]{pinp}

%% Some pieces required from the pandoc template
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

% Use the lineno option to display guide line numbers if required.
% Note that the use of elements such as single-column equations
% may affect the guide line number alignment.

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

% The geometry package layout settings need to be set here...
\geometry{layoutsize={0.95588\paperwidth,0.98864\paperheight},%
          layouthoffset=0.02206\paperwidth,%
		  layoutvoffset=0.00568\paperheight}

\definecolor{pinpblue}{HTML}{185FAF}  % imagecolorpicker on blue for new R logo
\definecolor{pnasbluetext}{RGB}{101,0,0} %

\title{Exercise 1 - How Deep is the Ocean? September 17, 2018.}

\author[a]{EPIB607 - Inferential Statistics}

  \affil[a]{Fall 2018, McGill University}

\setcounter{secnumdepth}{5}

% Please give the surname of the lead author for the running footer
\leadauthor{Bhatnagar and Hanley}

% Keywords are not mandatory, but authors are strongly encouraged to provide them. If provided, please include two to five keywords, separated by the pipe symbol, e.g:
 \keywords{  Sampling distribution |  Means |  Proportions |  Standard error |  Standard deviation |  Parameter |  Statistic  }

\begin{abstract}
This in-class exercise will introduce you to sampling distributions for
means and proportions.
\end{abstract}

\dates{This version was compiled on \today}
\doi{\url{https://sahirbhatnagar.com/EPIB607/}}

\pinpfootercontents{Exercise 1: Sampling Distributions for Means and Proportions}

\begin{document}

% Optional adjustment to line up main text (after abstract) of first page with line numbers, when using both lineno and twocolumn options.
% You should only change this length when you've finalised the article contents.
\verticaladjustment{-2pt}

\maketitle
\thispagestyle{firststyle}
\ifthenelse{\boolean{shortarticle}}{\ifthenelse{\boolean{singlecolumn}}{\abscontentformatted}{\abscontent}}{}

% If your first paragraph (i.e. with the \dropcap) contains a list environment (quote, quotation, theorem, definition, enumerate, itemize...), the line after the list may have some extra indentation. If this is the case, add \parshape=0 to the end of the list environment.

\section{What percentage of the world's surface is covered by
water?}\label{what-percentage-of-the-worlds-surface-is-covered-by-water}

The data provided by the
\href{https://topex.ucsd.edu/cgi-bin/get_srtm30.cgi}{Scripps Institution
of Oceanography} can provide an answer, but some work is required on
your part. James Hanley (JH) has randomly sampled \(n=5\) and \(n=20\)
latitudes and longitudes for every student in the class. This document
contains unique latitudes and longitudes for

\begin{ShadedResult}
\begin{verbatim}
[1] "Bhatnagar, Sahir"
\end{verbatim}
\end{ShadedResult}

and was sent in an email (using the
\href{https://cran.r-project.org/package=gmailr}{gmailr} package) as a
pdf attachment to the following address:

\begin{ShadedResult}
\begin{verbatim}
[1] "sahir.bhatnagar@mcgill.ca"
\end{verbatim}
\end{ShadedResult}

\subsection*{A sample of 5}\label{a-sample-of-5}
\addcontentsline{toc}{subsection}{A sample of 5}

\begin{ShadedResult}
\begin{verbatim}
Longitude.n.5 <- c(-8.338,121.546,56.551,179.704,64.075)
\end{verbatim}
\end{ShadedResult}\begin{ShadedResult}
\begin{verbatim}
Latitude.n.5 <- c(38.531,24.208,11.288,79.076,-44.077)
\end{verbatim}
\end{ShadedResult}

\subsection*{A sample of 20}\label{a-sample-of-20}
\addcontentsline{toc}{subsection}{A sample of 20}

\begin{ShadedResult}
\begin{verbatim}
Longitude.n.20 <- c(129.865,8.409,69.401,-94.07,-141.684,84.384,4.708,59.453,170.693,145.75,
9.223,120.522,-154.618,121.445,-20.45,-90.918,101.493,127.653,97.46,124.264)
\end{verbatim}
\end{ShadedResult}\begin{ShadedResult}
\begin{verbatim}
Latitude.n.20 <- c(65.213,-17.739,10.111,-44.445,-59.084,21.162,-59.658,3.739,67.245,-4.353,
-15.5,14.423,-6.199,-32.676,-28.391,-21.106,-58.707,-20.757,17.094,24.236)
\end{verbatim}
\end{ShadedResult}

%\showmatmethods

\bibliography{pinp}
\bibliographystyle{jss}

\end{document}


% Lecture for ph2a Caltech 2017: Vibrations and Waves
\documentclass[pdf, handout, hideothersubsections]{beamer}
\usepackage{beamerthemeshadow}
\mode<presentation>
  {
    \usefonttheme{structuresmallcapsserif}
    \usetheme{Darmstadt}
    \usecolortheme{whale}
    %\useinnertheme{circles}
%    \useoutertheme{tree}
  }

\usepackage{svg}
\usepackage{xmpmulti}
\usepackage{mathtools}
%\usepackage{enumitem}
\usepackage{hyperref}
\hypersetup{
    pdffitwindow=true,     % window fit to page when opened
    colorlinks=true,       % false: boxed links; true: colored links
    linkcolor=orange,      % color of internal links
    citecolor=green,       % color of links to bibliography
    filecolor=magenta,     % color of file links
    urlcolor=blue,         % color of external links
    pdfstartview={Fit}
}

% Fonts/encoding
\renewcommand{\UrlFont}{\ttfamily\tiny}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage[sc,medium,raggedright]{titlesec}
\usepackage{newtxmath}
%\usepackage{libertine}
\usepackage[osf]{ebgaramond}

\graphicspath{{Figures/}}

\begin{document}
\title{Interference}
\author{Caltech: ph2a}
\date{21 - Nov - 2017}

\frame{\titlepage}

\frame{\frametitle{Table of Contents}\tableofcontents}

\setbeamerfont{footnote}{size=\tiny}

\section{Overview}
\begin{frame}
\frametitle{Overview:}
\begin{enumerate}
  \pause
\item Interference of waves leads to many phenomena: audio feedback
  for musicians, dead spots in cell reception, rogue waves in the
  ocean, satellite dishes, etc.
\pause
\item NASA Deep Space Network: communication with satellites
\pause
\item Optical Interferometry/Astronomy: Early Warnings for Extinction
  Level Asteroids
\pause
\item Time-tagged Cell phone accelerometer signals for early EQ warning

\end{enumerate}
\end{frame}

\begin{frame}
\frametitle{Satellite Dishes}
\includegraphics[width=0.99\textwidth]{Canberra_Deep_Space_Communication_Complex.jpg}

\end{frame}

\section{Interference of Two Waves}
\begin{frame}
\frametitle{Huygen's Principle}
\begin{columns}
  \begin{column}{0.3\textwidth}
    \includegraphics[width=0.99\textwidth]{Huygen.pdf}
  \end{column}

  \begin{column}{0.7\textwidth}
    \begin{itemize}
    \item A \emph{Wavefront} is a surface over which an optical wave has a
      constant phase.
      \pause
    \item In 3D, a point source emits spherical waves; i.e. it will emit
      spherical wavefronts.
      \pause
    \item For 2D, the wavefronts are circles.
      \pause
    \item Huygen's principle: the propagation of an arbitrary wave can be
      understood by imagining that each piece of a wavefront emits a
      secondary spherical wavelet. \pause The coherent superpostion of
      these wavelets determines the new wavefront.
    \end{itemize}
  \end{column}
\end{columns}
\end{frame}

\begin{frame}
\frametitle{Interference of Two Waves}
Let us consider two point sources of some kind of wave (need not be
electromagnetic):
\begin{columns}

  \begin{column}{0.4\textwidth}
    \includegraphics[width=0.99\textwidth]{TwoSource.jpg}
  \end{column}

  \begin{column}{0.6\textwidth}
\begin{align*}
\Psi &= \action<+->{A(r_1) e^{i (k r_1 - \omega t)} + A(r_2) e^{i (k r_2 - \omega t)}\\}
     \action<+->{&\simeq A \Big[e^{i (k r_1 - \omega t)} + e^{i (k r_2 - \omega t)}\Big] \\}
     \action<+->{&= A e^{i (k r - \omega t)} \times 2 \cos{k (r_2 -
                   r_1)} \\}
\action<+->{|\Psi|^2 &= 4 |A|^2 cos^2[k (r_2 - r_1)] \\}
\action<+->{|\Psi|^2 &= 4 |A|^2 cos^2[2 \pi \frac{d}{\lambda} \sin{\theta}]}
\end{align*}
\pause
where $\delta \phi$ is the phase \emph{difference}, $d$ is the average
distance from the slits to the source, and $\theta$ is the angle to
the point on the screen.
  \end{column}

  \end{columns}
\end{frame}

\begin{frame}
\frametitle{2 Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/IMGintpattern_f5000_n2.png}

\end{frame}

\section{Interference of N Sources}
\begin{frame}
\frametitle{3 Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/IMGintpattern_f5000_n3.png}

\end{frame}

\begin{frame}
\frametitle{N Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/IMGintpattern_f5000_n9.png}

see animations...

\end{frame}
%\section{Antennae}

\section{Interferometers}
\begin{frame}
\frametitle{Michelson Interferometer}
\begin{columns}
  \begin{column}{0.35\textwidth}
    \includegraphics[width=0.99\textwidth]{Michelson.jpg}
  \end{column}

  \begin{column}{0.65\textwidth}
    \begin{enumerate}
    \item Developed by Michelson in $\sim1880$ to look for the
      `luminiferous ether'
      \pause
    \item Illuminated by a single, `mono-chromatic' light source
      \pause
    \item Able to measure sub-nanometer displacements by $\sim1890$
      \pause
    \item Best Michelson interferometers today can measure
      $\sim10^{-16}$\,m.
      \pause
    \item Let's use our knowledge of superposition and interference to
      work out the sensitivity for two cases: \pause
      (1) the laser has truly one frequency, $\nu$ \pause
      and (2) the laser has a finite linewidth $\delta \nu$.

    \end{enumerate}
  \end{column}
\end{columns}
\end{frame}

\section{Optical Resonator}
\begin{frame}
\frametitle{The Fabry-Perot Interferometer}
Q: How can we determine the linewdith of a light (wave) source using
something other than a Michelson interferometer?\pause
A: We can use a SHO! Since we understand how the Bode Plot works for a
SHO, we can use it to characterize the laser. \pause

\begin{enumerate}
\item A Fabry-Perot resonator consists of two mirrors separated by a
  distance $L$, each with an \emph{amplitude} reflectivity, $r$.
\pause
\item As we did for the single layer anti-reflection coating, we can
  write down the relationships between all the fields.
\pause
\item Assuming that the mirrors are moving very slowly, with respect
  to the round trip travel time for the light, we can find the
  quasi-static solution to the fields.
\pause
\item Take a few minutes to solve for the fields...
\end{enumerate}
\pause
Now, let's plot it !!
\end{frame}

\begin{frame}
\frametitle{The Fabry-Perot Interferometer}

\centering
\includegraphics[width=0.99\textwidth]{../../Simulations/FabryPerot.pdf}

\end{frame}

\section{Summary}
\begin{frame}
\frametitle{Summary}
\begin{itemize}
  \item Huygen's principle can be used to propagate waves.
  \item It has not classical foundation, but it makes sense quantum-wise.
  \item The interference of waves can be understood using superposition

  \item Multiple wave interference is a natural extension of this method
  \item Interferometers are precise measurement tools: can convert
    optical phase changes into measureable power.

  \item Next: diffraction.

\end{itemize}
\footnotetext[1]{\url{https://www.khanacademy.org/test-prep/mcat/physical-processes/light-and-electromagnetic-radiation-questions/a/diffraction-and-constructive-and-destructive-interference}}
\end{frame}

\end{document}


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{September 22, 2014}
\maketitle
\section*{assignment}
Section 3.1: \#2, 7, 9, 11, 20.
\begin{enumerate}
\setcounter{enumi}{1}
\item
\begin{enumerate}
\item
no, not all elements have inverses
\item
no, no identity
\item
not associative
\item
no identity
\item
yes
\item
yes
\end{enumerate}
\setcounter{enumi}{6}
\item
this only includes things that are relatively prime to the item we are making the table for. of course 7 is prime,
\setcounter{enumi}{8}
\item
identity is $e$
\begin{align*}
  e=a^x\\
  \ln e=\ln a^x\\
  x\ln a=1\\
  x=\frac{1}{\ln a}
\end{align*}
\setcounter{enumi}{19}
\item
note that s is finite. we need to prove that an identity exists and every element is invertible.

$S=\{a_1,\dots,a_n\}, a\in S$. $\alpha:S\to S$ where $\alpha(x)=a\star x$. Claim, $\alpha$ is injective.$\alpha(x)=\alpha(y)=a\star x=a\star y\to x=y$. Since $S$ is finite and $\alpha$ is injective then $\alpha$ must be bijective and then surjective.

so $a\in S$ so there exists $e\in S$ st $\alpha(e)=a\star e=a$.

now we need to show that $e$ works for all elements, not just the $a$ that we chose

there exists $c\in S$ st $b=ca$. we have $\beta(x)=xa$ similar to above

so $b*e=(c*a)*e=c*(a*e)=c*a=b$

so there exists $b*e=b$ for all $b$ and similarly $e'*b=b$ for all $b$ in $S$.

claim $e=e'$. shown by $e'*e=e'$ and $e'*e=e$

so we have our identity.

and so on

proof doesn't work if $S$ is infinite because surjectivity isn't implied from injectivity

counterexample would be $(\mathbb{Z}^*,\cdot)$

note that this is proved more generally in 3.1.8
\end{enumerate}

\section*{3.2 subgroups}
let $(G,*)$ be a group and $H\subseteq G$ not equal to $\emptyset$. we say that $H$ is a subgroup of $G$ if with respect to the same operation, $H$ is a group.

\subsubsection*{example}
$(\mathbb{R},+), \mathbb{Q}\subseteq\mathbb{R}$, $\mathbb{Q}$ is a subgroup of $R$

checking associativity is a waste of time, it's given by super group. identity must also be in subgroup, inverse must exist for all elements of subgroup. and operation must be binary. eg it must be closed.

\subsection*{proposition 3.2.2}
\begin{itemize}
\item
$ab\in H$ for all $a,b\in H$
\item
$e\in H$
\item
$a^{-1}\in H$ for all $a\in H$
\end{itemize}
\subsubsection*{proof}
the operation being closed is clear

e being unique is done by observing $e'e'=e'$ where $e'$ is inverse in $H$. now in $G$ $e'e=e'$ and so $e'e'=e'e\to(e')^{-1}e'=(e')^{-1}e'e\to e'=e$

so the inverse is unique

then $e=ab$ but $e=a^{-1}$ so $ab=aa^{-1}\to a^{-1}ab=a^{-1}aa^{-1}$ so $b=a^{-1}$ if $b\in H$

closure brings identity and inverse automatically if $G$ is finite

trivial subgroups are the group itself and it's identity element
\section*{examples}

\end{document}


\documentclass[12pt]{article}  %,twocolumn is too scrunched. decrease margin, increase column seperation

%%%
%%% Composition of formulas for MST Qualifyin Exam
%%% All mistakes are mine, all work is cited by Author
%%% Creative Commons:
%%% Attribution-Noncommercial-Share Alike 3.0 Unported
%%% http://creativecommons.org/licenses/by-nc-sa/3.0/
%%%

\usepackage{verbatim} % multi-line comments
\usepackage[pdftitle={equations for the qualifying exam}, pdfauthor={Ben Payne}, pdfsubject={equations}, pdfkeywords={maxwell, lagrange}]{hyperref}
\usepackage{times}

% AMS packages and font files
\usepackage{amsmath} % necessary for gathered equations
\usepackage{amsfonts}
%% For figures
%\usepackage[dvipdfm,colorlinks=true]{hyperref}
\usepackage[dvips]{graphicx}
\usepackage[usenames,dvipsnames]{color}
\usepackage{setspace}

% screws up the paragraph formatting
%\raggedright

% margins must be 1 inch:
%\begin{comment}
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\textwidth}{6.5in}
%\end{comment}

%% Commonly used macros
% from https://facetsproject.org/facets/browser/trunk/docs/gsdocs/nondimtf2hall.tex
\newcommand{\pfrac}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\pfraca}[1]{\frac{\partial}{\partial #1}}
\newcommand{\pfracb}[2]{\partial #1/\partial #2}

\begin{document}
%\twocolumn
\title{Physics equations}
\author{Ben~Payne\footnote{Electronic address: ben.is.located@gmail.com}}
%\affiliation{Department~of~Physics, Missouri~University~of~Science~\&~Technology, Rolla,~MO~65409}
\date{\today}

\thispagestyle{empty}  % hides page number of the title page
\pagestyle{empty} % no page numbers on the following pages
%\begin{abstract}
%equations for the qualifying exam
%\end{abstract}

version 0.03, 20090512

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{unit conversion}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%see http://en.wikibooks.org/wiki/LaTeX/Tables
%for help with tables

see http://physics.nist.gov/cuu/Units/units.html and \cite{ZemanskyYoungGen} page T-5 \\

\begin{tabular}{lcccc}
Description                    & Name    & Symbol   & convert          & SI \\
\hline
\\[0.1pt]
Force                          & Newton  & N        &                   & $\frac{m \ kg}{s^2}$  \\
\\[0.1pt]
energy, work, quantity of heat & joule   & J        & $N \ m$            & $\frac{m^2 \ kg}{s^2}$ \\
\\[0.1pt]
power                          & Watt    & W        & $\frac{J}{s}$      & $\frac{m^2 \ kg}{s^3}$ \\
\\[0.1pt]
pressure, stress               & pascal  & Pa       & $\frac{N}{m^2}$    & $\frac{kg}{m \ s^2}$ \\
\\[0.1pt]
electric charge,
quantity of electricity        & coulomb & C        &                   & $s \ A$ \\ % amp/second?
\\[0.1pt]
electric potential difference,
electromotive force            & volt    & V        & W/A  % J/C?           & $\frac{m^2 \ kg}{s^3 \ A}$ \\
\\[0.1pt]
capacitance                    & farad   & F        & C/V             & $\frac{s^4 \ A^2}{m^2 \ kg}$ \\
\\[0.1pt]
electric resistance            & ohm     & $\Omega$ & V/A             & $\frac{m^2 \ kg}{s^3 \ A^2}$ \\
\\[0.1pt]
magnetic field                 & Tesla   & T        & $\frac{V \ s}{m}$  % N/(A m)? & $\frac{m \ kg}{s^2 \ A}$ \\
\end{tabular}

\ \\

$1 \text{Joule} = 6.24150974 \ 10^{18}$ electron volts

\ \\
$k_{Boltzmann} T_{room} = \frac{1}{40}$ eV

\ \\
$T_{room} = 293.15 K$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{constants}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

see http://en.wikipedia.org/wiki/Physical\_constant and  http://physics.nist.gov/cuu/Constants/

\ \\

Universal constants : \\

\begin{tabular}{lcr}
Description                       & Symbol                  & SI value \\
\hline
\\[0.1pt]
speed of light in vacuum          & c                       & $299 792 458 \ \frac{m}{s}$ \\
\\[0.1pt]
Newtonian constant of gravitation & G                       & $6.67428(67) \ 10^{−11} \frac{m^3}{kg \ s^2}$ \\
\\[0.1pt]
Planck's constant                 & h                       & $6.626 068 96(33) \ 10^{−34} \  J \ s$ \\
\\[0.1pt]
reduced Planck constant           & $\hbar = \frac{h}{2 \pi}$ & $1.054 571 628(53) \ 10^{−34} \ J \ s$ \\
\end{tabular}

\ \\

\begin{tabular}{lcr}
Description                             & Symbol, definition                         & SI value \\
\hline
\\[0.1pt]
magnetic constant (vacuum permeability) & $\mu_0$                                    & $4 \pi \ 10^{−7} \frac{N}{A^2}$ \\
\\[0.1pt]
electric constant (vacuum permittivity) & $\epsilon_0 = \frac{1}{\mu_0 c^2}$         & $8.854 187 817 \ 10^{−12} \ \frac{F}{m}$ \\
\\[0.1pt]
elementary charge                       & $e$                                       & $1.602 176 487(40) \ 10^{−19} \ C$ \\
\\[0.1pt]
Bohr radius                             & $a_0 = \frac{\alpha}{4 \pi R_\infty}$      & $0.529 177 2108(18) \ 10^{−10} \ m$ \\
\\[0.1pt]
classical electron radius               & $r_e = \frac{e^2}{4\pi\epsilon_0 m_e c^2}$ & $2.817 940 2894(58) \ 10^{−15} \ m$ \\
\\[0.1pt]
electron mass                           & $m_e$                                      & $9.109 382 15(45) \ 10^{−31} \ kg = 511 \frac{KeV}{c^2}$  \\
\\[0.1pt]
fine-structure constant                 &$ \alpha = \frac{\mu_0 e^2 c}{2 h} =
                                          \frac{e^2}{4 \pi \epsilon_0 \hbar c}$     & $7.297 352 5376(50) \ 10^{−3}$ \\
proton mass                             & $m_p $                                     & $1.672 621 637(83) \ 10^{−27} \ kg$ \\
\\[0.1pt]
Rydberg constant                        & $R_\infty = \frac{\alpha^2 m_e c}{2 h}  $        & $10 973 731.568 525(73) \ \frac{1}{m}$ \\
\\[0.1pt]
atomic mass unit
\\[0.1pt]
(unified atomic mass unit)              & $m_u = \frac{1}{u} $                             & $1.660 538 86(28) \ 10^{−27} \ kg$ \\
\\[0.1pt]
Avogadro's number                       & $N_{Av}$                                   & $6.022 1415(10) \ 10^{23} \ \frac{1}{mol}$ \\
\\[0.1pt]
Boltzmann constant                      & $k_{B} = \frac{R}{N_{Av}} $                         & $1.380 6505(24) \ 10^{−23} \ \frac{J}{K}$ \\
\\[0.1pt]
gas constant                            & $R$                                        & $8.314 472(15) \ \frac{J}{K \ mol}$ \\
\\[0.1pt]
standard atmosphere                     & $atm$                                      & $101 325 \ Pa = 14.7 \ Psi $
\end{tabular}
\ \\
Miscellaneous:
\begin{equation}
 1 \ eV = 1.602 \ 10^{-19} J
\end{equation}

standard temperature is $293.15 \ K$

\begin{equation}
 \frac{m_{proton}}{m_e} = 1836
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Symbol notations}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

See page 631-642 of \cite{ReifThermo}

$C_v \equiv$ specific heat for constant volume

$k_b \equiv$ Boltzmann constant

$\vec{E} \equiv$ electric field

$\vec{B} \equiv$ magnetic field

$\vec{D} \equiv$ electric displacement, equ 4.21, page 175 \cite{GriffithED}

$\vec{N} \equiv$ torque

$W \equiv$ work

$\vec{v} \equiv$ velocity

$V \equiv$ electrostatic potential [Volts]

$V \equiv$ volume

$U \equiv$ potential energy [Volts]

$\vec{P} \equiv$ polarization, page 166 \cite{GriffithED}

$I \equiv$ current [Amps]

$\vec{F} \equiv$ force [Newtons, $\frac{kg \cdot m}{s^2}$]

$E \equiv$ energy

$T \equiv$ kinetic energy

$T \equiv$ temperature

$L \equiv$ lagrangian

$L \equiv$ capacitance

$\vec{L} \equiv$ classical (orbital) angular momentum

$l \equiv$ quantum (orbital) angular momentum

$\vec{p} \equiv$ linear momentum

$\omega \equiv$ angular frequency

$z \equiv$ single particle partition function

$Z \equiv$ total partition function

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{thebibliography}{99}

\bibitem{ZemanskyYoungGen}
Sears, Zemansky, Young \textit{University Physics, Fifth edition}, (1976)

\bibitem{GriffithED}
Griffith \textit{Intro to Electrodynamics}, (1999)

\bibitem{JacksonED}
Jackson \textit{Classical Electrodynamics}, (1999)

\bibitem{GoldsteinCM}
Goldstein \textit{Classical Mechanics}, (1980) (second edition)\\
Available from Aaron

\bibitem{ReifThermo}
Reif \textit{Fundamentals of statistical and thermal physics}, (1965)

\bibitem{ParrisQM}
Parris's book on \textit{Quantum mechanics}, (2008) \\
\htmladdnormallink{463 course page}{http://physics.mst.edu/classes/class_463notes.html}

\bibitem{LiboffQM}
Liboff \textit{Introduction to Quantum mechanics}, (2003) Fourth edition

\bibitem{MarionCM}
Marion \textit{Classical Dynamics of Particles and systems}, (1970) Second edition. \\
Available from Prof Waddill, Elizabeth

\bibitem{TiplerMP}
Tipler, Llewellyn \textit{Modern Physics}, (1999)

\end{thebibliography}

\end{document}


\documentclass{article}
\usepackage{listings}
% \usepackage{ctex}
\usepackage{amsmath}
\usepackage[a4paper, left = 2cm, right = 2cm]{geometry}
\usepackage[colorlinks, urlcolor=blue]{hyperref}

\begin{document}

\begin{titlepage}
    \title{Chapter 4: Naive Bayes}
    \author{\href{https://github.com/ZacBi}{Zac Bi}}
    \date{December 18, 2019}
    \maketitle
    \thispagestyle{empty}
\end{titlepage}

\section*{Solutions}

\subsection*{4.1}
\paragraph*{}
Recall that for a doc, the prob it is labeled as class $c$:
\begin{align*}
    \hat{c} & = \mathop{arg} \limits_{c} \max P(c|d)                                                       \\
            & = \mathop{arg} \limits_{c \in C} \max P(c) \! \prod_{i \in position} \!\!\!\!\!\!\! P(w_i|c)
\end{align*}

% \paragraph*{{}}
% Compute equation above in log space to turn it to **linear classifier**:
% \begin{align*}
%     \hat{c} & = \mathop{arg} \limits_{c} \max \log(P(c)) + \sum_{i \in positions} \!\!\!\!\!\!\!P(w_i|c)
% \end{align*}

For positive:
\begin{align*}
    P(pos|d) & = P(\texttt{I|pos}) \times \dots \times P(\texttt{films|pos}) \\
             & = 0.09 \times 0.07 \times 0.29 \times 0.04 \times 0.08        \\
             & = 5.84 \times 10^{-6}
\end{align*}

For negtive:
\begin{align*}
    P(neg|d) & = P(\texttt{I|neg}) \times \dots \times P(\texttt{films|neg}) \\
             & = 0.16 \times 0.06 \times 0.06 \times 0.15 \times 0.11        \\
             & = 9.5 \times 10^{-6}
\end{align*}

So NB will assign positive to the sentence 'I always like foreign films.'

\subsection*{4.2}

\paragraph*{}
Counts and probs(after add-1 smoothing) for each word in train set($P(comedy) = 0.4, P(action) = 0.6$):

\begin{center}
    \begin{tabular}{c c c c c}
        word    & comedy & action & $\textrm{P}_\textrm{comedy}$ & $\textrm{P}_\textrm{action}$
        \\ \hline
        fun     & 3      & 1      & 0.25                         & 0.111
        \\ \hline
        couple  & 2      & 0      & 0.1875                       & 0.055
        \\ \hline
        love    & 2      & 1      & 0.1875                       & 0.111
        \\ \hline
        fast    & 1      & 2      & 0.125                        & 0.167
        \\ \hline
        furious & 0      & 2      & 0.0625                       & 0.167
        \\ \hline
        shoot   & 0      & 4      & 0.0625                       & 0.278
        \\ \hline
        fly     & 1      & 1      & 0.125                        & 0.111
    \end{tabular}
\end{center}

For P(comedy|D):
\begin{align*}
    P(comedy|D) & = P(comedy) \times P(w_1^n|comedy)                            \\
                & = 0.4 \times (0.125 \times 0.1875 \times 0.0625 \times 0.125) \\
                & = 7.3 \times 10^{-5}
\end{align*}

For P(action|D):
\begin{align*}
    P(action|D) & = P(action) \times P(w_1^n|action)                          \\
                & = 0.6 \times (0.165 \times 0.055 \times 0.278 \times 0.111) \\
                & = 1.68 \times 10^{-5}
\end{align*}

So the most likely class for D is comedy.

\subsection*{4.3}
\paragraph*{}

For binarized naive Bayes, the table should like:
\begin{center}
    \begin{tabular}{c c c c c}
        doc & 'good' & 'poor' & 'great' & (class) \\
        d1  & 1      & 0      & 1       & pos     \\
        d2  & 0      & 1      & 1       & pos     \\
        d3  & 1      & 1      & 0       & neg     \\
        d4  & 1      & 1      & 1       & neg     \\
        d5  & 0      & 1      & 0       & neg     \\
    \end{tabular}
\end{center}

\paragraph*{}
Now we mark the test sentence as test document D, which has been removed unseen words in vocabulary, i.e,
\texttt{good good great poor}
then we compute probs of neg and pos for each NB model
(mNB: multinominal NB, bNB: binarized NB).

\begin{align*}
    P_{\text{mNB}}(pos|D) & = P_{\text{mNB}}(pos) \times \prod_{i \in positions}P_{\text{mNB}}(w_i|pos)      \\
                          & = P_{\text{mNB}}(pos) \times                                                     \\
                          & \quad P_{\text{mNB}}(\texttt{good}|pos) \times P_{\text{mNB}}(\texttt{good}|pos)
    \times P_{\text{mNB}}(\texttt{poor}|pos) \times P_{\text{mNB}}(\texttt{great}|pos)                       \\
                          & = 0.4 \times 0.33 \times 0.33 \times 0.5 \times 0.17                             \\
                          & = 0.0037                                                                         \\
    P_{\text{mNB}}(neg|D) & = P_{\text{mNB}}(neg) \times \prod_{i \in positions}P_{\text{mNB}}(w_i|neg)      \\
                          & = 0.6 \times 0.176 \times 0.176 \times 0.176 \times 0.647                        \\
                          & = 0.0021                                                                         \\
    P_{\text{bNB}}(pos|D) & = P_{\text{bNB}}(pos) \times \prod_{i \in positions}P_{\text{bNB}}(w_i|pos)      \\
                          & = 0.4 \times 0.286 \times 0.286 \times 0.428 \times 0.286                        \\
                          & = 0.004                                                                          \\
    P_{\text{bNB}}(neg|D) & = P_{\text{bNB}}(neg) \times \prod_{i \in positions}P_{\text{bNB}}(w_i|neg)      \\
                          & = 0.6 \times 0.33 \times 0.33 \times 0.22 \times 0.45                            \\
                          & = 0.006                                                                          \\
\end{align*}

\paragraph*{}
Multinominal NB model assigns pos to D while binarized NB model is just the opposite.

\end{document}