\documentclass[10pt]{article}

\usepackage{systeme}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
%\usepackage{palatino}
\usepackage{setdeck}

\usepackage{xcolor}
%\usepackage{tcolorbox}

%\usepackage[textheight=8.5in, margin=1.6in]{geometry}
\usepackage[total={6in,8in}]{geometry}

\usepackage{tikz}
\usetikzlibrary{cd}
\tikzset{
      labr/.style={anchor=north, rotate=90, inner sep=.7mm}
    }
\tikzset{
      labl/.style={anchor=south, rotate=90, inner sep=.7mm}
    }

%\usepackage{pgfplots}
\tikzstyle{ball} = [circle,shading=ball, ball color=black,
    minimum size=1mm,inner sep=1.3pt]
%\usetikzlibrary{arrows.meta}
%\tikzset{>={Latex[length=2mm,width=1.5mm]}}

%\usepackage{graphicx}

\usepackage{needspace}  % <-- to prevent bad pagebreak over environment titles
% Use:  \Needspace{3\baselineskip} before opening an environment

\usepackage[shortlabels]{enumitem}
\setlist[enumerate]{leftmargin=*,label=(\alph*)}

%\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\sn}{\mathfrak{S}}
\newcommand{\PP}{\mathbb{P}}
\newcommand{\ve}{\varepsilon}
\newcommand{\ips}[2]{\langle{#1}, {#2}\rangle}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\Span}{\mathrm{Span}}
\DeclareMathOperator{\rk}{\mathrm{rank}}
\DeclareMathOperator{\rspace}{\mathrm{rowspace}}
\DeclareMathOperator{\cspace}{\mathrm{colspace}}
\DeclareMathOperator{\trace}{\mathrm{tr}}
\DeclareMathOperator{\im}{\mathrm{im}}
\DeclareMathOperator{\Sym}{\mathrm{Sym}}
\DeclareMathOperator{\Hom}{\mathrm{Hom}}
\DeclareMathOperator{\diag}{\mathrm{diag}}
\DeclareMathOperator{\glb}{\mathrm{glb}}
\DeclareMathOperator{\lub}{\mathrm{lub}}
\DeclareMathOperator{\real}{\mathrm{Re}}
\DeclareMathOperator{\imag}{\mathrm{Im}}

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

\allowdisplaybreaks

\begin{document}
\centerline{Math 201 lecture for Friday, Week 11}
\bigskip

\centerline{\textbf{Lengths, distances, components, angles}}  
\bigskip
 
\textbf{Definition.} Let~$(V,\ips{\,}{})$ be an inner product space over~$F=\R$
or~$\C$.  The \emph{norm} or \emph{length} of~$x\in V$ is
\[
  \lVert x\rVert =\sqrt{\ips{x}{x}}\in\R_{\geq0}.
\]
Two vectors~$x,y\in V$ are \emph{orthogonal} or \emph{perpendicular}
if~$\ips{x}{y}=0$.  A \emph{unit vector} is a vector of
norm~$1$: so~$x\in V$ is a unit vector if~$\lVert x\rVert=1$, which is
equivalent to~$\ips{x}{x}=1$.
\medskip

\textbf{Examples of norms.} 
\begin{itemize}
  \item $V=\R^n$, $\ips{x}{y}=x\cdot y$, the usual dot product.  Then
    for~$x\in\R^n$,
    \[
      \lVert x\rVert=\sqrt{x_1^2+\cdots+x_n^2}.
    \]
  \item $V=\C^n$, $\ips{x}{y}=x\cdot\overline{y}$, the usual dot product
    on~$\C^n$.  Then for~$z\in\C^n$,
    \begin{align*}
      \lVert z\rVert
      &= \sqrt{z_1\overline{z_1}+\cdots+z_n\overline{z_n}}\\
      &= \sqrt{|z_1|^2+\cdots+|z_n|^2}.
    \end{align*}
    If~$z_j\in\C$ is written as~$z_j=x_j+iy_j$ with~$x_j,y_j\in\R$,
    then~$|z_j|^2=x_j^2+y_j^2$.  So then
    \[
      \lVert z\rVert =  \sqrt{x_1^2+y_1^2+\cdots+x_n^2+y_n^2}.
    \]
    Thus, if we identify~$\C^n$ with~$\R^{2n}$ via the isomorphism
    \[
      (x_1+iy_1,\dots,x_n+iy_n)\to(x_1,y_1,\dots,x_n,y_n),
    \]
    then the isomorphism preserves norms.
\end{itemize}
\medskip 

\textbf{Proposition.} (Pythagorean theorem)  Let~$(V,\ips{\,}{})$ be an inner product space over~$F=\R$
or~$\C$, and let~$x,y\in V$ be perpendicular.  Then
\[
  \lVert x\rVert^2+\lVert y\rVert^2=\lVert x+y\rVert^2.
\]
\begin{center}
  \begin{tikzpicture}[scale=1.2]
  \draw[->] (0,0)--(2,0);
  \draw[->] (0,0)--(0,1.5);
  \draw[->] (0,0)--(2,1.5);
  \draw[->,dashed] (2,0)--(2,1.5);
  \node at (-0.2,-0.2) {$\vec{0}$};
  \node at (2,-0.2) {$x$};
  \node at (1.0,-0.3) {$\lVert x\rVert$};
  \node at (2.4,0.7) {$\lVert y\rVert$};
  \node at (-0.2,1.5) {$y$};
  \node at (2.4,1.8) {$x+y$};
  \node[rotate=37] at (0.85,1.0) {$\lVert x+y\rVert$};
\end{tikzpicture}
\end{center}

\begin{proof}
  Since~$x$ and~$y$ are perpendicular, we have~$\ips{x}{y}=0$.  
  It follows that~$\ips{y}{x}=\overline{\ips{x}{y}}=0$, too.  Therefore,
  \begin{align*}
    \lVert x+y\rVert^2
    &=\ips{x+y}{x+y}\\
    &=\ips{x}{x}+\ips{x}{y}+\ips{y}{x}+\ips{y}{y}\\
    &=\ips{x}{x}+\ips{y}{y}\\
    &=\lVert x\rVert^2+\lVert y\rVert^2.
  \end{align*}
\end{proof}

Suppose we are given two vectors~$x,y$ in an inner product space. A useful
geometric operation is to break~$x$ into two parts, one of which lies along the
vector~$y$. Given any number~$c$, the vector~$cy$ lies along~$y$ and we can
evidently write~$x$ as the sum of two vectors: $x=(x-cy)+cy)$.  In addition,
though, we would like to require, by adjusting~$c$, that the vector~$x-cy$ is
perpendicular to~$y$.  The picture in~$\R^2$ would be:
\begin{center}
  \begin{tikzpicture}
    \draw[->] (0,0)--(3.5,0);
    \draw[->] (0,0)--(2.0,0);
    \node at (3.5,-0.3) {$y$};
    \draw[->] (0,0)--(2,2);
    \node at (1.7,2.2) {$x$};
    \draw[dashed] (2,0)--(2,2);
    \node at (2.0,-0.3) {$cy$};
    \node at (-0.2,-0.2) {$\vec{0}$};
  \end{tikzpicture}
\end{center}
We can calculate the required scalar~$c$:
\[
  \ips{x-cy}{y}=0
  \Longleftrightarrow \ips{x}{y}-c\ips{y}{y}=0
  \Longleftrightarrow c=\frac{\ips{x}{y}}{\ips{y}{y}}
  \Longleftrightarrow c=\frac{\ips{x}{y}}{\lVert y\rVert^2},
\]
which makes sense as long as~$y\neq0$.
\medskip

\textbf{Definition.} Let~$(V,\ips{\ }{\ })$ be an inner product space over~$F=\R$
or~$\C$, and let~$x,y\in V$ with~$y\neq 0$.  The \emph{component}
of~$x$ along~$y$ is the scalar
\[
  c=\frac{\ips{x}{y}}{\ips{y}{y}}=\frac{\ips{x}{y}}{\lVert y\rVert^2}.
\]
The \emph{orthogonal projection} of~$x$ to~$y$ is the
vector~$cy$.
\medskip

\textbf{Example.} Let~$x\in V = \R^n$ or~$\C^n$, and let~$e_j$ be the~$j$-th
standard basis vector.  Then
\[
  \frac{\ips{x}{e_j}}{\ips{e_j}{e_j}}= \frac{x_{j}}{1}=x_j.
\]
Thus,~$x_j$ is the component of~$x$ along~$e_j$, and~$x_je_j$ is the projection
of~$x$ to~$e_j$.
\medskip

\textbf{Example.} Let~$x=(3,2)$ and~$y=(5,0)=5e_1$ in~$\R^2$ with the usual inner
product.  Then the component of~$x$ along~$y$ is
\[
\frac{\ips{x}{y}}{\ips{y}{y}}=
\frac{(3,2)\cdot(5,0)}{(5,0),(5,0)}=
\frac{15}{25}=
\frac{3}{5}.
\]
So the projection of~$x$ to~$y$ is
\[
  cy=\frac{3}{5}(5,0)=(3,0),
\]
as expected.

\Needspace{3\baselineskip}
\textbf{Proposition.} Let~$(V,\ips{\ }{\ })$ be an inner
product space over~$F=\R$ or~$\C$. Let~$x,y\in V$ and ~$c\in F$.  Then
\begin{enumerate}
  \item\label{11friit1} $\lVert cx\rVert=|c|\lVert x\rVert$.
  \item\label{11friit2} $\lVert x\rVert=0$ if and only if~$x=0$.
  \item\label{11friit3} Cauchy-Schwarz inequality: $\left|\ips{x}{y}\right|\leq\lVert x\rVert \lVert y\rVert$.
  \item\label{11friit4} Triangle inequality: $\lVert x+y\rVert\leq\lVert x\rVert+\rVert
    y\rVert$.
\end{enumerate}

\begin{proof}
  Parts~\ref{11friit1} and~\ref{11friit2} are left as exercises.
  Part~\ref{11friit3} is tricky.  If~$y=0$, we're
  done.  So assume~$y\neq0$, and let~$c=\ips{x}{y}/\ips{y}{y}$ be the component
  of~$x$ along~$y$.  By construction,~$x-cy$ is perpendicular to~$y$ and hence
  to~$cy$.  Therefore, by the Pythagorean theorem,
  \[
    \lVert x-cy\rVert^2+\lVert cy\rVert^2=\lVert(x-cy)+cy\rVert^2=\lVert x\rVert^2.
  \]
  Since~$\lVert x-cy\rVert^2\geq0$, if we drop that term in the above equation, we
  get
  \[
    \lVert cy\rVert^2\leq\lVert x\rVert^2.
  \]
  Take square roots to get
  \[
  \lVert x\rVert\geq \lVert cy\rVert=|c|\lVert y\rVert
  =\left|\frac{\ips{x}{y}}{\lVert y\rVert^2}\right|\lVert y\rVert
  =\frac{|\ips{x}{y}|}{\lVert y\rVert}.
  \]
  Multiply through by~$\lVert y\rVert$ to get Cauchy-Schwarz.
  
  For the proof of the triangle inequality, we will need two basis results
  concerning complex numbers.  Let~$z=a+bi$ be any complex number.  Then we have
  (i) $z+\overline{z}=(a+bi)+(a-bi)=2a$.  So
  \[
    z+\overline{z}=2\real(z),
  \]
  and (ii) $|z|=\sqrt{a^2+b^2}\geq|a|$. So  
  \[
    \real(z)\leq |z|.
  \]
  The triangle inequality is then an easy consequence of Cauchy-Schwarz:
  \begin{align*}
  \lVert x+y\rVert^2 &=\ips{x+y}{x+y}\\
  &=\ips{x}{x}+\ips{x}{y}+\ips{y}{x}+\ips{y}{y}\\
  &=\lVert x\rVert^2+\ips{x}{y}+\ips{y}{x}+\lVert y\rVert^2\\
  &=\lVert x\rVert^2+\ips{x}{y}+\overline{\ips{x}{y}}+\lVert y\rVert^2\\
  &=\lVert x\rVert^2+2\real(\ips{x}{y})+\lVert y\rVert^2\\
  &\leq\lVert x\rVert^2+2\left|\ips{x}{y}\right|+\lVert y\rVert^2\\
  &\leq\lVert x\rVert^2+2\Vert x \Vert \Vert y \Vert +\lVert y\rVert^2\\
  &\leq(\lVert x\rVert+\lVert y\rVert)^2.
  \end{align*}
  Take square roots to get the triangle inequality.
\end{proof}

\textbf{Distance.} Let~$(V,\ips{\ }{\ })$ be an inner product space over~$\R$
  or~$\C$.  The \emph{distance} between~$x,y\in V$ is defined to be
  \[
    d(x,y):=\rVert x-y\rVert.
  \]
The following properties then easily follow from what we have already done:
\medskip

\Needspace{3\baselineskip}

\textbf{Proposition.} For all~$x,y,z\in V$,
\begin{enumerate}
  \item Symmetry: $d(x,y)=d(y,x)$.
  \item Positive-definiteness: $d(x,y)\geq0$, and~$d(x,y)=0$ iff~$x=y$.
  \item Triangle inequality: $d(x,y)\leq d(x,z)+d(z,y)$.
\end{enumerate}
\medskip

\textbf{Angles.} Now let~$(V,\ips{\ }{\ })$ be an inner product space over~$F=\R$.
(So we will not consider the case~$F=\C$ in our discussion of angles.) We would
like to define the notion of an {\em angle} between~$x,y\in V$. Our
picture for the component provides motivation:
\begin{center}
  \begin{tikzpicture}
    \draw[->] (0,0)--(3.5,0);
    \draw[->] (0,0)--(2.0,0);
    \node at (3.5,-0.3) {$y$};
    \draw[->] (0,0)--(2,2);
    \node at (1.7,2.2) {$x$};
    \draw[dashed] (2,0)--(2,2);
    \draw[->] (0.5,0) arc (0:35:0.7);
    \node at (0.8,0.3) {$\theta$};
    \node at (2.0,-0.3) {$cy$};
    \node at (-0.2,-0.2) {$\vec{0}$};
    \node at (3.5,1.5) {$c=\frac{\ips{x}{y}}{\lVert y\rVert^2}$};
  \end{tikzpicture}
\end{center}
The dashed vertical line and the vector~$y$ are perpendicular (by definition
of~$c$).  The cosine of the displayed angle should be the length of the
base,~$cy$, divided by the length of the hypotenuse,~$x$.  That quotient is
\[
  \frac{\lVert cy\rVert}{\lVert x\rVert}=|c|\frac{\lVert y\rVert}{\lVert x\rVert}
  =\frac{|\langle x,y\rangle|}{\lVert y\rVert^2}\frac{\lVert y\rVert}{\lVert x\rVert}
  =\frac{|\langle x,y\rangle|}{\lVert x\rVert\lVert y\rVert}.
\]
Omitting the absolute value on the real number~$\langle x,y\rangle$ in the
numerator provides the correct signs for the different quadrants (when~$\theta$
is not between~$0$ and~$90$ degrees).
\medskip

\textbf{Definition.} Let $(V,\ips{\ }{\ })$ be an inner product space
  over~$F=\R$, and let~$x,y$ be nonzero elements of~$V$.  The \emph{angle}~$\theta$ between~$x$ and~$y$ is 
  \[
   \theta=\cos^{-1}\left( \frac{\ips{x}{y}}{\lVert x\rVert\lVert
   y\rVert}\right),
  \]
  and thus,
  \[
    \ips{x}{y}=\lVert x\rVert\lVert y\rVert\cos(\theta).
  \]
\Needspace{3\baselineskip}
\textbf{Remarks.}
\begin{itemize}
  \item Cauchy-Schwarz says~$|\ips{x}{y}\leq\lVert x\rVert\lVert y\rVert$.
    Therefore,
    \[
      -1\leq \frac{\ips{x}{y}}{\lVert x\rVert\lVert y\rVert}\leq 1.
    \]
    So the inverse cosine in the definition of the angle always makes sense.
  \item  In the definition of the angle, it might make more sense conceptually to
    write
\[
  \cos(\theta)=\bigg\langle\frac{x}{\lVert x\rVert},\frac{y}{\lVert
    y\rVert}\bigg\rangle.
\]
In other words, the cosine of the angle between~$x$ and~$y$ is the inner product
of their directions where the {\em direction} of a vector~$w$ is taken to be the
scalar multiple of~$w$ with unit length,~$w/\lVert w\rVert$.
\end{itemize}
\end{document}  
