\subsection{Propositional logic}\label{subsec:propositional_logic}

\begin{remark}\label{rem:propositional_language_is_alphabet}
  The \hyperref[def:propositional_language]{language of propositional logic} is, strictly speaking, an \hyperref[def:formal_language/alphabet]{alphabet} rather than a \hyperref[def:formal_language/language]{language}. Nonetheless, this is the established terminology.
\end{remark}

\begin{definition}\label{def:propositional_language}\mcite[sec. 7.2]{OpenLogicFull}
  The \term{language of propositional logic} consists of:

  \begin{thmenum}
    \thmitem{def:propositional_language/prop} A nonempty, \hyperref[def:set_countability/at_most_countable]{at most countable} set \( \boldop{Prop} \) of \term{propositional variables}. Technically, we can have different languages with different variables, but it is safe to assume that there is only one single language of propositional language.

    \thmitem{def:propositional_language/constants} Two \term{propositional constants} (also known as \term{truth values}):
    \begin{thmenum}
      \thmitem{def:propositional_language/constants/verum} The \term{verum} \( \top \).
      \thmitem{def:propositional_language/constants/falsum} The \term{falsum} \( \bot \).
    \end{thmenum}

    \thmitem{def:propositional_language/negation} \term{Negation} \( \neg \).
    \thmitem{def:propositional_language/connectives} The set \( \Sigma \) of \term{propositional connectives}, namely
    \begin{thmenum}
      \thmitem{def:propositional_language/connectives/conjunction} \term{Conjunction} \( \wedge \) (also known as \hyperref[def:standard_boolean_operators]{\term{and}} and \hyperref[def:semilattice/meet]{\term{meet}}).
      \thmitem{def:propositional_language/connectives/disjunction} \term{Disjunction} \( \vee \) (also known as \hyperref[def:standard_boolean_operators]{\term{or}} and \hyperref[def:semilattice/join]{\term{join}}).
      \thmitem{def:propositional_language/connectives/conditional} \term{Conditional} \( \rightarrow \) (also known as \term{if\ldots then} and \hyperref[def:material_implication]{\term{material implication}}).
      \thmitem{def:propositional_language/connectives/biconditional} \term{Biconditional} \( \leftrightarrow \) (also known as \term{iff} and \term{material equivalence}).
    \end{thmenum}

     Note that \enquote{conditional} and \enquote{biconditional} are nouns in this context.

    \thmitem{def:propositional_language/parentheses} Parentheses \( ( \) and \( ) \) for defining the order of operations unambiguously (see \fullref{rem:propositional_formula_parentheses}).
  \end{thmenum}

  \Fullref{rem:smaller_propositional_language} shows we can actually utilize a smaller propositional language without losing any of its semantics.
\end{definition}

\begin{definition}\label{def:propositional_syntax}
  The following related definitions constitute what is called the \term{syntax of propositional logic}.

  \begin{thmenum}
    \thmitem{def:propositional_syntax/grammar_schema} Consider the following \hyperref[ex:natural_number_arithmetic_grammar/backus_naur_form]{grammar schema}:
    \begin{bnf*}
      \bnfprod{variable}   {P \in \boldop{Prop}} \\
      \bnfprod{connective} {\circ \in \Sigma} \\
      \bnfprod{formula}    {\bnfpn{variable} \bnfor} \\
      \bnfmore             {\bnfts{\( \top \)} \bnfor \bnfts{\( \bot \)} \bnfor} \\
      \bnfmore             {\bnfts{\( \neg \)} \bnfpn{formula} \bnfor} \\
      \bnfmore             {\bnfts{(} \bnfsp \bnfpn{formula} \bnfsp \bnfpn{connective} \bnfsp \bnfpn{formula} \bnfsp \bnfts{)}}
    \end{bnf*}

    Note that \( \boldop{Prop} \) may be infinite, in which case the grammars may have infinitely many rules. If needed, we can circumvent this by introducing an appropriate naming convention for variables, for example by allowing arbitrary strings of alphanumeric characters for variable names.

    For the sake of readability, we will be using the conventions in \fullref{rem:propositional_formula_parentheses} regarding parentheses.

    \thmitem{def:propositional_syntax/formula} The set \( \boldop{Form} \) of \term{propositional formulas} is the language \hyperref[def:grammar_derivation/grammar_language]{generated} by this grammar schema with \( \bnfpn{formula} \) as a starting rule. Propositional formulas are also called sentenced unlike in first-order logic where only specific formulas are called sentences --- see \fullref{def:first_order_syntax/ground_formula}.

    The grammar of propositional formulas is unambiguous as shown by \fullref{thm:propositional_formulas_are_unambiguous}, which makes it possible to perform proofs via \fullref{thm:structural_induction_on_unambiguous_grammars}.

    \thmitem{def:propositional_syntax/subformula} If \( \varphi \) and \( \psi \) are formulas and \( \psi \) is a \hyperref[def:formal_language/subword]{subword} of \( \varphi \), we say that \( \psi \) is a \term{subformula} of \( \varphi \).

    \thmitem{def:propositional_syntax/variables} For each formula \( \varphi \), we inductively define its \term{variables} to be elements of the set
    \begin{equation}\label{eq:def:propositional_syntax/varables}
      \boldop{Var}(\varphi) \coloneqq \begin{cases}
        \varnothing,                                  &\varphi \in \set{ \top, \bot } \\
        \set{ P },                                    &\varphi = P \in \boldop{Prop} \\
        \boldop{Var}(\psi),                           &\varphi = \neg \psi \\
        \boldop{Var}(\psi) \cup \boldop{Var}(\theta), &\varphi = \psi \bincirc \theta, \bincirc \in \Sigma.
      \end{cases}
    \end{equation}

    Note that \( \boldop{Var}(\varphi) \) can naturally be totally ordered by the position of the first occurrence of a variable.
  \end{thmenum}
\end{definition}

\begin{proposition}\label{thm:propositional_formulas_are_unambiguous}
  The grammar of \hyperref[def:propositional_syntax/formula]{propositional formulas} is \hyperref[def:grammar_derivation/unambiguous]{unambiguous}.
\end{proposition}
\begin{proof}
  The proof is analogous to \fullref{ex:natural_number_arithmetic_grammar/derivation}.
\end{proof}

\begin{remark}\label{rem:propositional_formula_parentheses}
  We use the following two \enquote{abuse-of-notation} conventions regarding parentheses:
  \begin{thmenum}
    \thmitem{rem:propositional_formula_parentheses/outermost} We may skip the outermost parentheses in formulas with top-level \hyperref[def:propositional_language/connectives]{connectives}, e.g. we may write \( P \wedge Q \) rather than \( (P \wedge Q) \).

    \thmitem{rem:propositional_formula_parentheses/associative} Because of the associativity of \( \wedge \) and \( \vee \) (see \fullref{def:propositional_formula_induced_function} and \fullref{def:standard_boolean_operators}), we may skip the parentheses in chains like
    \begin{equation*}
      ( \ldots ((P_1 \wedge P_2) \wedge P_3) \wedge \ldots \wedge P_{n-1} ) \wedge P_n.
    \end{equation*}
    and instead write
    \begin{equation*}
      P_1 \wedge P_2 \wedge \ldots \wedge P_{n-1} \wedge P_n.
    \end{equation*}

    \thmitem{rem:first_order_formula_parentheses/additional} Although not formally necessary, for the sake of readability we may choose to add parentheses around certain formulas like
    \begin{equation*}
      \neg P \vee \neg Q.
    \end{equation*}
    and instead write
    \begin{equation*}
      (\neg P) \vee \neg Q.
    \end{equation*}

    This latter convention is more useful for quantifiers in \hyperref[def:first_order_syntax/formula]{first-order formulas}.
  \end{thmenum}

  These are only notations shortcuts in the \hyperref[rem:metalogic]{metalanguage} and the formulas themselves (as abstract mathematical objects) are still assumed to contain parentheses that help them avoid syntactic ambiguity (see \fullref{thm:propositional_formulas_are_unambiguous}).
\end{remark}

\begin{definition}\label{def:material_implication}
  Theorems in mathematics usually have the form \( P \rightarrow Q \). Formulas of this form are called \term{material implications} in order to distinguish them from logical implication, which relates to the metatheoretic concept of \hyperref[def:propositional_semantics/entailment]{entailment} (see \cite{MathSE:material_vs_logical_implication}). Note that the term \enquote{material implication} sometimes also refers to the \hyperref[def:propositional_language/connectives/conditional]{conditional connective \( \rightarrow \)} itself.

  We introduce terminology that is conventionally used when dealing with theorems.

  \begin{thmenum}
    \thmitem{def:material_implication/sufficient_condition} \( P \) is a \term{sufficient condition} for \( Q \).

    \thmitem{def:material_implication/necessary_condition} \( Q \) is a \term{necessary condition} for \( P \).

    \thmitem{def:material_implication/antecedent} \( P \) the \term{antecedent} of \( \varphi \).

    \thmitem{def:material_implication/consequent} \( Q \) the \term{consequent} of \( \varphi \).

    \thmitem{def:material_implication/inverse} The formula \( \neg P \rightarrow \neg Q \) is the \term[bg=противоположна,ru=противоположная]{inverse} of \( \varphi \).

    \thmitem{def:material_implication/converse} The formula \( Q \rightarrow P \) is the \term[bg=обратна,ru=обратная]{converse} of \( \varphi \).

    \thmitem{def:material_implication/contrapositive} The formula \( \neg Q \rightarrow \neg P \) is the \term{contrapositive} of \( \varphi \). In classical logic, it is \hyperref[def:propositional_semantics/equivalence]{equivalent} to the original formula due to \fullref{thm:boolean_equivalences/contrapositive}.
  \end{thmenum}
\end{definition}

\begin{definition}\label{def:propositional_valuation}
  We define \term[bg=оценка,ru=оценка]{valuations} for propositional formulas. It is possible to define different valuations, so in case of doubt, we will refer to the one defined here as the \term{classical valuation} giving \term{classical semantics}.

  This valuation implicitly depends on the \hyperref[def:boolean_algebra]{Boolean algebra} fixed in \fullref{def:boolean_function}. When dealing with Heyting semantics (see \fullref{def:propositional_heyting_algebra_semantics}), we use more general Heyting algebras where not only the top and bottom, but also other values are utilized.

  \begin{thmenum}
    \thmitem{def:propositional_valuation/interpretation} A \term{propositional interpretation} is a function with signature \( I: \boldop{Prop} \to \set{ T, F } \). See \fullref{def:boolean_value} for remarks regarding the \hyperref[def:boolean_algebra]{Boolean algebra} \( \set{ T, F } \) and the \fullref{def:standard_boolean_operators} for a list of some standard Boolean operators.

    \thmitem{def:propositional_valuation/formula_valuation} Given an interpretation \( I \), we define the \term{valuation} of a formula \( \varphi \) inductively as
    \begin{equation}\label{eq:def:propositional_valuation/formula_interpretation}
      \varphi\Bracks{I} \coloneqq \begin{cases}
        T,                                         &\varphi = \top \\
        F,                                         &\varphi = \bot \\
        I(P),                                      &\varphi = P \in \boldop{Prop} \\
        \overline{\psi\Bracks{I}},                 &\varphi = \neg \psi \\
        \psi_1\Bracks{I} \bincirc \psi_2\Bracks{I} &\varphi = \psi_1 \bincirc \psi_2, \bincirc \in \Sigma,
      \end{cases}
    \end{equation}
  \end{thmenum}
  where \( \bincirc \) on the left denotes the \hyperref[def:standard_boolean_operators]{Boolean operator} corresponding to the connective \( \bincirc \) on the right.
\end{definition}

\begin{remark}\label{rem:propositional_formula_valuation_without_variable_assignment}
  If we know that \( \boldop{Var}(\varphi) \subseteq \{ P_1, \ldots, P_n \} \), it follows that the \hyperref[def:first_order_valuation/formula_valuation]{valuation} \( \varphi\Bracks{I} \) only depends on the particular values \( I(P_1), \ldots, I(P_n) \) of \( I \).

  Let \( x_1, \ldots, x_n \in \set{ F, T } \) and let \( I \) be such that \( I(P_k) = x_k \) for \( k = 1, \ldots, n \). We introduce the notation
  \begin{equation}\label{eq:rem:propositional_formula_valuation_without_variable_assignment/short_semantic}
    \varphi\Bracks{x_1, \ldots, x_n}
  \end{equation}
  for \( \varphi\Bracks{I} \) because the rest of the interpretation \( I \) plays no role here. We may also use
  \begin{equation}\label{eq:rem:propositional_formula_valuation_without_variable_assignment/short_syntactic}
    \varphi[\psi_1, \ldots, \psi_n]
  \end{equation}
  to denote \hyperref[def:propositional_substitution]{substitution}.

  When using this notation, we implicitly assume that \( \boldop{Var}(\varphi) \subseteq \set{ P_1, \ldots, P_n } \).
\end{remark}

\begin{definition}\label{def:propositional_formula_induced_function}
  Let \( \varphi \) be a propositional formula and let \( \boldop{Var}(\varphi) = \set{ P_1, \ldots, P_n } \) be an ordering of the free variables of \( \varphi \). We define the \hyperref[def:boolean_function]{Boolean function}
  \begin{equation}\label{eq:def:propositional_formula_induced_function}
    \begin{split}
      &\fun_\varphi: \set{ T, F }^n \to \set{ T, F } \\
      &\fun_\varphi(x_1, \ldots, x_n) \coloneqq \varphi\Bracks{x_1, \ldots, x_n}.
    \end{split}
  \end{equation}
\end{definition}

\begin{definition}\label{def:propositional_semantics}
  We now define \term{semantical} properties of propositional formulas. Because of the connection with \hyperref[def:boolean_function]{Boolean functions} given in \fullref{def:propositional_formula_induced_function}, we also formulate some of the properties using Boolean functions.

  \begin{thmenum}
    \thmitem{def:propositional_semantics/satisfiability}\mcite[def. 7.14]{OpenLogicFull} Given an interpretation \( I \) and a set \( \Gamma \) of formulas, we say that \( I \) \term{satisfies} \( \Gamma \) if, for every formula \( \varphi \in \Gamma \) we have \( \varphi\Bracks{I} = T \).

    We also say that \( I \) is a \term{model} of \( \Gamma \) and write \( I \vDash \Gamma \).

    If \( \Gamma = \set{ \gamma_1, \ldots, \gamma_n } \) is a finite ordered set, we use the shorthand \( I \vDash \gamma_1, \ldots, \gamma_n \) rather than \( I \vDash \set{ \gamma_1, \ldots, \gamma_n } \). In particular, if \( \Gamma = \set{ \varphi } \) we write \( I \vDash \varphi \).

    Note that every interpretation vacuously satisfies the empty set \( \Gamma = \varnothing \) of formulas.

    We say that \( \Gamma \) is \term{satisfiable} if there exists a model for \( \Gamma \).

    \thmitem{def:propositional_semantics/entailment} We say that the set of formulas \( \Gamma \) \term{entails} the set of formulas \( \Delta \) and write \( \Gamma \vDash \Delta \) if either of the following hold:
    \begin{itemize}
      \thmitem{def:propositional_semantics/entailment/direct} Every model of \( \Gamma \) is also a model of \( \Delta \).
      \thmitem{def:propositional_semantics/entailment/functional} The following \hyperref[thm:def:function/properties/preimage]{preimage} inclusion holds:
      \begin{equation*}
        \bigcap_{\varphi \in \Gamma} \fun_\varphi^{-1}(T) \subseteq \bigcap_{\psi \in \Delta} \fun_\psi^{-1}(T).
      \end{equation*}
    \end{itemize}

    \thmitem{def:propositional_semantics/tautology} The formula \( \varphi \) is a (semantic) \term{tautology} if either:
    \begin{itemize}
      \thmitem{def:propositional_semantics/tautology/interpretations} Every interpretation satisfies \( \varphi \).
      \thmitem{def:propositional_semantics/tautology/entailment} The empty set \( \Gamma = \varnothing \) of formulas entails \( \varphi \), i.e. \( \vDash \varphi \).
      \thmitem{def:propositional_semantics/tautology/functional} The function \( \fun_\varphi \) is canonically true.
    \end{itemize}

    We also say that \( \varphi \) is \term{valid}.

    \thmitem{def:propositional_semantics/contradiction} Dually, \( \varphi \) is a (semantic) \term{contradiction} if either:
    \begin{itemize}
      \thmitem{def:propositional_semantics/contradiction/interpretations} No interpretation satisfies \( \varphi \).
      \thmitem{def:propositional_semantics/contradiction/entailment} The formula \( \varphi \) entails \( \bot \), i.e. \( \varphi \vDash \bot \).
      \thmitem{def:propositional_semantics/contradiction/functional} The function \( \fun_\varphi \) is canonically false.
    \end{itemize}

    \thmitem{def:propositional_semantics/equivalence} We say that \( \varphi \) and \( \psi \) are \term{semantically equivalent} and write \( \varphi \gleichstark \psi \) if either:
    \begin{itemize}
      \thmitem{def:propositional_semantics/equivalence/interpretations} We have \( \varphi\Bracks{I} = \psi\Bracks{I} \) for every interpretation \( I \).
      \thmitem{def:propositional_semantics/equivalence/entailment} Both \( \varphi \vDash \psi \) and \( \psi \vDash \varphi \).
    \end{itemize}

    \thmitem{def:propositional_semantics/equisatisfiability} A weaker notion than that of semantic equivalence is that of \term{equisatisfiability}. We say that the families \( \Gamma \) and \( \Delta \) are equisatisfiable if the following holds: \enquote{\( \Gamma \) is satisfiable if and only if \( \Delta \) is satisfiable}. For single-formula families \( \Gamma = \set{ \varphi } \) and \( \Delta = \set{ \psi } \), the following are equivalent conditions for equisatisfiability:
    \begin{itemize}
      \thmitem{def:propositional_semantics/equisatisfiability/interpretations} There exist interpretations \( I \) and \( J \) such that \( \varphi\Bracks{I} = \psi\Bracks{J} \).
      \thmitem{def:propositional_semantics/equisatisfiability/functional} We have \( \fun_\varphi = \fun_\psi \) for the induced functions.
    \end{itemize}

    A trivial example of equisatisfiable, but not equivalent formulas are \( \varphi = P \) and \( \psi = Q \) for \( P \neq Q \).
  \end{thmenum}
\end{definition}

\begin{theorem}\label{thm:lindenmaum_tarski_algebra_of_full_propositional_logic}
  We give an explicit connection between \hyperref[def:propositional_syntax/formula]{propositional formulas} and \hyperref[def:boolean_function]{Boolean functions}.

  \begin{thmenum}
    \thmitem{thm:lindenmaum_tarski_algebra_of_full_propositional_logic/equivalence_classes} The \hyperref[def:propositional_semantics/equivalence]{semantic equivalence} \( \gleichstark \) is an equivalence relation on the set \( \boldop{Form} \) of all propositional formulas.

    \thmitem{thm:lindenmaum_tarski_algebra_of_full_propositional_logic/bijection} The \hyperref[def:lindenbaum_tarski_algebra]{Lindenbaum-Tarski algebra}  \( \boldop{Form} / {{}\gleichstark} \) of all propositional formulas with respect to semantic equivalence is bijective with the set of all \hyperref[def:boolean_function]{Boolean functions} of arbitrary arity.

    Both are provably Boolean algebras, but with very different proofs --- the Lindenbaum-Tarski algebra is Boolean due to the purely syntactic \fullref{thm:intuitionistic_lindenbaum_tarski_algebra} and the set of all Boolean functions is a Boolean algebra due to the semantic \fullref{thm:functions_over_model_form_model}. This is another demonstration of \fullref{thm:classical_propositional_logic_is_sound_and_complete}.

    See \fullref{rem:thm:intuitionistic_lindenbaum_tarski_algebra/syntactic_proof}.
  \end{thmenum}
\end{theorem}
\begin{proof}
  \SubProofOf{thm:lindenmaum_tarski_algebra_of_full_propositional_logic/equivalence_classes} Follows from the equivalences in \fullref{def:equivalence_relation}.

  \SubProofOf{thm:lindenmaum_tarski_algebra_of_full_propositional_logic/bijection} Follows from the equivalences in \fullref{def:propositional_semantics/equivalence}.
\end{proof}

\begin{proposition}\label{thm:boolean_equivalences}
  The following (and many more) are called \term{Boolean equivalences} because they are actually statements about our choice of \hyperref[def:standard_boolean_operators]{standard Boolean operators}. They are formulated here because the framework of propositional logic is more convenient for stating the equivalences. Note that most of these equivalences fail in \hyperref[def:intuitionistic_propositional_deductive_systems]{intuitionistic logic}.

  For arbitrary propositional formulas \( \varphi \) and \( \psi \), the following semantic equivalences hold:
  \begin{thmenum}
    \thmitem{thm:boolean_equivalences/negation_bottom} \hyperref[def:propositional_language/negation]{Negation} can be expressed via the \hyperref[def:propositional_language/constants/falsum]{falsum}:
    \begin{equation}\label{eq:thm:boolean_equivalences/negation_bottom}
      \begin{split}
        \mathllap{\neg \varphi} &\gleichstark \mathrlap{\varphi \rightarrow \bot}.
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/double_negation} \hyperref[def:propositional_language/negation]{Negation} is an \hyperref[def:set_with_involution]{involution}:
    \begin{equation}\label{eq:thm:boolean_equivalences/double_negation}
      \begin{split}
        \mathllap{\neg \neg \varphi} &\gleichstark \mathrlap{\varphi}.
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/contrapositive} A \hyperref[def:material_implication]{material implication} is equivalent to its \hyperref[def:material_implication/contrapositive]{contrapositive}:
    \begin{equation}\label{eq:thm:boolean_equivalences/contrapositive}
      \begin{split}
        \mathllap{\varphi \rightarrow \psi} &\gleichstark \mathrlap{\neg \psi \rightarrow \neg \varphi.}
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/conditional_as_disjunction} A \hyperref[def:propositional_language/connectives/conditional]{conditional} is a \hyperref[def:propositional_language/connectives/disjunction]{disjunction} with the \hyperref[def:material_implication/antecedent]{antecedent} negated:
    \begin{equation}\label{eq:thm:boolean_equivalences/conditional_as_disjunction}
      \begin{split}
        \mathllap{\varphi \rightarrow \psi} &\gleichstark \mathrlap{ \neg \varphi \vee \psi. }
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/biconditional_via_conditionals} A \hyperref[def:propositional_language/connectives/biconditional]{biconditional} is a \hyperref[def:propositional_language/connectives/conjunction]{conjunction} of \hyperref[def:propositional_language/connectives]{conditionals}:
    \begin{equation}\label{eq:thm:boolean_equivalences/biconditional_via_conditionals}
      \begin{split}
        \mathllap{\varphi \leftrightarrow \psi} &\gleichstark \mathrlap{(\varphi \rightarrow \psi) \wedge (\psi \rightarrow \varphi).}
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/biconditional_as_conjunction} The \hyperref[def:propositional_language/connectives/biconditional]{biconditional} is a \hyperref[def:propositional_language/connectives/disjunction]{conjunction} of \hyperref[def:propositional_language/connectives/conjunction]{disjunctions}:
    \begin{equation}\label{eq:thm:boolean_equivalences/biconditional_as_conjunction}
      \begin{split}
        \mathllap{\varphi \leftrightarrow \psi} &\gleichstark \mathrlap{(\neg \varphi \vee \psi) \wedge (\neg \varphi \vee \psi).}
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/biconditional_as_disjunction} The \hyperref[def:propositional_language/connectives/biconditional]{biconditional} is a \hyperref[def:propositional_language/connectives/disjunction]{disjunction} of \hyperref[def:propositional_language/connectives/conjunction]{conjunctions}:
    \begin{equation}\label{eq:thm:boolean_equivalences/biconditional_as_disjunction}
      \begin{split}
        \mathllap{\varphi \leftrightarrow \psi} &\gleichstark \mathrlap{(\varphi \wedge \psi) \vee (\neg \varphi \wedge \neg \psi).}
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/biconditional_member_negation} A \hyperref[def:propositional_language/connectives/biconditional]{biconditional} is equivalent its termwise negation:
    \begin{equation}\label{eq:thm:boolean_equivalences/biconditional_member_negation}
      \begin{split}
        \mathllap{\neg \varphi \leftrightarrow \neg \psi} &\gleichstark \mathrlap{\varphi \leftrightarrow \psi.}
      \end{split}
    \end{equation}

    \thmitem{thm:boolean_equivalences/biconditional_negation} A negation of a \hyperref[def:propositional_language/connectives/biconditional]{biconditional} is again a biconditional with one of the terms negated:
    \begin{equation}\label{eq:thm:boolean_equivalences/biconditional_negation}
      \begin{split}
        \mathllap{\neg \parens{\varphi \leftrightarrow \psi}}
        &\gleichstark
        \mathrlap{\neg \varphi \leftrightarrow \psi \gleichstark}
        \\ &\gleichstark
        \mathrlap{\varphi \leftrightarrow \neg \psi.}
      \end{split}
    \end{equation}
  \end{thmenum}
\end{proposition}
\begin{proof}
  The proofs follow directly from the table in \fullref{def:standard_boolean_operators}.
\end{proof}

\begin{definition}\label{def:propositional_substitution}
  We sometimes want to substitute a propositional variable with another variable or even with a formula. This is akin to applying a \hyperref[def:boolean_function]{Boolean function} like \( x \vee y \) to different variables (e.g. to obtain \( x \vee x \)) or even concrete values (e.g. \( F \vee T \)), except that it is done on a purely syntactic level without involving any semantics involved.

  It does not pose any technical difficulty to extend this definition beyond replacing a variable like it is usually done (e.g. \cite[def. 7.8]{OpenLogicFull}). Not only that, we can then use this mechanism to define complicated rewriting rules as in \fullref{alg:conjunctive_normal_form_reduction} and have semantic equivalence automatically follow from \fullref{thm:propositional_substitution_equivalence}.

  \begin{thmenum}
    \thmitem{def:propositional_substitution/single} We define the \term{substitution} of the propositional formula \( \theta \) with \( \chi \) in \( \varphi \) as
    \begin{equation}\label{eq:def:propositional_substitution/single}
      \varphi[\theta \mapsto \chi] \coloneqq \begin{cases}
        \chi,                                                             &\varphi = \theta \\
        \varphi,                                                          &\varphi \neq \theta \T{and} \varphi \in \set{ \top, \bot } \cup \boldop{Prop} \\
        \neg \psi[\theta \mapsto \chi],                                   &\varphi \neq \theta \T{and} \varphi = \neg \psi \\
        \psi_1[\theta \mapsto \chi] \bincirc \psi_2[\theta \mapsto \chi], &\varphi \neq \theta \T{and} \varphi = \psi_1 \bincirc \psi_2, \circ \in \Sigma.
      \end{cases}
    \end{equation}

    Note that it is not strictly necessary for \( \theta \) to be a subformula of \( \varphi \).

    In the case where \( \theta \) is a single variable, if \( P \in \boldop{Var}(\varphi) \), then \( \varphi[P \mapsto \chi] \) is said to be an \term{instance} of \( \varphi \).

    \thmitem{def:propositional_substitution/simultaneous} We will now define \term{simultaneous substitution} of \( \theta_1, \ldots, \theta_n \) with \( \chi_1, \ldots, \chi_n \). We wish to avoid the case where \( \theta_k \) is a subformula of \( \chi_{k-1} \) and it accidentally gets replaced during \( \varphi[\theta_{k-1} \mapsto \chi_{k-1}][\theta_k \mapsto \chi_k] \).

    Define
    \begin{equation*}
      \cat{Bound} \coloneqq \boldop{Var}(\chi_1) \cup \ldots \cup \boldop{Var}(\chi_n).
    \end{equation*}
    and, for each variable \( P_k \) in \( \cat{Bound} \), pick a variable \( Q_k \) from \( \boldop{Prop} \setminus \boldop{Bound} \) (we implicitly assume the existence of enough variables in \( \boldop{Prop} \)). Let \( m \) be the \hyperref[def:cardinal]{cardinality} of \( \boldop{Bound} \). The simultaneous substitution can now be defined as
    \begin{align*}
      \varphi[\theta_1 \mapsto \chi_1, \ldots, \theta_n \mapsto \chi_n] \coloneqq \varphi
      [\theta_1 \mapsto \chi_1[P_1 \mapsto Q_1, \ldots, P_m \mapsto Q_m]] \\
      \vdots \hspace{3cm} \\
      [\theta_n \mapsto \chi_n[P_1 \mapsto Q_1, \ldots, P_m \mapsto Q_m]] \\
      [Q_1 \mapsto P_1, \ldots, Q_m \mapsto P_m].
    \end{align*}
  \end{thmenum}
\end{definition}

\begin{proposition}\label{thm:propositional_substitution_equivalence}
  If \( \theta \) is a subformula of \( \varphi \) and if \( \theta \gleichstark \chi \), then
  \begin{equation}\label{eq:thm:propositional_substitution_equivalence}
    \varphi[\theta \mapsto \chi] \gleichstark \varphi.
  \end{equation}

  By induction, this also holds for \hyperref[def:propositional_substitution/simultaneous]{simultaneous substitution}.
\end{proposition}
\begin{proof}
  We use structural induction on \( \varphi \):

  \begin{itemize}
    \item If \( \varphi = \theta \), then \( \varphi[\theta \mapsto \chi] = \chi \) and, by definition,
    \begin{equation*}
      \varphi = \theta \gleichstark \chi = \varphi[\theta \mapsto \chi].
    \end{equation*}

    \item If \( \varphi \neq \theta \) and \( \varphi \in \set{ \top, \bot } \cup \boldop{Prop} \), then \( \varphi[\theta \mapsto \chi] = \varphi \) and \eqref{eq:thm:propositional_substitution_equivalence} again holds trivially.

    \item If \( \varphi \neq \theta \) and \( \varphi = \neg \chi \) and if the inductive hypothesis holds for \( \chi \), then \( \varphi[\theta \mapsto \chi] = \neg \psi[\theta \mapsto \chi] \). For any interpretation \( I \),
    \begin{equation*}
      \parens[\Big]{ \varphi[\theta \mapsto \chi] }\Bracks{I}
      =
      \overline{\parens[\Big]{ \psi[\theta \mapsto \chi] }\Bracks{I}}
      \reloset {\T{ind.}} =
      \overline{\psi\Bracks{I}}
      =
      \varphi\Bracks{I}.
    \end{equation*}

    Therefore, \eqref{eq:thm:propositional_substitution_equivalence} holds in this case.

    \item If \( \varphi \neq \theta \) and \( \varphi = \psi_1 \bincirc \psi_2, \bincirc \in \Sigma \) and if the inductive hypothesis holds for both \( \psi_1 \) and \( \psi_2 \), then for any interpretation \( I \),
    \begin{equation*}
      \parens[\Big]{ \varphi[\theta \mapsto \chi] }\Bracks{I}
      =
      \parens[\Big]{ \psi_1[\theta \mapsto \chi] }\Bracks{I} \bincirc \parens[\Big]{ \psi_2[\theta \mapsto \chi] }\Bracks{I}
      \reloset {\T{ind.}} =
      \psi_1\Bracks{I} \bincirc \psi_2\Bracks{I}
      =
      \varphi\Bracks{I}.
    \end{equation*}

    Therefore, \eqref{eq:thm:propositional_substitution_equivalence} holds in this case also.
  \end{itemize}

  We have verified that \eqref{eq:thm:propositional_substitution_equivalence} holds in all cases.
\end{proof}

\begin{remark}\label{rem:smaller_propositional_language}
  For \hyperref[def:propositional_semantics]{semantical} concepts, it is immaterial which element of an equivalence class we consider. \hyperref[def:boolean_closure]{Complete sets of Boolean operations} allow us to represent each formula using a strict subset of the \hyperref[def:propositional_language/constants]{propositional constants}, \hyperref[def:propositional_language/negation]{negation} and \hyperref[def:propositional_language/connectives]{connectives}. \Fullref{ex:posts_completeness_theorem} shows some concrete commonly used complete sets of Boolean operations. This is also the motivation for studying \hyperref[def:lindenbaum_tarski_algebra]{Lindenbaum-Tarski algebras}.

  This is useful in
  \begin{itemize}
    \item Reduction to normal forms such as the \hyperref[def:conjunctive_disjunctive_normal_form]{conjunctive normal form} in \fullref{alg:conjunctive_normal_form_reduction}.

    \item \hyperref[def:propositional_semantics/satisfiability]{Satisfiability} proofs that rely on \hyperref[rem:structural_recursion_and_induction]{structural induction} because it allows us to consider less cases in the induction.

    \item Having fewer rules in \hyperref[alg:conjunctive_normal_form_reduction]{deductive systems}. For example, we may choose to add \eqref{eq:thm:minimal_propositional_negation_laws/pierce} to the axioms of the \hyperref[def:positive_implicational_deductive_system]{positive implicational derivation system} and due to \fullref{thm:minimal_propositional_negation_laws} this derivation system would be able to emulate the \hyperref[def:classical_propositional_deductive_systems]{classical derivation system}.
  \end{itemize}
\end{remark}

\begin{definition}\label{def:conjunctive_disjunctive_normal_form}
  We will now introduce the conjunctive and disjunctive normal forms.

  \begin{thmenum}
    \thmitem{def:conjunctive_disjunctive_normal_form/literal} A \term{literal} is either a propositional variable \( L = P \) or a negation \( L = \neg P \) of a propositional variable. These are called \term{positive} and \term{negative} literals, correspondingly.

    \thmitem{def:conjunctive_disjunctive_normal_form/normal_form} A propositional formula \( \varphi \) is in \term{conjunctive normal form} (resp. \term{disjunctive normal form}) if \( \varphi \) is a finite conjunction of disjunctions (resp. finite disjunction of conjunctions) of literals. That is, if \( \varphi \) is in conjunctive normal form, it has the form
    \begin{equation*}
      (L_{1,1} \vee \ldots \vee L_{1,n_1}) \wedge \cdots \wedge (L_{k,1} \vee \ldots \vee L_{k,n_k}).
    \end{equation*}

    \thmitem{def:conjunctive_disjunctive_normal_form/conjunct_disjunct} A \term{disjunct} (resp. a \term{conjunct}) is a set of literals, the difference between the two being the context in which they are used. To each formula in conjunctive normal form there corresponds a set of disjuncts and to each formula in disjunctive normal form there corresponds a set of conjuncts.
  \end{thmenum}
\end{definition}

\begin{algorithm}\label{alg:conjunctive_normal_form_reduction}
  Let \( \varphi \) be any formula. We explicitly derive a formula in conjunctive normal form that is \hyperref[def:propositional_semantics/equivalence]{semantically equivalent} to \( \varphi \). In a software implementation, we can easily construct an efficient recursive procedure based on the following steps.

  \begin{thmenum}
    \thmitem{alg:conjunctive_normal_form_reduction/constants} Pick any variable \( P \) and substitute
    \begin{align*}
      \top \T{with} P \vee \neg P, && \bot \T{with} P \wedge \neg P
    \end{align*}
    to get rid of the \hyperref[def:propositional_language/constants]{propositional constants}.

    \thmitem{alg:conjunctive_normal_form_reduction/iff} For any subformulas \( \psi \) and \( \theta \) of \( \varphi \), perform the substitution
    \begin{equation*}
      \psi \leftrightarrow \theta \T{with} (\psi \rightarrow \theta) \wedge (\theta \rightarrow \psi)
    \end{equation*}
    to get rid of \hyperref[def:propositional_language/connectives/biconditional]{biconditional connectives}. Semantic equivalence with \( \varphi \) is then justified by \fullref{thm:boolean_equivalences/biconditional_via_conditionals}.

    \thmitem{alg:conjunctive_normal_form_reduction/implies} For any subformulas \( \psi \) and \( \theta \) of \( \varphi \), perform the substitution
    \begin{equation*}
      \psi \rightarrow \theta \T{with} \neg \psi \vee \theta.
    \end{equation*}
    to get rid of \hyperref[def:propositional_language/connectives/conditional]{conditional connectives}. Equivalence with \( \varphi \) is justified by \fullref{thm:boolean_equivalences/conditional_as_disjunction}.

    \thmitem{alg:conjunctive_normal_form_reduction/de_morgan} For any subformulas \( \psi \) and \( \theta \) of \( \varphi \), use \fullref{thm:de_morgans_laws} to justify the substitution
    \begin{align*}
      \neg(\psi \vee \theta) \T{with} \neg \psi \wedge \neg \theta
      &&
      \neg(\psi \wedge \theta) \T{with} \neg \psi \vee \neg \theta.
    \end{align*}

    In order to ensure that \hyperref[def:propositional_language/negation]{negation} is only present before propositional variables, repeat \ref{alg:conjunctive_normal_form_reduction/de_morgan} until we reach a fixed point, i.e. until nothing is substituted anymore.

    \thmitem{alg:conjunctive_normal_form_reduction/double_negation} For any variable \( P \) of \( \varphi \), use \fullref{eq:thm:boolean_equivalences/double_negation} to justify the substitution
    \begin{equation*}
      \neg \neg P \T{with} P.
    \end{equation*}

    \thmitem{alg:conjunctive_normal_form_reduction/distributivity} Finally, for any subformulas \( \psi \), \( \theta \) and \( \chi \) of \( \varphi \), use \hyperref[eq:def:semilattice/distributive_lattice/finite/join_over_meet]{distributivity} of \( \vee \) over \( \wedge \) to justify the substitution
    \begin{equation*}
      \psi \vee (\theta \wedge \chi) \T{with} (\psi \vee \theta) \wedge (\theta \vee \chi).
    \end{equation*}

    In order to ensure that conjunction is always one level higher than disjunction, repeat \ref{alg:conjunctive_normal_form_reduction/distributivity} until we reach a fixed point.
  \end{thmenum}

  The resulting formula is in conjunctive normal form. As a consequence of \fullref{thm:propositional_substitution_equivalence}, it is equivalent to \( \varphi \).
\end{algorithm}


\section{Stokes's Theorem}
\noindent
Let $C$ be a closed, counter-clockwise oriented curve in $\mathbb{R}^2$, and let $D$ be the region contained within $C$. Let $S$ be an open surface with opening boundary $C$, and let $V$ be the region contained inside $\tilde{S} = D \cup S$.

[INSERT IMAGE]

\noindent
Finding the flux of $\nabla \times \vec{F}$,
\begin{equation*}
	\oint\limits_{\tilde{S}}\oint{\nabla \times \vec{F}} = \iiint\limits_{V}{\nabla \cdot (\nabla \times \vec{F})\mathrm{d}V}
\end{equation*}
by Divergence Theorem. Since $\nabla \cdot (\nabla \times \vec{F}) = 0$,
\begin{equation*}
	\iint\limits_{D}{\nabla \times \vec{F}\mathrm{d}A} = \iint\limits_{S}{\nabla \times \vec{F} \cdot \mathrm{d}\vec{s}}
\end{equation*}
\begin{equation*}
	\oint\limits_{C}{\vec{F} \cdot \mathrm{d}\vec{r}} = \iint\limits_{S}{\nabla \times \vec{F} \cdot \mathrm{d}\vec{s}}
\end{equation*}
by Green's Theorem for Circulation. This is Stokes's Theorem.\\

\noindent
For example, let's use Stokes's Theorem to evaluate $\iint\limits_{S}{\nabla \times \vec{F} \cdot \mathrm{d}\vec{s}}$ where $S$ is the hemisphere $x^2 + y^2 + z^2 = 4, x \geq 0$ and $\vec{F}(x,y,z) = \langle yz, x\sin{z}, xyz^2 \rangle$.
\begin{equation*}
	S = \left\{(x,y,z) \mid x^2 + y^2 + z^2 = 2^2, x \geq 0 \right\}
\end{equation*}
\begin{equation*}
	C = \left\{(y,z) \mid y^2 + z^2 = 2^2 \right\} = \left\{(r,\theta) \mid r = 2, 0 \leq \theta \leq 2\pi \right\}
\end{equation*}
where $\theta$ is in the yz-plane.
\begin{equation*}
	C = \vec{r}(t) = \langle 0, 2\cos{t}, 2\sin{t} \rangle, 0 \leq t \leq 2\pi
\end{equation*}
\begin{equation*}
	\vec{F}\circ\vec{r} = \langle 4\cos{t}\sin{t}, 0, 0 \rangle
\end{equation*}
\begin{equation*}
	\vec{r^\prime}(t) = \langle 0, -2\sin{t}, 2\cos{t}\rangle
\end{equation*}
\begin{equation*}
	\left(\vec{F}\circ\vec{r}\right) \cdot \vec{r^\prime} = 0.
\end{equation*}
So,
\begin{equation*}
	\iint\limits_{S}{\nabla \times \vec{F}\mathrm{d}A} = \oint_{0}^{2\pi}{0\mathrm{d}t} = 0
\end{equation*}

\input{./vectorAnalysis/faradaysLawInductionAmperesLaw}


\subsection{Estimated State}
\workinprogress
Since the agent operates in a partially observable environment, the agent's internal state representation of the environment needs to take into account the fact that the current environment state is not certain. For this reason, a probability distribution over possible environment states is used by the agent to internally represent the environment state. The internal agent state is described mathematically by
\[p(x_t | e_{1:t}, u_{1:t})\]
which is the distribution of possible world states given all evidence and control actions up to the current time step, where $x_t$, $e_t$ and $u_t$ follow the conventions of being the hidden state variables, the evidence variables and the control action variables respectively. The agent updates this state using the world model specified in the preceding chapter, using the filtering algorithm explained in Section \ref{subsec:BGInfAlgos}. There are a couple of noteworthy points:
\begin{itemize}
    \item A distribution that has a single sharp peak would indicate that the agent believes that the target is at a specific location with high confidence. This is clearly preferred to a flat, uniform distribution representing uncertainty in relation to where the target might be.
    \item The only true source of uncertainty in the world state is introduced by the sensor. Therefore, analysis of this state representation in relation to the sensor model should provide insight into how the system performs.
\end{itemize}
\par In order to update the estimated state of the agent, the below equations are used, which are described in their general form in Section \ref{subsec:BGInfAlgos}. For brevity $x_t$ denotes the hidden state variables, $e_t$ denotes the evidence variables and $u_t$ denotes the control action taken by the agent. The equations only describe the estimated state update for move actions, since if the agent terminates the search a terminal state is deterministically entered. The $SearchStatus$ variable is omitted from the equations since it only effects the equations if the $Action$ variable is to terminate the search.
%\footnotesize
%\begin{equation}
\scriptsize
%\begin{equation}\label{eqn:SearchStatus}
%\[
    %\begin{cases}\label{eqn:AgentUpdateEquation}
    \begin{center}
    \begin{align}
    \begin{split}
    %\centering
        p(AgentLoc_t = x, TargetLoc_t = y | e_{1:t}, u_{1:t}) = &\\
       \begin{cases}
            \eta \alpha p(AgentLoc_{t-1} = x, TargetLoc_t = y | e_{1:t-1}, u_{1:t-1}) \text{ if $e_t$ is a positive reading and $AgentLoc_t \neq TargetLoc_t$} \\
            \eta \beta p(X_{t-1}=x_t | e_{1:t-1}, u_{1:t-1}) \text{ if $e_t$ is a negative reading and $Agent_loc_t$ = $TargetLoc_t$} \\
            \eta (1-\alpha) p(X_{t-1}=x_t | e_{1:t-1}, u_{1:t-1}) \text{ if $e_t$ is a negative reading and $Agent_loc_t \neq TargetLoc_t$} \\
            \eta (1-\beta) p(X_{t-1}=x_t | e_{1:t-1}, u_{1:t-1}) \text{ if $e_t$ is a positive reading and $Agent_loc_t$ = $TargetLoc_t$}
        %\end{cases}
%\eta O_{t} T^{T} f_{1:t-1}
    \end{cases}
    \end{split}
    \end{align}
    \end{center}
%\]
%\end{equation}
\normalsize

$\eta$ is a normalising factor, $\alpha$ is the probability of a sensor false positive detection and $\beta$ is the probability of a sensor false negative detection.


\chapter{Relativistic quantum mechanism}
\section{Klein Gordon equation}
In this chapter we consider two types of wave equations which have been proposed for the description of particles traveliing at speeds-close to that of light.At these speeds, the Iamiltonian of the (free) particle is no longer given by $\left(\mathbf{p}^{2} / 2 m\right)$; hence Schrödinger's equation, obtained from such a Hamiltonian by the prescription of Sec. $2.1$, is not applicable to relativistic particles. One could try to generalize the equation by using, instead of $\left(\mathbf{p}^{2} / 2 m\right)$, the relativistic expression for the energy, namely $E=\left(c^{2} \mathbf{p}^{2}+m^{2} c^{4}\right)^{1 / 2}$. The operator replacement $E \rightarrow i \hbar \partial_{i} t, \mathbf{p} \rightarrow-i \hbar \nabla$ would then lead to $i \hbar \partial \psi / \partial t=\left(-\hbar^{2} i^{2} \nabla^{2}+m^{2} c^{4}\right)^{1 / 2} \psi$ This equation has some obviously unattractive features. The space and time differential operators enter in it in very different ways. This is in contrast with the quite symmetric role of the space and time coordinates (as different components of a single four-vector) in relativity theory. The meaning of the operator$\left(-\hbar^{2} c^{2} \nabla^{2}+m^{2} c^{4}\right)^{1 / 2}$ is itself unclear. One could get around this by passing to the momentum representation. But even this possibility would disappear if the quantity under the square root were to be modified to include functions of $\mathbf{x}:$ for example, through the replacement $\mathbf{p} \rightarrow(\mathbf{p}-e \mathbf{A} / c)$ which becomes necessary when electromagnetic fields are present (assuming that the particle has charge $e$ ). Schrodinger suggested (immediately after his formulation of nonrelativistic quantum mechanics) that in order to avoid the difficulties arising from the square root, the operator replacement of $\mathbf{p}$ and $E$ be made in the relativistic expression for $E^{2}$ :
$$
E^{2}=c^{2} p^{2}+m^{2} c^{4}
$$
The resulting equation is
$$
-\hbar^{2} \frac{\partial^{2} \psi}{\partial t^{2}}=-\hbar^{2} c^{2} \nabla^{2} \psi+m^{2} c^{4} \psi
$$
or
$$
\frac{1}{c^{2}} \frac{\partial^{2} \psi}{\partial t^{2}}-\nabla^{2} \psi+\left(\begin{array}{c}
m c \\
\hbar
\end{array}\right)^{2} \psi=0
$$
This equation is konwn is as Klein Gordon equation .\\
 Meanwhile Dirac succeeded in constructing another equation which is of the first order in $(\partial / \partial t)$ and $\nabla$, unlike Eq. 10.2, and yet involves these operators in a fully symmetric way. The Dirac equation constrains the spin of the particle to be $\frac{1}{2}$. Its application to the electron was phenomenally successful, not only in helping to understand its propertics in a natural way, but more spectacularly, in the prediction of its anti-particle, the positron (which was later discovered in cosmic rays). The Klein-Gordon equation has nothing to say about the spin of the particle; it is ribe ane to be used for particles of spin 0 , like the $\pi$-and $K$-mesons.\\
 \subsubsection{plane wave Solution}
 $$
 \frac{1}{c^{2}} \frac{\partial^{2} \psi}{\partial t^{2}}-\nabla^{2} \psi+\left(\begin{array}{c}
 m c \\
 \hbar
 \end{array}\right)^{2} \psi=0
 $$
 Solutions to this equation corresponding to particles of definite momentum $\mathbf{p}=\hbar \mathbf{k}$ may be obtained by substituting $\psi(\mathbf{x}, t)=f(t) e^{i \mathbf{k} \cdot \mathbf{x}} .$ This leads to $d^{2} f \mid d t^{2}=\left[c^{2} \mathbf{k}^{2}+\left(m c^{2} / \hbar\right)^{2}\right] f$. Solving this we obtain (apart from a constant normalization factor), the plane wave solutions:
 $$
 \begin{aligned}
 \psi(\mathbf{x}, t) &=e^{i\left(\mathbf{k}_{\mathbf{x}} \mathbf{x} \mp \omega t\right)}=e^{i(\mathbf{p} \cdot \mathbf{x}-E t) / \hbar} \\
 E &=\pm \hbar \omega=\pm\left(c^{2} \mathbf{p}^{2}+m^{2} c^{4}\right)^{1 / 2}
 \end{aligned}
 $$
 In contrast to the nonrelativistic case where the coefficient $(E / \hbar)$ of $(-i t)$ in the exponent is the positive quantity $\left(\mathbf{p}^{2} / 2 m \hbar\right)$, here we have solutions with - $\omega$ as well as with $+\omega$. The appearance of the 'negative energy' solutions (characterized by $+\omega t$ in the exponent) is typical of relativistic wave equations;
 \subsubsection{Charge and current densities}
 Another difference from the nonrelativistic case is that $\psi^{*} \psi$ cannot be interpreted as the probability density $P(\mathbf{x}, t) .$ We expect $P(\mathbf{x}, \bar{t})$ to satisfy a continuity equation of the form  namely $\partial P \mid \partial t+\operatorname{div} \mathbf{S}=0$, which would ensure that $\int P(\mathbf{x}, t) d^{2} x$ is time-independent. To obtain such an equation we multiply klein gordon equation on the left by $\psi^{*}$, its complex conjugate equation by $\psi$, and subtract.
 The resulting equation can be written as
 $$
 \frac{1}{c^{2}} \frac{\partial}{\partial t}\left(\psi^{*} \frac{\partial \psi}{\partial t}-\psi \frac{\partial \psi^{*}}{\partial t}\right)-\nabla \cdot\left(\psi^{*} \nabla \psi-\psi \nabla \psi^{*}\right)=0
 $$
 This is a continuity cquation, with
 $$
 \begin{aligned}
 &P(\mathbf{x}, t)=\frac{i \hbar}{2 m c^{2}}\left(\psi^{*} \frac{\partial \psi}{\partial t}-\psi \frac{\partial \psi^{*}}{\partial t}\right) \\
 &{\mathbf{S}(\mathbf{x}, t)=-\frac{i \hbar}{2 m}\left(\psi^{*} \nabla \psi-\psi \nabla \psi^{*}\right)}
 \end{aligned}
 $$
 A convenient choice of a common constant factor in $P$ and $S$ has been made here. With this choice, S coincides exactly with the corresponding nonrelativistic expression. However, $P$ is quite different. It vanishes identically if $\psi$ is real, and in the case of complex wave functions, $P$ can even be made negative by choosing $\partial \psi / \partial t$ appropriately. Clearly, $P$ cannot be a probability density. One could multiply $P$ by a charge $e$ and then interpret it as a charge density (which can be positive or negative) and $S$ as the corresponding electric current density.
 \section{Dirac equation}
 The occurance of negative probability density is due to the presence of time derivatives in the expression for $P(r, t)$. This can be avoided by not allowing any time derivative other than the first order to appear in the wave equation. When the wave equation is of first order in time, it must be first order in space coordinates too. Dirac was probably influenced by the Maxwell's equations as they are first order equations in both space and time coordinates.\\
 As in Klein-Gordon equation, we can start from the basic energy equation, equation
 Replacing $E$ by $i \hbar \partial / \partial t$ and $p$ by $-i \hbar \nabla$ and allowing the $$E=\pm\left(c^{2} p^{2}+m^{2} c^{4}\right)^{1 / 2}$$
 Replacing $E$ by $i \hbar \partial / \partial t$ and $p$ by $-i \hbar \nabla$ and allowing the resulting operator equation to operate on the wavefunction $\Psi(r, t)$, we get\\
 $$i \hbar \frac{\partial \Psi(r, t)}{\partial t}=\pm\left(-c^{2} \hbar^{2} \nabla^{2}+m^{2} c^{4}\right)^{1 / 2} \Psi(r, t)$$
 To proceed further, we have to define the square root of an operator which is not yet defined. However, Dirac boldly wrote
 $$c^{2} p^{2}+m^{2} c^{4}=\left[c\left(\alpha_{x} p_{x}+\alpha_{y} p_{y}+\alpha_{z} p_{z}+\beta m c\right)\right]^{2}$$
 and then searched for conditions to be placed on the $\alpha$ 's and $\beta$ so that the equation is valid. For equation above to hold true, we must have
$$\left.\begin{array}{r}
	\alpha_{x}^{2}=\alpha_{y}^{2}=\alpha_{z}^{2}=\beta^{2}=1 \\
	\alpha_{x} \alpha_{y}+\alpha_{y} \alpha_{x}=\alpha_{y} \alpha_{z}+\alpha_{z} \alpha_{y}=\alpha_{z} \alpha_{x}+\alpha_{x} \alpha_{z}=0 \\
	\alpha_{x} \beta+\beta \alpha_{x}=\alpha_{y} \beta+\beta \alpha_{y}=\alpha_{z} \beta+\beta \alpha_{2}=0
\end{array}\right\}$$
That is, the $\alpha$ 's and $\beta$ anticommute in pairs and their squares are unity. These properties immediately suggest that they cannot be numbers. Already, we have a set of anticommuniting matrices, the Pauli's spin matrices. Hence, it is convenient to express them in terms of matrices. The energy can now be written as
$$E=\pm c\left(\alpha_{x} p_{x}+\alpha_{y} p_{y}+\alpha_{z} p_{z}+\beta_{m c}\right)$$
The positive or negative sign can be taken since replacement of $\alpha$ by $-\alpha$ and $\beta$ by $-\beta$ does not change the relationships between $\alpha$ 's and $\beta$. Hence the relativistic Hamiltonian of a particle can be taken as $$E=H=c \alpha \cdot p+\beta m c^{2}$$
Replacing $E$ and $p$ by their operators and allowing the resulting operator equation to operate on $\Psi(r, t)$, we
$$i \hbar \frac{\partial \Psi(r, t)}{\partial t}=-i c \hbar\left(\alpha_{x} \frac{\partial}{\partial x}+\alpha_{y} \frac{\partial}{\partial y}+\alpha_{z} \frac{\partial}{\partial z}\right) \Psi(r, t)+\beta m c^{2} \Psi(r, t)$$
which is Dirac's relativistic equation for a free particle.
\newpage
\begin{abox}
	Practice set 1
	\end{abox}
\begin{enumerate}
	\begin{minipage}{\textwidth}
		\item The Dirac Hamiltonian $H=c \vec{\alpha} \cdot \vec{p}+\beta m c^{2}$ for a free electron corresponds to the classical relation $E^{2}=p^{2} c^{2}+m^{2} c^{4}$. The classical energy-momentum relation of a piratical of charge $q$ in a electromagnetic potential $(\phi, \vec{A})$ is $(E-q \phi)^{2}=c^{2}\left(\vec{p}-\frac{q}{c} \vec{A}\right)^{2}+m^{2} c^{4}$.
		Therefore, the Dirac Hamiltonian for an electron in an electromagnetic field is
		\exyear{NET JUNE 2015}
	\end{minipage}
	\begin{tasks}(2)
		\task[\textbf{A.}] $c \vec{\alpha} \cdot p+\frac{e}{C} \vec{A} \cdot \vec{A}+\beta m c^{2}-e \phi$
		\task[\textbf{B.}]$c \vec{\alpha} \cdot\left(\vec{p}+\frac{e}{c} \vec{A}\right)+\beta m c^{2}+e \phi$
		\task[\textbf{C.}]$c\left(\vec{\alpha} \cdot \vec{p}+e \phi+\frac{e}{c}|\vec{A}|\right)+\beta m c^{2}$
		\task[\textbf{D.}]$c \vec{\alpha} \cdot\left(\vec{p}+\frac{e}{c} \vec{A}\right)+\beta m c^{2}-e \phi$
	\end{tasks}
\begin{minipage}{\textwidth}
	\item The dynamics of a free relativistic particle of mass $m$ is governed by the Dirac Hamiltonian $H=c \vec{\alpha} \cdot \vec{p}+\beta m c^{2}$, where $\vec{p}$ is the momentum operator and $\vec{\alpha}=\left(\alpha_{x}, \alpha_{y}, \alpha_{z}\right)$ and $\beta$ are four $4 \times 4$ Dirac matrices. The acceleration operator can be expressed as
	\exyear{NET DEC 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{2 i c}{\hbar}(c \vec{p}-\vec{\alpha} H)$
	\task[\textbf{B.}]$2 \mathrm{ic}^{2} \vec{\alpha} \beta$
	\task[\textbf{C.}]$\frac{i c}{\hbar} H \vec{\alpha}$
	\task[\textbf{D.}]$-\frac{2 i c}{\hbar}(c \vec{p}+\vec{\alpha} H)$
\end{tasks}
\end{enumerate}
\colorlet{ocre1}{ocre!70!}
\colorlet{ocrel}{ocre!30!}
\setlength\arrayrulewidth{1pt}
\begin{table}[H]
	\centering
	\arrayrulecolor{ocre}

	\begin{tabular}{|p{1.5cm}|p{1.5cm}||p{1.5cm}|p{1.5cm}|}
		\hline
		\multicolumn{4}{|c|}{\textbf{Answer key}}\\\hline\hline
		\rowcolor{ocrel}Q.No.&Answer&Q.No.&Answer\\\hline
		1&\textbf{d}&2&\textbf{a}\\\hline
	\end{tabular}
\end{table}


\section{Formulation of the isogeometric SBFEM}
\label{iso_section:formulation}
\paragraph{}
The nodal coordinates on the boundary are denoted as $\mathbf{x}_b$. As in a standard 1D iso-parametric finite element, the geometry of the element described by the coordinates $\mathbf{x}_b(\eta)$ as shown in Fig.~\ref{lr_fig:sbfem_intro}, is expressed as
\begin{equation}
    \mathbf{x}_b(\eta) = \mathbf{N}(\eta) \mathbf{x}_b
    \label{lr_eq:sbfem_boundary_interpolate}
\end{equation}
%
where $\mathbf{N}(\eta)$ is the shape function matrix.
Without loss of generality, the origin of the Cartesian coordinate system is chosen at the scaling center.
The geometry of the subdomain, described by $x$, is formed by scaling the boundary (Eq.~\ref{lr_eq:sbfem_boundary_interpolate})
\begin{equation}
    \mathbf{x} = \xi \mathbf{x}_b (\eta)
    \label{lr_eq:sbfem_scaling}
\end{equation}
%
where $\xi$ is the normalized radial coordinate running from the scaling center towards the boundary, with $\xi=0$ at the scaling center and $\xi=1$ on the boundary.
The coordinates $\xi$ and $\eta$ are the so-called scaled boundary coordinates.
They are related to the polar coordinates $r$ and $\theta$.
The transformation is expressed as
\begin{equation}
\begin{aligned}
    r(\xi,\eta) &= \xi r_b(\eta)     \\
    \theta(\eta) &= \arctan \frac{y(\eta)}{x(\eta)}
    \label{lr_eq:sbfem_transform}
\end{aligned}
\end{equation}
%
where $r_b$ is the distance from the scaling center to a point on the boundary.
The transformation between the Cartesian coordinates and the scaled boundary coordinates is similar to the coordinate transformation in the constructing iso-parametric finite elements.
The scaling center must be placed at the position so that all boundary of the domain is visible from the point.
This limitation can be easily solved by using a mesh generation algorithm described in Sec.~\ref{qdt_sec:main}.
The displacement at any point are approximated by
\begin{equation}
    \mathbf{u}(\xi,\eta) = \mathbf{N}(\eta) \mathbf{u}(\xi)
    \label{lr_eq:sbfem_disp_interpolation}
\end{equation}
%
where $\mathbf{N}(\eta)$ are the shape functions of elements on the boundary and $\mathbf{u}(\xi)$ is the displacement along the radial lines, represented by a set of N analytical functions.
By substituting Eq.~\ref{lr_eq:sbfem_disp_interpolation} into the definition of strain-displacement relations, the strain $\epsilon(\xi,\eta)$ are expressed as
\begin{equation}
    \epsilon(\xi,\eta) = \mathbf{Lu}(\xi,\eta)
    \label{lr_eq:sbfem_strain_disp_relation}
\end{equation}
%
where $\mathbf{L}$ is a linear operator matrix formulated in the scaled boundary coordinates
\begin{equation}
    \mathbf{L} =    \mathbf{b}_1(\eta) \frac{\partial}{\partial \xi} +
                    \frac{1}{\xi} \mathbf{b}_2(\eta)
    \label{lr_eq:sbfem_l_operator}
\end{equation}
%
and
\begin{equation}
    \begin{aligned}
    \mathbf{b}_1(\eta) & = \frac{1}{|J|}
            \begin{bmatrix}
                y_b(\eta),_{\eta}   &   0   \\
                0   &   -x_b(\eta),_{\eta}  \\
                -x_b(\eta),_{\eta} & y_b(\eta),_{\eta}
            \end{bmatrix} \\
    \mathbf{b}_2(\eta) & = \frac{1}{|J|}
            \begin{bmatrix}
                -y_b    &   0   \\
                0       &   x_b \\
                x_b     &   y_b
            \end{bmatrix}
    \end{aligned}
    \label{lr_eq:sbfem_little_b}
\end{equation}
%
The determinant of the Jacobian matrix is
\begin{equation}
    |J| = x_b(\eta)y_b(\eta),_{\eta}
        - y_b(\eta)x_b(\eta),_{\eta}
    \label{lr_eq:sbfem_Jdet}
\end{equation}
%
where $x_b(\eta)$ and $y_b(\eta)$ are given by Eq.~\ref{lr_eq:sbfem_boundary_interpolate}.
The stresses $\sigma(\xi,\eta)$ are given by:
\begin{equation}
    \sigma(\xi,\eta) =  \mathbf{DB}_1(\eta) \mathbf{u}(\xi),_{\xi} +
                        \frac{1}{\xi} \mathbf{DB}_2(\eta) \mathbf{u}(\xi)
    \label{lr_eq:sbfem_stress}
\end{equation}
%
where in the above equation, the definition of strain and the linear operator matrix given by Eq.~\ref{lr_eq:sbfem_strain_disp_relation} and Eq.~\ref{lr_eq:sbfem_l_operator} are used with
\begin{equation}
    \begin{aligned}
        \mathbf{B}_1(\eta) &= \mathbf{b}_1(\eta) \mathbf{N}(\eta)    \\
        \mathbf{B}_2(\eta) &= \mathbf{b}_2(\eta) \mathbf{N}(\eta),_{\eta}
        \label{lr_eq:sbfem_captial_b}
    \end{aligned}
\end{equation}
%
substituting Eq.~\ref{lr_eq:sbfem_strain_disp_relation} and Eq.~\ref{lr_eq:sbfem_stress} in the virtual work statement for elastostatics \citep{Deeks2002} and following the derivation
\begin{equation}
    \begin{aligned}
        \delta \mathbf{u}(\xi)^{T} \left(
            (\mathbf{E}_0 \xi \mathbf{u}(\xi),_{\xi}
            + \mathbf{E}_1^T \mathbf{u}(\xi))|_{\xi=1}
            - \mathbf{F}
        \right) - \\
        \int_0^1 \delta u(\xi)^T\left(
            \mathbf{E}_0 \xi^2 \mathbf{u}(\xi),_{\xi\xi} + (\mathbf{E}_0 + \mathbf{E}_1^T - \mathbf{E}_1) \xi \mathbf{u}(\xi),_{\xi}
            - \mathbf{E}_2 u(\xi)
        \right) d\xi = 0
    \end{aligned}
    \label{lr_eq:sbfem_virtual_work}
\end{equation}
%
where $\mathbf{u}(\xi)$ is the nodal displacement vector and $\mathbf{F}$ is the vector of equivalent boundary nodal forces, given by:
\begin{equation}
    \mathbf{F} = (\mathbf{E}_0 \xi \mathbf{u}(\xi),_{\xi} + \mathbf{E}_1^T \mathbf{u}(\xi))|_{\xi=1}
    \label{lr_eq:sbfem_nodal forces}
\end{equation}
%
By considering the arbitrariness of $\delta \mathbf{u}(\xi)$, the following ODE is obtained:
\begin{equation}
    \mathbf{E}_0 \xi^2 \mathbf{u}(\xi),_{\xi\xi} + (\mathbf{E}_0 + \mathbf{E}_1^T - \mathbf{E}_1)\xi \mathbf{u}(\xi),_{\xi} - \mathbf{E}_2 \mathbf{u}(\xi) = 0
    \label{lr_eq:sbfem_ODE}
\end{equation}
%
where $\mathbf{E}_0$, $\mathbf{E}_1$ and $\mathbf{E}_2$ are known as the coefficient matrices and are given by:
\begin{equation}
    \begin{aligned}
        \mathbf{E}_0 &= \int_\eta \mathbf{B}_1(\eta)^T \mathbf{DB}_1(\eta)|J|d\eta \\
        \mathbf{E}_1 &= \int_\eta \mathbf{B}_2(\eta)^T \mathbf{DB}_1(\eta)|J|d\eta \\
        \mathbf{E}_2 &= \int_\eta \mathbf{B}_2(\eta)^T \mathbf{DB}_2(\eta)|J|d\eta
    \end{aligned}
    \label{lr_eq:sbfem_coe_matrix}
\end{equation}
%
Eq.~\ref{lr_eq:sbfem_ODE} is a homogeneous second-order differential equation.
Its solution is obtained by introducing the variable $\mathbf{\chi}(\xi)$
\begin{equation}
    \mathbf{\chi} = \left\{
        \begin{matrix}
            \mathbf{u}(\xi)  \\
            \mathbf{q}(\xi)
        \end{matrix}
    \right\}
    \label{lr_eq:sbfem_ODE_soltion}
\end{equation}
%
where $\mathbf{q}(\xi)$ is the internal force vector
\begin{equation}
    \mathbf{q}(\xi) =   \mathbf{E}_0 \xi \mathbf{u}(\xi),_{\xi} +
                        \mathbf{E}_1^T \mathbf{u}(\xi)
    \label{lr_eq:sbfem_internal_force}
\end{equation}
%
The boundary nodal forces are related to the displacement functions by:
\begin{equation}
    \mathbf{F} = \mathbf{q}(\xi=1) = (\mathbf{E}_0\xi \mathbf{u}(\xi),_{\xi} + \mathbf{E}_1^T\mathbf{u}(\xi))|_{\xi=1}
    \label{lr_eq:sbfem_boundary_nodal_force}
\end{equation}
%
This allows Eq.~\ref{lr_eq:sbfem_ODE} to be transformed into a first order ordinary differential equation with twice the number of unknowns as:
\begin{equation}
    \xi \mathbf{\chi}(\xi),_{\xi} = -\mathbf{Z} \mathbf{\chi}(\xi)
    \label{lr_eq:sbfem_1stODE}
\end{equation}
%
where $\mathbf{Z}$ is a Hamiltonian matrix
\begin{equation}
    \mathbf{Z} = \begin{bmatrix}
        \mathbf{E}_0^{-1} \mathbf{E}_1^T    &  -\mathbf{E}_0^{-1}   \\
        \mathbf{E}_1 \mathbf{E}_0^{-1} \mathbf{E}_1^T - \mathbf{E}_2    &   -\mathbf{E}_1 \mathbf{E}_0^{-1}
    \end{bmatrix}
    \label{lr_eq:sbfem_zmatrix}
\end{equation}
%
An eigenvalue decomposition of $\mathbf{Z}$ is performed and it yields:
\begin{equation}
    \mathbf{Z} \begin{bmatrix}
        \mathbf{\Phi}_u \\
        \mathbf{\Phi}_q
    \end{bmatrix} = \begin{bmatrix}
        \mathbf{\Phi}_u  \\
        \mathbf{\Phi}_q
    \end{bmatrix} \mathbf{\Lambda}_n
    \label{lr_eq:sbfem_eigen_decomp}
\end{equation}
%
In Eq.~\ref{lr_eq:sbfem_eigen_decomp}, $\mathbf{\Lambda}_n$ $=$ diag$(\lambda_1$, $\lambda_2$, $\dots$, $\lambda_n)$ contains only the eigenvalues with negative real part.
$\mathbf{\Phi}_u$ and $\mathbf{\Phi}_q$ are the subsets of the eigenvectors corresponding to $\mathbf{\Lambda}_n$.
They represent the modal displacements and forces, respectively.
The general solution of Eq.~\ref{lr_eq:sbfem_1stODE} is given by:
\begin{align}
    \mathbf{u}(\xi) &= \mathbf{\Phi}_u \xi^{-\mathbf{\Lambda_n}} \mathbf{c}
    \label{lr_eq:sbfem_general_sol_disp} \\
    \mathbf{q}(\xi) &= \mathbf{\Phi}_q \xi^{-\mathbf{\Lambda_n}} \mathbf{c}
    \label{lr_eq:sbfem_general_sol_str}
\end{align}
%
where $\mathbf{c}$ are integration constants that are obtained from the nodal displacements $\mathbf{u}_b = \mathbf{u}(\xi=1)$ as:
\begin{equation}
    \mathbf{c} = \mathbf{\Phi}_u^{-1} \mathbf{u}_b
    \label{lr_eq:sbfem_int_constant}
\end{equation}
%
The complete displacement field of a point defined by the sector covered by a line element on the boundary is obtained by substituting Eq.~\ref{lr_eq:sbfem_general_sol_str} into Eq.~\ref{lr_eq:sbfem_disp_interpolation} resulting in:
\begin{equation}
    \mathbf{u}(\xi,\eta) = \mathbf{R}(\eta) \mathbf{\Phi}_u \xi ^{-\mathbf{\Lambda}_n} c
    \label{lr_eq:sbfem_displacement_field}
\end{equation}
%
Taking the derivative of $\mathbf{u}(\xi)$ with respect to $\xi$ and substituting into Eq.~\ref{lr_eq:sbfem_stress} the stress field $\sigma(\xi,\eta)$ can be expressed as:
\begin{equation}
    \sigma(\xi,\eta) = \mathbf{\Psi}_\alpha (\eta) \xi^{-\mathbf\Lambda}_n - \mathbf{I} \mathbf{c}
    \label{lr_eq:sbfem_stress_field}
\end{equation}
%
where the stress mode $\mathbf{\Psi}_\sigma(\eta)$ is defined as:
\begin{equation}
    \mathbf{\Psi}_\alpha(\eta) =    \mathbf{D}(
                                       -\mathbf{B}_1(\eta) \mathbf{\Phi}_u \mathbf{\Lambda}_n +
                                        \mathbf{B}_2(\eta) \mathbf{\Phi}_u
                                    )
    \label{lr_eq:sbfem_stress_mode}
\end{equation}
%
The stiffness matrix of an element is obtained by first substituting Eq.~\ref{lr_eq:sbfem_int_constant} into Eq.~\ref{lr_eq:sbfem_general_sol_str} at $\xi=1$.
This results in:
\begin{equation}
    \mathbf{F} = \mathbf{\Phi}_q \mathbf{\Phi}_u^{-1} \mathbf{u}_b
    \label{lr_eq:sbfem_kmat_previous}
\end{equation}
%
From Eq.~\ref{lr_eq:sbfem_kmat_previous}, the stiffness matrix $\mathbf{K}$ can be identified to be given by the expression
\begin{equation}
    \mathbf{K} = \mathbf{\Phi}_q \mathbf{\Phi}_u^{-1}
    \label{lr_eq:sbfem_kmat}
\end{equation}
%
The SBFEM has recently been extended to dynamic analysis in bounded domains \citep{Song2009}.
Assuming time-harmonic behavior, the scaled boundary equation in displacement is extended as:
\begin{equation}
    \mathbf{E}_0 \xi^2 \mathbf{u}(\xi),_{\xi\xi} +
    (\mathbf{E}_0 + \mathbf{E}_1^T - \mathbf{E}_1)\xi \mathbf{u}(\xi),_{\xi} -
    \mathbf{E}_2 \mathbf{u}(\xi) + \omega^2 \mathbf{M}_0 \xi^2 \mathbf{u}(\xi) = 0
    \label{lr_eq:sbfem_dynamic}
\end{equation}
%
Where $\mathbf{M}_0$ is a coefficient matrix defined as
\begin{equation}
    \mathbf{M}_0 = \int_\eta \mathbf{N}^T \rho \mathbf{N}|J| d\eta
    \label{lr_eq:sbfem_dynamic_mass}
\end{equation}
%
Using Eq.~\ref{lr_eq:sbfem_internal_force} and Eq.~\ref{lr_eq:sbfem_boundary_nodal_force}, Eq.~\ref{lr_eq:sbfem_dynamic_mass} can be transformed into an equivalent first-order non-linear differential equation in dynamic stiffness $\mathbf{S}(\omega)$,
\begin{equation}
    (\mathbf{S}(\omega)-\mathbf{E}_1)\mathbf{E}_0^{-1}
    (\mathbf{S}(\omega)-\mathbf{E}_1^T) - \mathbf{E}_2 +
    \omega \mathbf{S}(\omega),_\omega + \omega^2 \mathbf{M}_0 = 0
    \label{lr_eq:sbfem_dynamic_1stODE}
\end{equation}
%
The dynamic stiffness matrix $\mathbf{S}(\omega)$ relates the nodal forces to the displacements at the boundary as,
\begin{equation}
    \mathbf{F} = \mathbf{S}(\omega) \mathbf{u}(\xi=1)
    \label{lr_eq:sbfem_dynamic_nodal_force}
\end{equation}
%
Eq.~\ref{lr_eq:sbfem_dynamic_1stODE} is solved by expanding the dynamic stiffness into a series of continued fractions.
For this purpose, it is expressed as
\begin{equation}
    \mathbf{S}(\omega) = \mathbf{K} - \omega^2 \mathbf{M} + \omega^4 \left[
        \mathbf{R}^{(1)}
    \right]^{-1}
    \label{lr_eq:sbfem_dynamic_stiffness}
\end{equation}
%
In Eq.~\ref{lr_eq:sbfem_dynamic_stiffness}, the first two terms represent the low-frequency expansion of the dynamic stiffness, whereas the third term corresponds to the residual of the low-frequency approximation.
Substituting Eq.~\ref{lr_eq:sbfem_dynamic_stiffness} in Eq.~\ref{lr_eq:sbfem_dynamic_1stODE} and equating terms in increasing order of powers of $\omega$ to zero yields equations for $\mathbf{K}$ ,$\mathbf{M}$  and $\mathbf{R}^{(1)}$.
Setting the constant terms equal to zero yields an algebraic Riccati equation for the static stiffness matrix $\mathbf{K}$, which is equivalent to the solution process described earlier.
Setting all terms in $\omega^2$ equal to zero yields a Lyapunov equation for the low-order mass matrix $\mathbf{M}$.
The solution procedure of that Lyapunov equation is described in detail in \citep{Son1997}.
The remaining equation for the residual is solved by expanding  $\mathbf{R}^{(1)}$ as
\begin{equation}
    \mathbf{R}^{(1)} = \mathbf{S}_0^{(1)} - \omega^2 \mathbf{S}_1^{(1)} + \omega^4 [\mathbf{R}^{(2)}]^{-1}
    \label{lr_eq:sbfem_dynamic_R}
\end{equation}
%
Eq.~\ref{lr_eq:sbfem_dynamic_R} is analogous to the expansion of the dynamic stiffness, Eq.~\ref{lr_eq:sbfem_dynamic_stiffness}, where the coefficients $\mathbf{S}^{(1)}_0$ and $\mathbf{S}^{(1)}_1$ correspond to the `stiffness' and `mass' term of $\mathbf{R}^{(1)}$, respectively.
Equations for $\mathbf{S}^{(1)}_0$ and $\mathbf{S}^{(1)}_1$ are found by substituting Eq.~\ref{lr_eq:sbfem_dynamic_R} into the equation for $\mathbf{R}^{(1)}$.
This procedure is continued until the residual $\mathbf{R}^{M_{cf}+1}$ can be neglected.
The symbol of $M_{cf}$ denotes the order of continued-fraction expansion.
Substituting all terms of the expansion back into Eq.~\ref{lr_eq:sbfem_dynamic_stiffness} yields:
\begin{dmath}
    \mathbf{S}(\omega) =    \mathbf{K} - \omega^2 \mathbf{M} + \omega^4 \left(
                                \mathbf{S}_0^{(1)} - \omega^2 \mathbf{S}^{(1)} + \omega^4 \left(
                                    \mathbf{S}_0^{(2)} - \omega^2 \mathbf{S}^{(2)} + \dots +
                                    \omega^4 \left(
                                        \mathbf{S}_0^{(M_{cf})} - \omega^2 \mathbf{S}_1^{(M_{cf})}
                                    \right)^{-1}
                                \right)^{-1}
                            \right)^{-1}
\label{lr_eq:sbfem_dynamic_s_full}
\end{dmath}
%
The coefficients $\mathbf{S}^{(i)}_0$ and $\mathbf{S}^{(i)}_1$ in Eq.~\ref{lr_eq:sbfem_dynamic_s_full} are calculated following a recursive procedure.
A more detailed derivation can be found in \citep{Song2009}.


\lab{Facial Recognition using Eigenfaces}{Facial Recognition using Eigenfaces}
\label{lab:FacialRecognition}

\objective{In this lab we use the singular value decomposition to build a facial recognition system.}

Suppose we have a large database containing images of human faces together with identification information for each face.
Given an unidentified facial image, we would like to find a matching face in the database, thereby identifying the person in the image.
Such a task is known as \emph{facial recognition}.
This task may come up, for example, in law enforcement, when attempting to identify unknown persons in surveillance footage.
As humans, it is generally easy to compare two face images and determine whether the faces belong to the same person.
However, it becomes impractical for humans to visually compare one face image with several thousand other face images in a database.
Hence, we need a computational technique that automates the process of facial recognition.
One particularly simple and effective technique is known as \emph{eigenfaces}, which we now explore.

\section*{Eigenfaces}
The method of eigenfaces provides a mathematical and computational technique for efficiently storing and querying a database of face images.
As the name suggests, this method involves eigenvalues and eigenvectors of matrices related to the collection of face images at hand.
At its core, the method of eigenfaces maps each face image to a low-dimensional representation in a way that highlights the distinguishing
characteristics of the face while suppressing the irrelevant and unnecessary details.
In this light, eigenfaces can be viewed as a means of dimensionality reduction.
Let's get into the nuts and bolts of how this works.

Suppose we have a collection of $k$ face images represented as vectors $f_1, f_2, \ldots, f_k$ of length $l$.
(A digital image is normally represented by a $m \times n$ array of pixel values, but we can represented as a vector in $\mathbb{R}^{mn}$ by simply concatenating the rows of the array.)
Define the \emph{mean face} $\mu$ to be the average of each face vector:
\[
\mu = \frac{1}{k}\sum_{i=1}^k f_i.
\]
\begin{figure}
\includegraphics[width=0.3\textwidth]{meanFace.png}
\caption{The mean face.}
\label{facialRecognition:meanFace}
\end{figure}

\begin{problem}
\label{prob:getTrainingFaces}
Download the \li{faces94} face image database found at \url{http://cswww.essex.ac.uk/mv/allfaces/faces94.html} and extract the files.
You should now have a directory named ``faces94", which contains multiple face images each of a large collection of individuals.
We will construct a database of face images by selecting exactly one face image for each person in the directory.
Execute the following code to construct the collection of faces (you may need to change the variable \li{path} to point to the location
of the \li{faces94} directory on your machine):
\begin{lstlisting}
>>> import numpy as np
>>> from os import walk
>>> from scipy.ndimage import imread
>>> # these are the dimensions of the images
>>> w = 200
>>> h = 180
>>> # traverse the directory, get one image per subdirectory
>>> path = "./faces94"
>>> faces = []
>>> for (dirpath, dirnames, filenames) in walk(path):
>>>     for f in filenames:
>>>         if f[-3:]=="jpg": # only get jpg images
>>>             # load image, convert to grayscale, flatten into vector
>>>             face = imread(dirpath+"/"+f).mean(axis=2).ravel()
>>>             faces.append(face)
>>>             break
>>> # put all the face vectors column-wise into a matrix
>>> F = np.array(faces).T
\end{lstlisting}
The array \li{F} should be a $360000 \times 153$ matrix whose columns consist of 153 face images.
\end{problem}
\begin{problem}
\label{prob:meanFace}
Calculate the mean face image \li{mu} from the face image array \li{F} that you obtained in problem \ref{prob:getTrainingFaces}.
This can be done easily using \li{np.mean} and specifying the correct axis.

Plot the mean face.
As a convenience, you may use the following function to plot the image given just the flat vector representation:
\begin{lstlisting}
>>> from matplotlib import pyplot as plt
>>> import matplotlib.cm as cm
>>> def show(im, w=200, h=180):
>>>     """
>>>     Plot the w by h image whose pixel values are given by the array im.
>>>     """
>>>     plt.imshow(im.reshape((w,h)), cmap=cm.Greys_r)
>>>     plt.show()
>>> # given that you have calculated the mean face mu, show it
>>> show(mu)
\end{lstlisting}
Your mean face should match that shown in Figure \ref{facialRecognition:meanFace}.
\end{problem}
\begin{figure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{differenceFace0.png}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{differenceFace1.png}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{differenceFace2.png}
\end{subfigure}
\caption{Three mean-shifted faces from the dataset.}
\label{facialRecognition:differenceFaces}
\end{figure}
For each $i = 1,\ldots, k$, define $\bar{f}_i := f_i - \mu$.
The mean-shifted face vector $\bar{f}_i$ represents how the $i$-th face deviates from the average, and thus captures more directly the unique and distinguishing features of the face.
Now form the $l \times K$ matrix $A$ whose columns are given by the mean-shifted face vectors, i.e.
\[
A = \begin{bmatrix}
\bar{f}_1 & \bar{f}_2 & \cdots & \bar{f}_k
\end{bmatrix}.
\]
\begin{problem}
Using the face matrix \li{F} and the mean face \li{mu} from problems \ref{prob:getTrainingFaces} and \ref{prob:meanFace}, calculate the
matrix of mean-shifted face vectors \li{A}.
(This can be done in a nice, vectorized manner using array broadcasting.)
Plot the first mean-shifted face, i.e. the first column of the matrix \li{A}.
It should match the first face in Figure \ref{facialRecognition:differenceFaces}.
\end{problem}

Thus far, we have obtained the mean face vector $\mu$ and a representation of our collection of face images via the matrix $A$.
With just this matrix and the mean vector, how might we go about searching our collection of face images for the closest match to a new face image $g$?
A straightforward approach is to subtract the mean face vector from $g$, obtaining $\bar{g} = g-\mu$, and then compute the Euclidean distance from
$\bar{g}$ to each mean-shifted face vector $\bar{f}_i$, i.e. compute the Euclidean distance between $\bar{g}$ and each column of $A$.
Having done so, we can then choose the index $i$ where this distance $\|\bar{g}-\bar{f}_i\|_2$ is smallest, and return the $i$-th face image as the best match.
Although this approach is quite sensible, it become computationally expensive as the number and size of our face images increases.
What we need, then, is a way to reduce the dimensionality of our images.

\begin{comment}
The discussion in the paragraph below needs some work.
I need to better understand why the eigenfaces basis works so well.

Although this approach is quite sensible, there are a few issues.
Firstly, as the number of face images in our database grows large, both storing the full matrix $A$ and computing $\|\bar{g}-\bar{f}_i\|_2$ for all $i$
become increasingly difficult from a computational standpoint.
Secondly -- and this is the more important point -- calculating the Euclidean distance between two face images in the standard basis may not be the best measure
of how similar the two faces are (and empirical evidence supports this).
For example, if we have two images of the same face but with different backgrounds, the Euclidean distance between the face vectors may be very large,
since in the standard basis, every pixel is weighted equally.
Given these issues, it is natural to ask ourselves whether there exists a low-dimensional subspace with a basis in which we can represent our
face images with minimal error and where the Euclidean distance is a more robust measure of face similarity.
\end{comment}

Since the face images all have much in common, we have reason to hope that they all lie (nearly) in a low-dimensional subspace of $\mathbb{R}^l$.
The singular value decomposition of $A$ gives us just such a subspace.
In particular, if we write the singular value decomposition as
\[
A = U\Sigma V^H,
\]
then the columns of $U$ corresponding to the positive singular values form an orthonormal basis for the columns of $A$.
Recall that there are $r$ positive singular values, where $r$ is the rank of $A$.
Hence, if $r \ll l$, then we have found a low-dimensional subspace in which to represent our face vectors.
We call this subspace the \emph{eigenface subspace}, and we call each basis vector (i.e. each column of $U$ corresponding
to a positive singular value) an \emph{eigenface}.
\begin{figure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{eigenface0.png}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{eigenface1.png}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{eigenface2.png}
\end{subfigure}
\caption{The top three eigenfaces.}
\label{facialRecognition:eigenfaces}
\end{figure}
\begin{problem}
\label{prob:svd}
Calculate the singular value decomposition of the matrix \li{A} as follows:
\begin{lstlisting}
>>> from scipy imort linalg as la
>>> U,Sig,Vh = la.svd(A, full_matrices=False)
\end{lstlisting}
The keyword argument \li{full_matrices=False} cause the function to only return the columns of $U$ and $V$ corresponding
to positive singular values. Hence, \li{U} should be a $36000\times 153$ matrix whose columns are the eigenfaces.
Plot the first eigenface (i.e. the first column of \li{U}).
It should match the first eigenface shown in Figure \ref{facialRecognition:eigenfaces}.
By plotting some of the other eigenfaces, note that each has face-like properties, and different eigenfaces tend to capture different
types of facial structures.
\end{problem}

Not all of the eigenfaces are equally important, however.
In particular, the eigenfaces corresponding to the singular values closest to 0 contribute the least, on average, to the face vectors in $A$.
Thus, we can get away with only using the eigenfaces corresponding to the $n$ largest singular values (call these the top $n$ eigenfaces).
This is important when the rank $r$ is still too large to be practical.
Define $U_n$ to be the $l \times n$ matrix whose columns consist of the top $n$ eigenfaces.
The the coordinate vector of $\bar{f}_i$ in terms of these top $n$ eigenfaces is given by
\[
\hat{f}_i := U_n^H\bar{f}_i.
\]
Hence the matrix $\hat{A}$ defined by
\[
\hat{A}_n = \begin{bmatrix}
\hat{f}_1 & \hat{f}_2 & \ldots & \hat{f}_k
\end{bmatrix}
= U_n^HA
\]
contains as its columns the coordinate vectors of the face images in the top $n$ eigenfaces basis.
Note that $\hat{A}$ is an $n \times k$ matrix, and is therefore much smaller than the original $l \times k$ matrix $A$.
\begin{problem}
\label{prob:top_n}
The columns of the matrix \li{U} that you computed in problem \ref{prob:svd} are already ordered according to descending singular values.
Thus, the first $n$ columns of \li{U} give the top $n$ eigenfaces.
Write a function \li{nEigenfaces} that takes as input \li{U}, \li{A}, and an integer $n$, and returns the matrices $U_n$ and $\hat{A}_n$ as described above.
\end{problem}
\begin{figure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{rebuiltAll.png}
\caption{All of the eigenfaces.}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{rebuiltHalf.png}
\caption{1/2 of the eigenfaces.}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{rebuiltFourth.png}
\caption{1/4 of the eigenfaces.}
\end{subfigure}
\caption{Image rebuilt with varying number of eigenfaces}
\label{facialRecognition:rebuiltImage}
\end{figure}
Of course, moving to a lower-dimensional subspace by using only the top $n$ eigenfaces introduces some error, in the sense that we cannot perfectly
reconstruct the face images from their coordinate vectors.
However, this error is tolerable, provided $n$ is not \emph{too} small.
Note that we can approximately reconstruct $\bar{f}_i$ from the coordinate vector $\hat{f}_i$ by
\[
\bar{f}_i \approx U_n\hat{f}_i.
\]
See Figure \ref{facialRecognition:rebuiltImage} for examples of reconstructed face images giving different numbers of eigenfaces.

We now have a low-dimensional representation of our database of face images given by $\hat{A}_n$, an array of eigenfaces given by $U_n$,
and the mean face $\mu$. Using just these objects, we can now perform facial recognition.
Let $g$ be a face vector.
We seek to find the face vector $f_i$ in the database that is closest to $g$.
In order to do so, we must process $g$ just as we processed each $f_i$, namely by subtracting out the mean face and then projecting onto the
eigenfaces basis.
Doing so yields the low-dimensional representation $\hat{g}$, given by
\[
\hat{g} = U_n^H(g-\mu).
\]
We then return the matching face image $f_{i^*}$, where
\[
i^* = \text{argmin}_i \|\hat{f}_i - \hat{g}\|_2.
\]
\begin{problem}
\label{prob:nearest}
Write a function \li{findNearest} that accepts a matrix $M$ of shape $a \times b$ and a vector $x$
of length $a$, and returns the index of the column of $M$ that is closest to $x$ with respect to Euclidean distance.
Using the NumPy functions \li{np.linalg.norm} and \li{np.argmin} will be useful here.
\end{problem}

\begin{problem}
\label{prob:match}
We will perform facial recognition on additional images from the \li{faces94} dataset.

Use the following code to build an array of additional images from the dataset:
\begin{lstlisting}
>>> # let's gather some random images from the directory, and try to recognize them!
>>> n_tests = 10
>>> test_files = []
>>> for (dirpath, dirnames, filenames) in walk(path):
>>>     for f in filenames:
>>>         if f[-3:]=="jpg": # only get jpg images
>>>             test_files.append(dirpath+"/"+f)
>>> test_files = sample(test_files, n_tests)
>>> test_images = np.array([imread(f).mean(axis=2).ravel() for f in test_files]).T
\end{lstlisting}
You can change the variable \li{n_tests} to increase or decrease the number of face images to test.

Using your function \li{findNearest} from problem \ref{prob:nearest}, loop through the test images and find
the index of best matching image from the database.
As you do so, plot the test face alongside the matching face from the database to determine whether your system
really is properly recognizing the faces.
Use the following code to conveniently plot two face vectors side-by-side:
\begin{lstlisting}
>>> def show2(im1, im2, w=200, h=180):
>>>     """Plot face vectors im1 and im2 side-by-side."""
>>>     plt.subplot(121)
>>>     plt.imshow(im1.reshape((w,h)), cmap=cm.Greys_r)
>>>     plt.subplot(122)
>>>     plt.imshow(im2.reshape((w,h)), cmap=cm.Greys_r)
>>>     plt.show()
\end{lstlisting}

Repeat this experiment for different values of $n$, the number of eigenfaces to include.
The system should improve as $n$ gets larger.
\end{problem}

By this point, you have created a basic facial recognition system.
We can extend the system to detect when a face doesn't match anything currently in the database, and then add this new face into the database.
We can also make the system more robust by including multiple pictures of the same face with different expressions and lighting conditions.
Although there are other approaches to facial recognition that utilize more complex techniques, the method of eigenfaces remains
a wonderfully simple and effective solution and provides another illustration of the usefulness of the singular value decomposition in a variety of applications.

\begin{comment}
What remains is some old content.

\section*{Preparing the data}

Through the course of this lab we will be building a class called \li{FacialRec} to handle everything in the facial recognition system.
In the \li{specs.py} file included with this lab there is an outline of this class along with some helper functions to help us test our system.

To populate our database, we will need some images of faces.
There are many databases available online, many of which would work with our project.
However, the algorithm which we will use is not completely robust, it requires the images to have similar lighting conditions and head positions.
Tilted head, dark lighting, wearing glasses, and different hairstyles can disrupt the algorithm.
Therefore, we need a database that contains images with consistent lighting and head posistions.
Also, to make the programming easier, we would like the images to be of the same file type and size.
The University of Essex has such a database at http://cswww.essex.ac.uk/mv/allfaces/index.html, (as well as other databases with varied head positions and lighting conditions) which we will use.

The function \li{getImages} included in the specifications file loads all the JPG files from a directory into a 3 dimensional array.
The first dimension specifices the image while the other two give the grayscale image in a 2D array.
We can also use the function \li{showImage} to display the 2D grayscale images.
This will be useful for testing the database.

\begin{problem}
Download the faces94 database from the University of Essex from http://cswww.essex.ac.uk/mv/allfaces/index.html.
Initialize a \li{FacialRec} object using the file path to the directory and have it use every 50$^{th}$ face in the database.
Also, for testing purposes, use the function \li{getImages} to put the whole database into an array of images.
Then use \li{showImage} to show the first image.
\end{problem}

Now that we have images, we need to calculate a few things before we can compute the eigenfaces from the covariance matrix.
We have already reduced the images to grayscale images in \li{getImages} to make computations easier.
Now we need the mean face of all the faces in the database. The mean face is a 2D array of each pixel average across the database.
Next we need to zero out the images using the mean face.
We will substract the mean face from each face in the database, giving the the difference faces.
Then we flatten the each 2D image into a one dimensional vector so that we have each image described in single vector space.

\begin{problem}
Implement the functions \li{initMeanImage} and \li{initDifferences}.
\li{initMeanImage} should store in \li{self.meanImage} the image of the means across each pixel in the entire database.
\li{initDifferences} should first initilize \li{self.differenceFaces} to be an array of each image in the database minus the mean image.
\li{self.differenceVectors} should be the matrix with the flattened vector of each image in the database as its rows.
If the database has 75 images each of size $200 \times 180$, then \li{self.differenceVectors} should be $75 \times 36000$.
Also, plot the mean face and the first difference face.
\end{problem}

\section*{Computing the Eigenfaces with SVD}

With these pelimanaries ready, we are now able to construct the Eigenfaces of the system from the covariance matrix.
At this point we have each image descibed in a vector space with as many pixels as there are in each image.
With the database we are using, this is a 36000 dimensional vector space.
There are too many random variables to work with at this point to work with, so we need to find some way to simplify the vector space.

We do this using the eigenvectors of the covariance matrix (which we call the eigenfaces).
The eigenfaces form a basis of all possible faces, so all faces could be expressed as a linear combination of eigenfaces from the covariance matrix gathered from faces in the database.
The corresponding eigenvalues of the eigenfaces give the weight or importance of each eigenface.
Now there the covariance matrix is still very large 36000 and could have many distinct eigenvectors.
However, only eigenfaces corresponding to higher eigenvalues really make a difference.
Infact, it turns out that there are only as many eigenvalues as there are images in the database.

Recall that taking the SVD of a real valued matrix $A$ gives us the eigenvectors of the matrix $AA^T$ in the columns of $V$.
If the difference vectors are denoted by $E$, then the covariance matrix is $C = EE^T$.
It then follows that we can use the SVD of $E$ to compute the eigenvectors of $C = EE^T$.

The \li{svd} function from \li{scipy.linalg} returns $U,V,V^T$. You can then get the eigenfaces with a call like
\begin{lstlisting}
u,s,vT = la.svd(self.differenceVectors,full_matricies=False)
self.eigenfaces = vT
\end{lstlisting}
This will put into \li{eigenfaces} the eigenfaces of the database as its rows.

\begin{problem}
Implement the function \li{initEigenfaces} by computing the eigenfaces of the images in the database using the SVD and storing them in \li{self.eigenfaces}.
The eigenfaces should be in the columns of \li{self.eigenfaces} so that it becomes a $36000 \times 75$ matrix.
Plot the first three eigenfaces.
\end{problem}

With the eigenfaces computed, we can now convert vectors representing faces into the eigenface space and back.
To convert to the eigenface space we first subtract off the mean face, flatten the vector, then project the vector on the eigenfaces.
To rebuild an image from its representation in eigenfaces, we simply add up the linear combination of eigenfaces then add back in the mean.

\begin{problem}
Implement the functions \li{projectToImageFaceSpace} and \li{rebuildFromEigenfaces}.
\li{projectToImageFaceSpace} should project an image into its coordinates in the basis of the eigenfaces.
\li{rebuildFromEigenfaces} should undo that projection by taking the coordinates in the eigenface space, projecting them back, and reshaping the image.
\end{problem}

\section*{Creating the Facial Recognition System}

The facial recognition database is almost done.
Given a face to seach for, we only have to project it into the eigenface basis and then perform a nearest neighbor seach for the closest image.

\begin{problem}
Implement the functions \li{initClassifier}, and \li{findNearest}.
\li{initClassifier} should initialize \li{self.nbrs} as a \li{sklearn.neighbors.KNearestNeighbors} with \li{nearest_neighbors=1}.
Create a set of training points from the images in the database projected into the eigenface basis and use the first \li{searchOrder} number of coefficeints in the \li{self.nbrs.fit} function.
For the labels give the indicies of the labels in the database (this can be done with \li{range})

Implement \li{findNearest} by subtracting off the mean face from the image and then projecting it into the eigenface basis.
Then perform a nearest neighbor search with the coefficeints up to \li{searchOrder} using \li{self.nbrs.predict}.
This will return an index to the matching image.

We also want to compute the distance of the image to the matching image to see if it's really a good match.
Do this by projecting the matching image to the eigenface basis and then taking the norm of its difference from the image passed in but in the eigenface basis.
\end{problem}

\begin{problem}
Verification

Your facial recognition database should be working now.
Try it on some exact images that are in the database, some faces that are in the database but that aren't exact copies, and faces that aren't in the database at all.
(Pick a random image from the full set, it probably won't be in the database.
 All images that are a multiple of \li{fileStep} are in the database.
 Indicies close to these are probably of the same person but a different picture.
 As you do all of these take note of the distance between the match and the image.
 Chose a reasonable limiting distance to designate a match or false match and add whether this condition is satisfied as a boolean.
\end{problem}
\end{comment}


\section{Errors}

The error boundaries for the classifiers were obtained
for both the Chernoff and Bhattacharyya Bounds \cite{duda2012pattern}.

For the Chernoff Bounds, the following equations were employed.

\begin{align*}
 \min[a,b] & \leq a^\beta b^{1-\beta}  \quad \text{for } a,b \geq 0 \text{ and } 0\leq \beta \leq 1  \\
 P(\text{error}) & \leq P^\beta (\omega_1) P^{1-\beta} (\omega_2) \int p^\beta (x | \omega_1)p^{1-\beta}(x|\omega_2)dx  \text{ for } 0 \leq \beta \leq 1\\
\int p^\beta &(x | \omega_1)p^{1-\beta}(x|\omega_2)dx  = \exp(-k(\beta)) \\
k(\beta) &= \frac{\beta(1-\beta)}{2} (\mu_2 - \mu_1)^T \det(\beta  \Sigma_1 + (1-\beta)\Sigma_2)^{-1} (\mu_2 - \mu_1) \\
& \quad + \frac{1}{2} \ln \frac{\det(\beta \Sigma_1  + (1-\beta)\Sigma_2)}{\det(\Sigma_1)^\beta \det(\Sigma_2)^{1-\beta}}
 \end{align*}

 Likewise, for the Bhattacharyya Bounds another set of equations was utilized

\begin{align*}
 P(\text{error}) & \leq \sqrt{P{\omega_1} P(\omega_2)} \int \sqrt{p(x | \omega_1) p(x|\omega_2)} dx\\
 &= \sqrt{P{\omega_1} P(\omega_2)} \exp{-k(1/2)}\\
 k(1/2) &= \frac{1}{8}(\mu_2 - \mu_1)^T \det(\frac{\Sigma_1 + Sigma_2}{2})^{-1} (\mu_2 + mu_1) \\
 & \quad + \frac{1}{2} \ln \frac{\det(\frac{\Sigma_1 + \Sigma_2}{2})}{\sqrt{\det(\Sigma_1)\det(\Sigma_2)}}
\end{align*}

\subsection{Case A}

For this case, the Chernoff bounds were determined to be

\begin{table}[htb]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.3712\%\\
$P_{23}$ & 11.3240\%\\
$P_{31}$ & 0.0016\%
\end{tabular}
\end{center}
\caption{Case A - Chernoff Bound}
\label{tab: case a chernoff}
\end{table}

Likewise the Bhattacharyya bounds were determined

\begin{table}[htb]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.3712\%\\
$P_{23}$ & 11.3240\%\\
$P_{31}$ & 0.0016\%
\end{tabular}
\end{center}
\caption{Case A - Bhattacharyya Bound}
\label{tab: case a bhatt}
\end{table}

\begin{figure}
 \centering
 \includegraphics{errorCaseA}
 \caption{Case A - Error bound}
 \label{case a error}
\end{figure}

The experimental error was also examined for the data set.

\begin{table}[htb]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.000\%\\
$P_{23}$ & 4.000\%\\
$P_{31}$ & 0.000\%
\end{tabular}
\end{center}
\caption{Case A - Experimental error}
\label{tab: case a experiment}
\end{table}

% errorExp =
%
%          0    0.0400         0

\newpage
\pagebreak

\subsection{Case B}

For this case, the Chernoff bounds were determined to be

\begin{table}[htb]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.0049\%\\
$P_{23}$ & 6.3073\%\\
$P_{31}$ & 0.0000\%
\end{tabular}
\end{center}
\caption{Case B - Chernoff Bound}
\label{tab: case b chernoff}
\end{table}

Likewise the Bhattacharyya bounds were determined

\begin{table}[htb!]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.0049\%\\
$P_{23}$ & 6.3073\%\\
$P_{31}$ & 0.0000
\end{tabular}
\end{center}
\caption{Case B - Bhattacharyya Bound}
\label{tab: case b bhatt}
\end{table}

\begin{figure}
 \centering
 \includegraphics{errorCaseB}
 \caption{Case B - Error bound}
 \label{case b error}
\end{figure}

The experimental error was also examined for the data set.

\begin{table}[htb]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.000\%\\
$P_{23}$ & 8.000\%\\
$P_{31}$ & 0.000\%
\end{tabular}
\end{center}
\caption{Case B - Experimental error}
\label{tab: case b experiment}
\end{table}

% errorExp =
%
%          0    0.0800         0

\newpage
\pagebreak

\subsection{Case C}

For this case, the Chernoff bounds were determined to be

\begin{table}[htb!]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.0012\%\\
$P_{23}$ & 7.9909\%\\
$P_{31}$ & 0.0000\%
\end{tabular}
\end{center}
\caption{Case C - Chernoff Bound}
\label{tab: case c chernoff}
\end{table}

Likewise the Bhattacharyya bounds were determined

\begin{table}[htb!]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.0074\%\\
$P_{23}$ & 8.0726\%\\
$P_{31}$ & 0.0000\%
\end{tabular}
\end{center}
\caption{Case C - Bhattacharyya Bound}
\label{tab: case c bhatt}
\end{table}

\begin{figure}
 \centering
 \includegraphics{errorCaseC}
 \caption{Case C - Error bound}
 \label{case c error}
\end{figure}

The experimental error was also examined for the data set.

\begin{table}[htb]
\begin{center}
\begin{tabular}{ll}
$P_{12}$ & 0.000\%\\
$P_{23}$ & 3.333\%\\
$P_{31}$ & 0.000\%
\end{tabular}
\end{center}
\caption{Case C - Experimental error}
\label{tab: case c experiment}
\end{table}

% errorExp =
%
%          0    0.0333         0